From f185fd30ea9a6f665450769731e43c655a2030e1 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Fri, 19 Dec 2025 11:32:31 -0800 Subject: [PATCH 1/2] Clean up values Signed-off-by: Justin Chu --- onnxscript/values.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/onnxscript/values.py b/onnxscript/values.py index 4c33664226..aa23204de5 100644 --- a/onnxscript/values.py +++ b/onnxscript/values.py @@ -1,8 +1,6 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -# ruff: noqa: TID251 - from __future__ import annotations import dataclasses @@ -39,15 +37,17 @@ _P = ParamSpec("_P") -def select_ir_version(version: int, domain: str = "") -> int: +def _select_ir_version(version: int, domain: str = "") -> int: """Selects a suitable ONNX ir_version for a given opset version.""" if domain == "": domain = "ai.onnx" - if (domain, version) not in onnx.helper.OP_SET_ID_VERSION_MAP: + if (domain, version) not in onnx.helper.OP_SET_ID_VERSION_MAP: # noqa: TID251 return max( - v for k, v in onnx.helper.OP_SET_ID_VERSION_MAP.items() if k[0] == "ai.onnx" + v + for k, v in onnx.helper.OP_SET_ID_VERSION_MAP.items() # noqa: TID251 + if k[0] == "ai.onnx" ) - required_min_version = onnx.helper.OP_SET_ID_VERSION_MAP[domain, version] + required_min_version = onnx.helper.OP_SET_ID_VERSION_MAP[domain, version] # noqa: TID251 return max(required_min_version, 10) @@ -193,7 +193,7 @@ def _get_attribute_value(attr_proto: onnx.AttributeProto) -> Any: """Get the default value of an ONNX attribute.""" if attr_proto.type == onnx.AttributeProto.UNDEFINED: return _EmptyDefault - return onnx.helper.get_attribute_value(attr_proto) + return onnx.helper.get_attribute_value(attr_proto) # noqa: TID251 def _param_schemas_from_op_schema( @@ -694,7 +694,7 @@ def to_proto(f): if "ir_version" in kwargs: ir_version = kwargs.pop("ir_version") else: - ir_version = select_ir_version(opsets[""]) + ir_version = _select_ir_version(opsets[""]) # Create the model model = ir.Model(self.function_ir.graph, ir_version=ir_version) From 5ca43278a67cc615d1df7637400eeaec61960d10 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Mon, 29 Dec 2025 12:17:43 -0800 Subject: [PATCH 2/2] apis Signed-off-by: Justin Chu --- onnxscript/values.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/onnxscript/values.py b/onnxscript/values.py index 0b8bd2519a..a5a2919306 100644 --- a/onnxscript/values.py +++ b/onnxscript/values.py @@ -16,7 +16,6 @@ ParamSchema, SymbolValue, TracedOnnxFunction, - select_ir_version, ) __all__ = [ @@ -30,5 +29,4 @@ "ParamSchema", "SymbolValue", "TracedOnnxFunction", - "select_ir_version", ]