How can I assign the all value of src_data1 to input0 without FOR loop?
Hi, I want to assign the value of src_data1 to input0 without FOR loop.
neon_gemmlowp.cpp . . . Tensor input0; . . . const char src_data1 = a; //a is a single-dimensional array . . . //For input0 for( int z = 0; z < ifm_src_img; ++z) { for( int y = 0; y < height_src1_image; ++y) { for( int x = 0; x < width_src1_image; ++x) { * reinterpret_cast<char>( input0.buffer() +input0.info()->offset_element_in_bytes(Coordinates(x,y,z))) = src_data1[ z * (width_src1_imageheight_src1_image) + y * width_src1_image + x]; } } } //std::cout << "Look"<<std::endl; //For input1 for( int z = 0; z < ifm_src_img; ++z) { for( int y = 0; y < height_src2_image; ++y) { for( int x = 0; x < width_src2_image; ++x) { * reinterpret_cast<char>( input1.buffer()+input1.info()->offset_element_in_bytes(Coordinates(x,y,z))) = src_data2[ z * (width_src2_image*height_src2_image) + y * width_src2_image + x]; } } } . . .
Hi, you can use the iterator and execution window instead. You can memcpy each row. There is an example at https://github.com/ARM-software/ComputeLibrary/blob/master/examples/neon_copy_objects.cpp.
But this method even runs slower than my method. Is there any other method that can assign the value of src_data to input quickly without FOR loop and execution window?
Unfortunately as the tensor has padding around the two-dimensional image, one can't simply memcpy the whole single dimensional array into a Tensor. You have to at least iterate each row.
Thanks a lot, I'd seek other method
That's sad. I would like to be able to use the buffer directly like NNPACK.
we are planning zero-copy method by which you can use the buffer directly. Hopefully, it could be ready at next quarter.
Hello @duhuanxianzi,
Well you could create a tensor with the shape that you want and allocate upfront without passing it to any function which might add padding to it. Then you could directly memcpy the buffer to it, but be aware that any Function you configure with this tensor might shrink the execution window as it doesn't have the padding that a kernel might require. While this is OK for vision functions might be destructive for Neural Network ones (depending on your model).
Concerning the zero-copy method we are planning to add, I think the current limitation will be the same as the one I mentioned above. You could directly say to a tensor use this memory and do not allocate yourself but then again the tensor will lock and will have to shrink the execution window in case padding is required.
Hi, I have solved this problem. And the efficiency of the new method is faster than before.
Thanks a lot!
Closing. Reopen if required.