Memory assignment to Tensor
Hi,
Can I allocate a buffer and assign that ptr to Tensor for neon based layers as shown below
float* buf=new float[size] Tensor.allocator()->allocate(buf)
instead of using the existing allocation strategy
Tensor.allocator()->allocate() Is there any overloaded function for allocate as it is for memory Memory(uint8_t *memory);
If I do so , are there any repercussions? do I need to handle any extra things?
Thanks
Hi,
Instead of doing Tensor.allocator()->allocate() you can do Tensor.allocator()->import_memory(arm_compute::Memory(your_ptr))
However you need to make sure the alignment/padding meet the minimum requirements or it will not work.
Thanks for quick reply. I will use the Tensor specific details for assigning memory, for memory increase after configure. But my concern is, Is it ok to maintain always doubleword alignment ?
I assume it is enough if I maintain the double word alignment and handle the padding requirements? If the padding is handled do we need to always maintain the padded element values to be zeroes?
Yes, as long as you handle the padding requirements it should work. The function will automatically zero the padding bytes for you if it relies on their values
I want to know about the impact on the output, if the padded elements of input are non-zeroes.
Example Scenario
If I have actual input/output size of 10, and due to the padding requirements let us say configure will change it to 16.
In this case, Does the read/write happen on the 16 values or only on the 10 values. If I give a buffer of 16 values size which as input with last 6 values are other than zeros , does it impact the output values?
It depends, sometimes padding is required by vector loads, sometimes by vector store, so can't really tell if the padding bytes will be written to. However the content of the padding bytes won't affect the output: if a kernel uses the values from the padding bytes then the ACL Function will run a fill border kernel before that kernel to make sure the value of the padding bytes won't affect the output of the kernel
Good to know that " padding bytes won't affect the output of the kernel" .Thanks Anthony.
@Subarukun what is the reason for reopening this?