Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates Onnx Version to 1.16 #3317

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion build_tools/python_deploy/build_linux_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TM_RELEASE_DOCKER_IMAGE="${TM_RELEASE_DOCKER_IMAGE:-quay.io/pypa/manylinux2014_$
# ./build_tools/docker/Dockerfile
TM_CI_DOCKER_IMAGE="${TM_CI_DOCKER_IMAGE:-powderluv/torch-mlir-ci:latest}"
# Version of Python to use in Release builds. Ignored in CIs.
TM_PYTHON_VERSIONS="${TM_PYTHON_VERSIONS:-cp38-cp38 cp310-cp310 cp311-cp311}"
TM_PYTHON_VERSIONS="${TM_PYTHON_VERSIONS:-cp38-cp38 cp310-cp310 cp311-cp311 cp312-cp312}"
# Location to store Release wheels
TM_OUTPUT_DIR="${TM_OUTPUT_DIR:-${this_dir}/wheelhouse}"
# What "packages to build"
Expand Down
18 changes: 10 additions & 8 deletions projects/pt1/e2e_testing/xfail_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2510,8 +2510,6 @@
"SplitDimStaticModule_basic",
"SqrtIntConstantModule_basic",
"SqrtIntModule_basic",
"StdCorrectionEmptyDimModule_basic",
"StdDimEmptyDimModule_basic",
"SubFloatModule_basic",
"SubIntModule_basic",
"TanhBackward_basic",
Expand Down Expand Up @@ -2565,8 +2563,6 @@
"UpSampleNearest2dDynamicFactor_basic",
"UpSampleNearest2dStaticFactor_basic",
"UpSampleNearest2d_basic",
"VarCorrectionEmptyDimModule_basic",
"VarDimEmptyDimModule_basic",
"ViewCollapseDynamicWithAtenSizeIntModule_basic",
"ViewCollapseModule_basic",
"ViewDynamicExpandCollapseModule_basic",
Expand Down Expand Up @@ -2683,17 +2679,23 @@


ONNX_CRASHING_SET = {
# unknown
"ElementwisePreluModule_basic",
"FakeQuantizePerTensorAffineModule_basic",
"FakeQuantizePerTensorAffineDynamicShapeModule_basic",
"ElementwisePreluModule_basic",
"ViewDynamicExpandCollapseWithParallelUnknownDimModule_basic",
# The following test sporadically stopped producing correct numerics for the golden value in the CI.
# For now, we are removing the test until this issue has been debugged.
"QuantizedMLP_basic",
"ScatterReduceFloatProdModuleIncludeSelf",
"ScatterReduceFloatSumModuleIncludeSelf",
"ScatterReduceIntProdModuleIncludeSelf",
"ScatterReduceIntSumModuleIncludeSelf",
# The following test sporadically stopped producing correct numerics for the golden value in the CI.
# For now, we are removing the test until this issue has been debugged.
"QuantizedMLP_basic",
# these empty dim modules generate IR with an empty float constant, which gets compared to int dims
"StdDimEmptyDimModule_basic",
"StdCorrectionEmptyDimModule_basic",
"VarCorrectionEmptyDimModule_basic",
"VarDimEmptyDimModule_basic",
# Runtime crash: mismatched size for broadcast
"MaxPool2dWithIndicesAllNegativeValuesModule_basic",
"MaxPool2dWithIndicesNonDefaultPaddingModule_basic",
Expand Down
5 changes: 5 additions & 0 deletions python/torch_mlir/extras/onnx_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,8 @@ def tensor_proto_to_attr(self, tp: onnx.TensorProto) -> Attribute:
onnx.TensorProto.DataType.FLOAT8E5M2: lambda: Float8E5M2Type.get(),
onnx.TensorProto.DataType.FLOAT8E5M2FNUZ: lambda: Float8E5M2FNUZType.get(),
onnx.TensorProto.DataType.STRING: lambda: "!torch.str",
onnx.TensorProto.DataType.UINT4: lambda: IntegerType.get_unsigned(4),
onnx.TensorProto.DataType.INT4: lambda: IntegerType.get_signed(4),
# Ommitted: STRING,
}

Expand Down Expand Up @@ -688,6 +690,9 @@ def tensor_proto_to_attr(self, tp: onnx.TensorProto) -> Attribute:
),
signless=False,
),
onnx.TensorProto.DataType.UINT8: lambda tp: DenseElementsAttr.get(
np.asarray(tp.int32_data, dtype=np.uint8).reshape(tp.dims), signless=False
),
onnx.TensorProto.DataType.INT8: lambda tp: DenseElementsAttr.get(
np.asarray(tp.int32_data, dtype=np.int8).reshape(tp.dims), signless=False
),
Expand Down
2 changes: 1 addition & 1 deletion python/torch_mlir/tools/import_onnx/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def load_onnx_model(args: argparse.Namespace) -> onnx.ModelProto:
raw_model = onnx.load(args.input_file)
else:
raw_model = onnx.load(args.input_file, load_external_data=False)
onnx.load_external_data_for_model(raw_model, args.data_dir)
onnx.load_external_data_for_model(raw_model, str(args.data_dir))

# Run the checker to test whether the file is above the threshold for
# in-memory shape inference. If not, go ahead and do the shape inference.
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pillow
dill
multiprocess
onnx==1.15.0
onnx==1.16.0
mpmath==1.3.0
4 changes: 3 additions & 1 deletion test/python/onnx_importer/import_smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def tearDownClass(cls):
def load_onnx_model(self, file_path: Path) -> onnx.ModelProto:
raw_model = onnx.load(file_path)
try:
inferred_model = onnx.shape_inference.infer_shapes(raw_model)
inferred_model = onnx.shape_inference.infer_shapes(
raw_model, data_prop=True
)
except onnx.onnx_cpp2py_export.shape_inference.InferenceError as e:
print("WARNING: Shape inference failure (skipping test):", e)
self.skipTest(reason="shape inference failure")
Expand Down