tensorflow / tensorrt

TensorFlow/TensorRT integration
Apache License 2.0
736 stars 226 forks source link

Problem transforming tensorflow model to tensorrt #246

Open Some-random opened 3 years ago

Some-random commented 3 years ago

We're having issue transforming tensorflow model (with embedding) to try. But the following error occurred.

File "/home/research/jiangdongwei/miniconda3/envs/cuda11/lib/python3.6/site-packages/tensorflow/python/compiler/tensorrt/trt_convert.py", line 1108, in convert
    self._converted_graph_def = self._run_conversion(grappler_meta_graph_def)
  File "/home/research/jiangdongwei/miniconda3/envs/cuda11/lib/python3.6/site-packages/tensorflow/python/compiler/tensorrt/trt_convert.py", line 1042, in _run_conversion
    grappler_session_config, meta_graph_def, graph_id=b"tf_graph")
  File "/home/research/jiangdongwei/miniconda3/envs/cuda11/lib/python3.6/site-packages/tensorflow/python/grappler/tf_optimizer.py", line 58, in OptimizeGraph
    graph_id, strip_default_attributes)
tensorflow.python.framework.errors_impl.InvalidArgumentError: input resource[0] expected type resource != float, the type of while_cond_1_y_net_embedding_embedding_lookup_317210[0]
    In {{node while/cond_1/y_net/embedding/embedding_lookup

It seems to indicate we should pass a float variable to tf.keras.layers.embedding but the input to embedding layer should be integers...

Damcy commented 3 years ago

I have met a similar problem when I use TF-TRT and saved_model_cli to convert a saved model. These two methods failed when using Embedding layer. https://stackoverflow.com/questions/67085221/failed-to-use-tf-trt-when-using-tf-keras-layers-embedding