tensorflow-onnx icon indicating copy to clipboard operation
tensorflow-onnx copied to clipboard

Unsupported ops: {`Merge`, `ReadFile`, `Substr`, `DecodeJpeg`, `DecodePng`, `ResizeArea`}

Open Julia-Melgare opened this issue 2 years ago • 2 comments

Describe the bug When trying to convert the MSI-Net model (https://github.com/alexanderkroner/saliency) from TF to ONNX, I get the following output:

python -m tf2onnx.convert --graphdef model_salicon_gpu.pb --inputs=input:0 --outputs=output:0 --output model_salicon_gpu.onnx

2023-04-05 15:21:26,532 - INFO - Using tensorflow=1.13.1, onnx=1.11.0, tf2onnx=1.14.0/8f8d49
2023-04-05 15:21:26,533 - INFO - Using opset <onnx, 15>
2023-04-05 15:21:27,763 - INFO - Computed 10 values for constant folding
2023-04-05 15:21:27,823 - INFO - folding node using tf type=Cast, name=truediv/Cast
2023-04-05 15:21:27,824 - INFO - folding node using tf type=Cast, name=truediv_1/Cast
2023-04-05 15:21:27,824 - INFO - folding node using tf type=Equal, name=Equal
2023-04-05 15:21:27,825 - INFO - folding node using tf type=Cast, name=truediv_2/Cast_1
2023-04-05 15:21:27,825 - INFO - folding node using tf type=Cast, name=truediv_3/Cast_1
2023-04-05 15:21:27,825 - INFO - folding node using tf type=Cast, name=truediv_4/Cast
2023-04-05 15:21:27,825 - INFO - folding node using tf type=Cast, name=truediv_5/Cast
2023-04-05 15:21:27,826 - INFO - folding node using tf type=Equal, name=Equal_1
2023-04-05 15:21:27,826 - INFO - folding node using tf type=Cast, name=truediv_6/Cast_1
2023-04-05 15:21:27,826 - INFO - folding node using tf type=Cast, name=truediv_7/Cast_1
2023-04-05 15:21:27,907 - INFO - Computed 10 values for constant folding
2023-04-05 15:21:27,964 - INFO - folding node using tf type=Cast, name=truediv/Cast
2023-04-05 15:21:27,965 - INFO - folding node using tf type=Cast, name=truediv_1/Cast
2023-04-05 15:21:27,965 - INFO - folding node using tf type=Equal, name=Equal
2023-04-05 15:21:27,965 - INFO - folding node using tf type=Cast, name=truediv_2/Cast_1
2023-04-05 15:21:27,965 - INFO - folding node using tf type=Cast, name=truediv_3/Cast_1
2023-04-05 15:21:27,965 - INFO - folding node using tf type=Cast, name=truediv_4/Cast
2023-04-05 15:21:27,966 - INFO - folding node using tf type=Cast, name=truediv_5/Cast
2023-04-05 15:21:27,966 - INFO - folding node using tf type=Equal, name=Equal_1
2023-04-05 15:21:27,966 - INFO - folding node using tf type=Cast, name=truediv_6/Cast_1
2023-04-05 15:21:27,966 - INFO - folding node using tf type=Cast, name=truediv_7/Cast_1
Traceback (most recent call last):
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\importer.py", line 426, in import_graph_def
    graph._c_graph, serialized, options)  # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: Negative dimension size caused by subtracting 2 from 1 for 'max_pooling2d/MaxPool' (op: 'MaxPool') with input shapes: [1,64,1,1].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\site-packages\tf2onnx\convert.py", line 710, in <module>
    main()
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\site-packages\tf2onnx\convert.py", line 295, in main
    output_path=args.output)
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\site-packages\tf2onnx\convert.py", line 169, in _convert_common
    custom_op_handlers=custom_op_handlers, **kwargs)
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\site-packages\tf2onnx\tfonnx.py", line 460, in process_tf_graph
    ignore_default, use_default)
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\site-packages\tf2onnx\tfonnx.py", line 492, in graphs_from_tf
    tf_graph = infer_shape(tf_graph, shape_override)
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\site-packages\tf2onnx\shape_inference.py", line 31, in infer_shape
    tf_graph = infer_shape_for_graph(tf_graph)
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\site-packages\tf2onnx\shape_inference.py", line 82, in infer_shape_for_graph
    tf_graph = tf_reload_graph(tf_graph)
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\site-packages\tf2onnx\tf_loader.py", line 738, in tf_reload_graph
    tf.import_graph_def(graph_def, name="")
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "C:\Users\VHLAB\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\importer.py", line 430, in import_graph_def
    raise ValueError(str(e))
