Thanks for the reply.
I’m trying to link the pytorch tensors and nn functions to another environment via a c interface.
e.g. allocate tensors via THTensor_… or THCTensor_… routines, pass the c pointer through a c-api to another interpreter.
No python, but i could probably start up higher with the c++ library routines if i could figure out how to pass the pointer through, e.g.
Tensor t=CPU(kFloat).ones({3, 4});
void *p=&t;
i don’t think i can use a pointer like the above since tensor t may be deleted out from under me as it goes out of scope.
so for now, i’ve been using the c-structure for a tensor.
processing through subsets of inputs is quick without the need to copy sizes & strides and the storage ptr to another tensor and incrementing the reference count.
origOffset = t->storageOffset;
origSize=t->size[dim];
then, subsets are quick:
t->size[dim]=n;
t->storageOffset = origOffset + index * t->stride[dim]