The problem here is that a std::vector can’t use “foreign” memory.
Some avenues that might work:
Use a pointer (int32_t* ) as an array or a ArrayRef<int32_t> (available in c10). In this case you need to keep the tensor allocated while you are using them. Also note that you need to be a bit careful with strides if your tensor can be non-contiguous.
Allocate the memory in the vector and then use from_blob to get a tensor. In this case you need to keep the vector around while using the tensor.