Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libprotobuf map.h error when running universal sentence encoder #253

Open
JZacaroli opened this issue Nov 22, 2023 · 1 comment
Open

libprotobuf map.h error when running universal sentence encoder #253

JZacaroli opened this issue Nov 22, 2023 · 1 comment

Comments

@JZacaroli
Copy link

JZacaroli commented Nov 22, 2023

I'm trying to embed a string using the universal sentence encoder, but I'm hitting this error when running the model:

[libprotobuf FATAL external/com_google_protobuf/src\google/protobuf/map.h:1293] CHECK failed: it != end(): key not found: value

I'm compiling like so (using windows):

g++ -std=c++17 -I/path/to/libtensorflow-cpu-windows-x86_64-2.15.0/include -I/path/to/cppflow-master/include -L/path/to/libtensorflow-cpu-windows-x86_64-2.15.0/lib hello_tf.cpp -ltensorflow -o hello_tf

This is hello_tf.cpp:

#include <iostream>
#include <tensorflow/c/c_api.h>
#include <cppflow/cppflow.h>

int main() {
  printf("Hello from TensorFlow C library version %s\n", TF_Version());

  cppflow::model model("model-use");

  auto input = cppflow::reshape(cppflow::tensor(std::string("hello")), {-1});
  std::cout << input << std::endl;

  auto output_tensor = model({{"serving_default_inputs:0", input}},{"StatefulPartitionedCall_1:0"}); // <-- Line causing the error
  
  return 0;
}

This is the output of the saved_model_cli command on the saved model .pb file:

The given SavedModel SignatureDef contains the following input(s):
  inputs['inputs'] tensor_info:
      dtype: DT_STRING
      shape: (-1)
      name: serving_default_inputs:0
The given SavedModel SignatureDef contains the following output(s):
  outputs['outputs'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 512)
      name: StatefulPartitionedCall_1:0
Method name is: tensorflow/serving/predict

If I change "serving_default_inputs:0" to "serving_default_inputs" and "StatefulPartitionedCall_1:0" to "StatefulPartitionedCall" when calling the model, then it doesn't fail, and instead returns this: (tensor: shape=[], dtype=TF_FLOAT, data=1). I am hoping to get a 512 dimensional vector out of it.

Any help is very much appreciated!

@JZacaroli
Copy link
Author

I've managed to get this working by using tensorflow v2.10, instead of v2.15. Not sure why this works though..
The tensorflow download page mentions v2.10 being the latest version that's supported GPU on windows, but just I'm using the CPU version.

Doesn't seem like an issue with cppflow, but I'll leave this up in case someone can explain what the protobuf error is about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant