Skip to content

onnx_graphsurgeon incompatible with ONNX 1.20.0 #4635

@Y-T-G

Description

@Y-T-G

onnx.helper dtypes have been deprecated in ONNX 1.20.0. So onnx_graphsurgeon import fails

import onnx_graphsurgeon
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 1
----> 1 import onnx_graphsurgeon

File /opt/conda/lib/python3.11/site-packages/onnx_graphsurgeon/__init__.py:1
----> 1 from onnx_graphsurgeon.exporters.onnx_exporter import export_onnx
      2 from onnx_graphsurgeon.graph_pattern import GraphPattern, PatternMapping
      3 from onnx_graphsurgeon.importers.onnx_importer import import_onnx

File /opt/conda/lib/python3.11/site-packages/onnx_graphsurgeon/exporters/onnx_exporter.py:134
    128     def __call__(self, arr):
    129         return self.func(arr)
    132 _NUMPY_ARRAY_CONVERTERS = {
    133     onnx.TensorProto.BFLOAT16: NumpyArrayConverter(
--> 134         np.uint16, onnx.helper.float32_to_bfloat16
    135     ),
    136     # FP8 in TensorRT supports negative zeros, no infinities
    137     # See https://onnx.ai/onnx/technical/float8.html#papers
    138     onnx.TensorProto.FLOAT8E4M3FN: NumpyArrayConverter(
    139         np.uint8, lambda x: onnx.helper.float32_to_float8e4m3(x, fn=True, uz=False)
    140     ),
    141 }
    144 # Converts a gs.Constant to an onnx tensor and convert the values according to gs.Constant.export_dtype
    145 def constant_to_onnx_tensor(tensor: Constant) -> onnx.TensorProto:

AttributeError: module 'onnx.helper' has no attribute 'float32_to_bfloat16'

https://github.com/onnx/onnx/blob/8827114d2c90c924ab05b68ac1093b0a6adf9324/onnx/helper.py#L359

Reproduce

  1. pip install --pre -U onnx
  2. import onnx_graphsurgeon

Metadata

Metadata

Assignees

No one assigned

    Labels

    Module:GraphSurgeonIssues with ONNX-GraphsurgeonModule:ONNXIssues relating to ONNX usage and import

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions