Skip to content

Occured Error When I execute export_graph method. #1071

@Don9wanKim

Description

@Don9wanKim

I trained classification model based on Deverta architecture using transformers package.
And I converted onnx file with my model.
It was successful.
By the way, Error was occured When I save to tensorflow file using onnx file.
How can I convert to tf file using onnx file ?

My code is simple :

    tf_rep = prepare(onnx_model)    
    tf_rep.export_graph(TF_PATH)

Error is here

    File "/home/jovyan/Segmentation/onnx-tensorflow/onnx_tf/backend_tf_module.py", line 99, in __call__  *
        output_ops = self.backend._onnx_node_to_tensorflow_op(onnx_node,
    File "/home/jovyan/Segmentation/onnx-tensorflow/onnx_tf/backend.py", line 347, in _onnx_node_to_tensorflow_op  *
        return handler.handle(node, tensor_dict=tensor_dict, strict=strict)
    File "/home/jovyan/Segmentation/onnx-tensorflow/onnx_tf/handlers/handler.py", line 59, in handle  *
        return ver_handle(node, **kwargs)
    File "/home/jovyan/Segmentation/onnx-tensorflow/onnx_tf/handlers/backend/gather_elements.py", line 71, in version_13  *
        return cls._common(node, **kwargs)
    File "/home/jovyan/Segmentation/onnx-tensorflow/onnx_tf/handlers/backend/gather_elements.py", line 41, in _common  *
        axis_perm = tf.tensor_scatter_nd_update(tf.range(tf.rank(data)),

    TypeError: Expected any non-tensor type, but got a tensor instead.

And I analized "gather_elements.py" file.

"tf.constant([axis, 0])" is the problem.
axis variable is "Tensor("Add_18:0", shape=(), dtype=int32)"

So, It was not complete convert to constant.
Let me know How can I this problem?...!

Python, ONNX, ONNX-TF, Tensorflow version

This section can be obtained by running get_version.py from util folder.

  • Python version: 3.8.12
  • ONNX version: 1.11.0
  • ONNX-TF version: 1.10.0
  • Tensorflow version: 2.13.0

Additional context
I added this PR When I install onnx-tf package.
Because "Squeeze" and "Unsqueeze" is not supported 13 version in the latest version.

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions