Skip to content

Commit 2cc2502

Browse files
authored
More robust checks for FLOAT8E8M0 (#2530)
Use hasattr instead of version checks to ensure existence of the FLOAT8E8M0 type. Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
1 parent f06cfa5 commit 2cc2502

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

onnxscript/type_annotation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import onnx
1111

1212
from onnxscript import onnx_types
13-
from onnxscript._internal import version_utils
1413

1514
# TypeAnnotationValue represents the (value of) valid type-annotations recognized
1615
# by ONNX Script. TODO: Flesh out a formal definition. Currently, it supports
@@ -71,10 +70,12 @@ def onnx_attr_type_to_onnxscript_repr(attr_type: onnx.AttributeProto.AttributeTy
7170
# TODO(after onnx requirement bump): Remove this check
7271
if (
7372
not (
74-
version_utils.onnx_older_than("1.18") and tensor_type == onnx_types.FLOAT4E2M1
73+
not hasattr(onnx.TensorProto, "FLOAT4E2M1")
74+
and tensor_type == onnx_types.FLOAT4E2M1
7575
)
7676
and not (
77-
version_utils.onnx_older_than("1.19") and tensor_type == onnx_types.FLOAT8E8M0
77+
not hasattr(onnx.TensorProto, "FLOAT8E8M0")
78+
and tensor_type == onnx_types.FLOAT8E8M0
7879
)
7980
)
8081
)

0 commit comments

Comments
 (0)