extension-ffi icon indicating copy to clipboard operation
extension-ffi copied to clipboard

C++ testing and validation

Open chenjun2hao opened this issue 6 years ago • 1 comments

How can I be in c + + compiler environment, testing and validation. there the ‘THFloatTensor_data’ is not defined, when i use the code as follow:

int my_lib_add_forward(THFloatTensor *input1, THFloatTensor *input2,
		       THFloatTensor *output)
{
  float * data_flat = THFloatTensor_data(input1);
}

chenjun2hao avatar Apr 04 '19 08:04 chenjun2hao

Hi, you can try to write something like

include<torch/torch.h>

int my_lib_add_forward(at::Tensor *input1, at::Tensor *input2, at::Tensor *output){ auto tmp = input1->contiguous(); float *data_flat = tmp.data(); }

good luck

ztianlin avatar May 28 '20 09:05 ztianlin