onnx / tensorflow-onnx

Convert TensorFlow, Keras, Tensorflow.js and Tflite models to ONNX
Apache License 2.0
2.31k stars 433 forks source link

ValueError: get tensor value: 'cache_size_distribution/cond/sub' must be Const #1706

Closed arnavc1712 closed 3 years ago

arnavc1712 commented 3 years ago

Describe the bug

When running the command python -m tf2onnx.convert --saved-model /tmp/rl-agent_policy-edb46cce-15d8-45d2-95bc-7c82b6918874 --opset 14 --output model.onnx --signature_def serving_default I get the following error:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tf2onnx/convert.py", line 617, in main() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tf2onnx/convert.py", line 277, in main output_path=args.output) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tf2onnx/convert.py", line 155, in _convert_common g = process_tf_graph(tf_graph, const_node_values=const_node_values, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tf2onnx/tfonnx.py", line 439, in process_tf_graph initialized_tables, tensors_to_rename, is_tflite, dequantize) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tf2onnx/tfonnx.py", line 488, in process_graphs initialized_tables, is_tflite, dequantize) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tf2onnx/tfonnx.py", line 589, in process_parsed_graph run_rewriters(g, rewriters, continue_on_error) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tf2onnx/tfonnx.py", line 361, in run_rewriters raise ex File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tf2onnx/tfonnx.py", line 352, in run_rewriters ops = func(g, g.get_nodes()) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tf2onnx/rewriter/random_uniform.py", line 32, in rewrite_random_uniform tmax = input2.inputs[0].get_tensor_value() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tf2onnx/graph.py", line 314, in get_tensor_value raise ValueError("get tensor value: '{}' must be Const".format(self.name)) ValueError: get tensor value: 'cache_size_distribution/cond/sub' must be Const

I am not able to understand what the error is since Opset 14 contains support for the Sub Operator type. Can someone please help?

System information

TomWildenhain-Microsoft commented 3 years ago

This is a bug in the RandomUniform rewriter assuming the inputs are constant. #1710 will skip the rewriter in this case, allowing the handler to deal with the non-constant case.