Mapping a pointer (of pre-existed data) to/from an ACL Tensor for processing ?
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..
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.
You can also have a look at this issue: https://github.com/ARM-software/ComputeLibrary/issues/296#issuecomment-358730182
Closing. Reopen if needed. Mapping pre-existing tensor is feasible using import memory entrypoints of Tensor.