cppflow icon indicating copy to clipboard operation
cppflow copied to clipboard

Can you provide a tf.example as input example?

Open hudengjunai opened this issue 3 years ago • 4 comments

Thank you for your cppflow lib. I'm integrated this lib in my inference server. but I encountered some problem.

my model is like this

 MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:

signature_def['serving_default']:
  The given SavedModel SignatureDef contains the following input(s):
    inputs['examples'] tensor_info:
        dtype: DT_STRING
        shape: (-1)
        name: input_example_tensor:0
  The given SavedModel SignatureDef contains the following output(s):
    outputs['prob'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1)
        name: Sigmoid:0
  Method name is: tensorflow/serving/predict

so how can I call like below

TF_TString tstr[16];
  int in_index=0;
  for (const auto &sample : section) {
    TF_TString_Init(&tstr[in_index]);
    TF_TString_Copy(&tstr[in_index], sample.c_str(), sample.size());
    //sample = tf.example.Serializetotring();
    in_index++;
  }

  int item_count = section.size();
  TF_Tensor
      *tf_tensor = TF_NewTensor(TF_STRING, nullptr, 0,  &tstr[0], section.size(), deallocator, nullptr);
  cppflow::tensor cp_tensor = cppflow::tensor(tf_tensor);
  inputs.push_back(std::make_tuple("input_example_tensor:0"s, cp_tensor));
  ```

but encuntered some problem

So, my question is ." how can I set tf.Example as input for cppflow", I want some examples code or snippet code to solve it. thanks.

hudengjunai avatar May 06 '22 09:05 hudengjunai

Thank you for your cppflow lib. I'm integrated this lib in my inference server. but I encountered some problem.

my model is like this

 MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:

signature_def['serving_default']:
  The given SavedModel SignatureDef contains the following input(s):
    inputs['examples'] tensor_info:
        dtype: DT_STRING
        shape: (-1)
        name: input_example_tensor:0
  The given SavedModel SignatureDef contains the following output(s):
    outputs['prob'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1)
        name: Sigmoid:0
  Method name is: tensorflow/serving/predict

so how can I call like below

TF_TString tstr[16];
  int in_index=0;
  for (const auto &sample : section) {
    TF_TString_Init(&tstr[in_index]);
    TF_TString_Copy(&tstr[in_index], sample.c_str(), sample.size());
    //sample = tf.example.Serializetotring();
    in_index++;
  }

  int item_count = section.size();
  TF_Tensor
      *tf_tensor = TF_NewTensor(TF_STRING, nullptr, 0,  &tstr[0], section.size(), deallocator, nullptr);
  cppflow::tensor cp_tensor = cppflow::tensor(tf_tensor);
  inputs.push_back(std::make_tuple("input_example_tensor:0"s, cp_tensor));
  ```

but encuntered some problem

So, my question is ." how can I set tf.Example as input for cppflow", I want some examples code or snippet code to solve it. thanks.

hudengjunai avatar May 06 '22 10:05 hudengjunai

Did you get any response? Your question is similar to mine which is about creating DT_STRING tensor. Also my address sanitizer is complaining memory leak on the way the DT_STRING tensor is created on the function "TF_TString_Copy()".

ns-wxin avatar May 20 '22 20:05 ns-wxin

No, I'am trying use compiled tensorflow_cc.so directly from tensorflow-source. and use the tf c++ header and lib.

RUN cd tensorflow-1.15.0 && ./configure && \
        bazel build  //tensorflow/tools/pip_package:build_pip_package && \
        bazel build //tensorflow:libtensorflow_cc.so && \
        bazel build --config=opt tensorflow:install_headers

After compiled the libtesorflow_cc.so lib and header files. Encountered some protobuf version problem. with grpc-server. So I delay this feature for my project.

Did you get any response? Your question is similar to mine which is about creating DT_STRING tensor. Also my address sanitizer is complaining memory leak on the way the DT_STRING tensor is created on the function "TF_TString_Copy()".

hudengjunai avatar May 23 '22 11:05 hudengjunai

Hi,

So, the problem is about how to create a proper TF_TString tensor, right?

serizba avatar Sep 23 '22 14:09 serizba