ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

Mapping a pointer (of pre-existed data) to/from an ACL Tensor for processing ?

Open terablade2001 opened this issue 8 years ago • 3 comments

Hi,

Is it possible to map pre-existed memory data to/from a Tensor for processing with ACL, in order to avoid needless memory copies - supposing the data has been already set by the user in the proper format? (At least for CPU cases, as GPU systems may require data transfers).

I mean something like Eigen's Map<>() utility, e.g.: float *ptrA = userLoadData(); Eigen::Map<Eigen::Matrix<float, Dynamic, Dynamic, RowMajor>> A(ptrA, rows, cols).

Can this be done with Arm Compute Library?

  • If yes can someone provide an example for GeMM between two arrays that has been pre-allocated (&initialized) to memory with, e.g., malloc()?

Or using iterators / memcpy (as described in docs) is the only available option?

Thanks in advance..

terablade2001 avatar Jan 23 '18 08:01 terablade2001

Hello @terablade2001,

Yes, for the NEON part this is feasible. You can import externally allocated memory to a tensor. There is a unit test here on how to do so. You have to be aware though that ACL requires padding in most of the operations, thus if your allocation cannot accommodate the padding then it will shrink the execution window and will calculate the GEMM on this window only (which will lead to incorrect results). We are adding capabilities to check if the allocation is ok or will shrink the window but it hasn't been added yet for GEMM.

GeorgeARM avatar Feb 09 '18 11:02 GeorgeARM

You can also have a look at this issue: https://github.com/ARM-software/ComputeLibrary/issues/296#issuecomment-358730182

AnthonyBarbier avatar Feb 13 '18 16:02 AnthonyBarbier

Closing. Reopen if needed. Mapping pre-existing tensor is feasible using import memory entrypoints of Tensor.

GeorgeARM avatar Jun 02 '18 09:06 GeorgeARM