C Api creating tensor and accessing it

Good morning,

I am implementing some functions in C to speed up part of my code, however when trying to use TH functions I have few problems.
I am trying to create a 2D tensor using :

THFloatTensor * IoU = THFloatTensor_newWithSize2d(nb1,nb2);
Which does’nt raise any errors. But when compiling the functions :

THTensor_get2d and THTensor_set2d
give me warnings, and during execution the set function give the error :

undefined symbol: THTensor_set2d

But those functions seems to be well defined in https://github.com/pytorch/pytorch/blob/master/aten/src/TH/generic/THTensor.h

Any idea ?

Also when working with CPU Tensors, should I include

#include <TH/TH.h>

To be able to use




I am a bit lost about how to manipulate and create tensors in C. I was creating them in python before and manipulated them in C as 1D arrays.

Please use the C++ API instead.https://pytorch.org/cppdocs/

I have already quite some functions implemented in C to interface some Cuda code with my python code, Isn’t there any way for me to make this work using types such as THCudaTensor or THFloatTensor ?
Especially as this is a very easy way to use data created in python directly in C and Cuda.

I am for now using the tensor as a float * to access its elements and create it in python directly.