ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

The most efficient to way to split a Tensor into two?

Open jialiang19 opened this issue 9 years ago • 1 comments

Hey Everyone:

Currently, I am implementing the original AlexNet using the Library with OpenCL support, and the original implementations require one to split one CLTensor into two CLTensors. From the issue #8, I learnt that there is no function currently int the library can do it. It is users' responsibility to split the CLTensors.

Currently, the only way I know is to use Window to copy data from CLTensor into a c++ array, then use another Window to copy data from the c++ array into two CLTensors. This will work, but the large data transfer is just so inefficient. This will slow down the performance drastically.

Is there a way that I can make first CLTensor's buffer's pointer pointing to the beginning of the CLTensor needed to be split and second CLTensor's buffer's pointer pointing to the midway of the CLTensor without massive data transferring? Can you show me some sample code?

If there is a way, Is there an efficient way to merge two CLTensor together also?

Thanks!

jialiang19 avatar Jun 22 '17 12:06 jialiang19

Hello @jialiang19,

We added in the latest release support to create subtensors from existing tensor. In this manner, you can split a tensor to multiple ones and use the same backing memory. In OpenCL, though its a bit more complicated. If you have a Mali DDK version greater than r13p0 then subtensors should work perfectly fine, for earlier releases you might face some issues. Give it a try and we will be glad to help you in case of any issues.

GeorgeARM avatar Jul 03 '17 10:07 GeorgeARM