Solved by tom in post #2 
              
              
                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 carefu…