Get the data from INPUT tensor
MESeraph opened this issue · comments
@sunshinemyson
CopyDataToTensor() will not used according to the current structure of my case.
Hello. In the old APIs, data_
stores a pointer to original input data blob, which is a "wild pointer" now that a user may free the memory block immediately after CreateTensor
returns.
Therefore, if you don't need CopyDataToTensor
, but just want to access the input blob again, then I suggest you change CreateTensor({::Input, ...}, input_ptr)
into CreateIOTensor(...)
. The new API keeps data_
there, and it can work almost the same as CreateTensor
, if only you don't modify or release the input blob on input_ptr
.
If your tensor is not TensorAttribute::INPUT
, could you share your detailed use case then?
@gdh1995 Thank You! I Got.
I need modify input data of some Op. For example,indices of onehot/gatherelements, TIM-VX is not support negative.
But it just be used in my Op unittest.
I'm not sure what you meant. But if just to modify input data and re-run forwarding, you may call Graph::CreateIOTensor
, and then call Tensor::FlushCacheForHandle
everytime you have modified the memory area of a input blob.
BTW, as far as I've understand from TIM-VX source code, with the old APIs, if you modified the memory area of a input tensor's data_
, the real input data used in graph forwarding would not be updated. You'll have to use CopyDataToTensor
to sync your modification.