VeriSilicon / TIM-VX

VeriSilicon Tensor Interface Module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get the data from INPUT tensor

MESeraph opened this issue · comments

image
I need the data of INPUT tensor.
But I see that you have added restrictions on INPUT/OUTPUT tensor recently.
If it is removed, will it have other effects?

commented

@MESeraph ,

Is it possible use CopyDataToTensor() in your case? In principle, we should keep original API definition. But this change is raised by @gdh1995 who would like to use "TENSOR_HANDLE", I need to make a PR and send you and @gdh1995 to review.

@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.

@gdh1995 Thank you! I will check how use these APIs.