galeone / tfgo

Tensorflow + Go, the gopher way
https://pgaleone.eu/tensorflow/go/2017/05/29/understanding-tensorflow-using-go/
Apache License 2.0
2.43k stars 155 forks source link

Serving models with custom op using tfgo #58

Open JiahuaWU opened 3 years ago

JiahuaWU commented 3 years ago

Hi, I trained a model with custom op and export it using saved_model API and I would like to serve it using tfgo. However, since tfgo binds to tensorflow C library(more precisely libtensorflow.so) which is very hard to modify, I'm not sure how to register the custom op in the binary in this case. Is there any chance and would anyone give some help? Here is an example of training script in which dynamic_embedding is implemented as a custom op built in the library tensorflow-recommenders-addons, and when I try to load the model using tfgo I get the following error:

panic: Op type not registered 'TFRA>CuckooHashTableOfTensors' in binary running on CXJK8129239. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) `tf.contrib.resampler` should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed.
janpfeifer commented 2 years ago

Same issue for TensorFlow Decision Forests models, they require TF custom ops.

MatthewZholud commented 2 years ago

Custom ops can be loaded using tf.LoadLibrary(opFilePass)

For decision forest i found ops file here. File path: /tensorflow_decision_forests/tensorflow/ops/inference/inference.so