ValueError: Negative dimension size caused by subtracting 2 from 1 for 'max_pooling2d/MaxPool' (op: 'MaxPool') with input shapes: [1,64,1,1].

This happens when trying to convert from both SavedModel and frozen graph formats.

Urgency

None

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 18.04*): Windows 10
  • TensorFlow Version: 1.13.1
  • Python version: 3.6.8
  • ONNX version (if applicable, e.g. 1.11*): 1.11.0
  • ONNXRuntime version (if applicable, e.g. 1.11*): 1.11.0

To Reproduce

  1. Download the model from here;
  2. I initially got a decoding error when first attempting to run the cmd command, so I also changed line 60 of tf_utils.py to include an 'ignore' flag: decode = np.vectorize(lambda x: x.decode('UTF-8', 'ignore'))
  3. Attempt to run the conversion: python -m tf2onnx.convert --graphdef model_salicon_gpu.pb --inputs=input:0 --outputs=output:0 --output model_salicon_gpu.onnx

Screenshots

Additional context

Whenever I was running inferences on the original TF frozen graph model locally, I never got this error: ValueError: Negative dimension size caused by subtracting 2 from 1 for 'max_pooling2d/MaxPool' (op: 'MaxPool') with input shapes: [1,64,1,1].

Julia-Melgare avatar Apr 05 '23 18:04 Julia-Melgare

Update: I was able to surpass this dimension size issue, and now I have run into another problem with unsupported operators:

2023-04-10 10:51:55,150 - ERROR - Tensorflow op [cond_7/Merge: Merge] is not supported
2023-04-10 10:51:55,150 - ERROR - Tensorflow op [cond_5/Merge: Merge] is not supported
2023-04-10 10:51:55,150 - ERROR - Tensorflow op [cond_3/Merge: Merge] is not supported
2023-04-10 10:51:55,150 - ERROR - Tensorflow op [cond_1/Merge: Merge] is not supported
2023-04-10 10:51:55,150 - ERROR - Tensorflow op [ReadFile_1: ReadFile] is not supported
2023-04-10 10:51:55,151 - ERROR - Tensorflow op [is_jpeg_1/Substr: Substr] is not supported
2023-04-10 10:51:55,151 - ERROR - Tensorflow op [cond_4/DecodeJpeg: DecodeJpeg] is not supported
2023-04-10 10:51:55,151 - ERROR - Tensorflow op [cond_4/DecodePng: DecodePng] is not supported
2023-04-10 10:51:55,154 - ERROR - Tensorflow op [ReadFile: ReadFile] is not supported
2023-04-10 10:51:55,154 - ERROR - Tensorflow op [is_jpeg/Substr: Substr] is not supported
2023-04-10 10:51:55,155 - ERROR - Tensorflow op [cond/DecodeJpeg: DecodeJpeg] is not supported
2023-04-10 10:51:55,155 - ERROR - Tensorflow op [cond/DecodePng: DecodePng] is not supported
2023-04-10 10:51:55,159 - ERROR - Tensorflow op [cond_6/ResizeArea: ResizeArea] is not supported
2023-04-10 10:51:55,166 - ERROR - Tensorflow op [cond_2/ResizeArea: ResizeArea] is not supported
2023-04-10 10:51:55,174 - ERROR - Unsupported ops: Counter({'Merge': 4, 'ReadFile': 2, 'Substr': 2, 'DecodeJpeg': 2, 'DecodePng': 2, 'ResizeArea': 2})

I would like to know if there is any chance of adding support for these operators in the near future? Thanks in advance.

Julia-Melgare avatar Apr 10 '23 14:04 Julia-Melgare

Those TF data operations ops, like ReadFile and Substr, have no corresponding ONNX ops so they won't be able to be supported as expected.

fatcat-z avatar Apr 24 '23 06:04 fatcat-z