mardi 27 mars 2018

How to access the indices of a tensorflow::tensor?

I have implemented the standard tutorial of https://www.tensorflow.org/extend/adding_an_op, but how to access the values of input:

auto input = input_tensor.flat<int32>();

The registered kernel is gpu

REGISTER_KERNEL_BUILDER(Name("ZeroOut").Device(DEVICE_GPU), ZeroOutOp);

I have tried several methods:

input(0,0); // segmentation fault

input.data()[0]; // segmentation fault 

Eigen::array<long,1> offset = {0};
Eigen::array<long,1> extent = {0}; 
input.slice(offset, extent) // does print an empty line

 const float *input = input_tensor.flat<float>().data();
 input[0]; // segmentation fault

Aucun commentaire:

Enregistrer un commentaire