cppflow icon indicating copy to clipboard operation
cppflow copied to clipboard

How to extract a string from tensor?

Open abucka opened this issue 4 years ago • 2 comments

Hi,

I have a string tensor that looks like this:

(tensor: shape=[1], data= ["0007 HMS\342\226\221\342\226\221\342\226\221"])

How can I decode and extract the string? or just extract the string and decode in C++?

abucka avatar Jun 28 '21 15:06 abucka

when I want to extract the data using var.get_data<std::string>() I run into the sigfpe (arithmetic error) on this line from tensor.h: size_t size = TF_TensorByteSize(res_tensor) / TF_DataTypeSize(TF_TensorType(res_tensor));

I would really appreciate any help! :)

abucka avatar Jul 01 '21 10:07 abucka

Hi @abucka

I am not quite sure right now, but I would say that you need to work with char, not with std::string.

serizba avatar Mar 03 '22 16:03 serizba

Closing due to inactivity.

serizba avatar Sep 23 '22 11:09 serizba