Skip to content

Commit b115d5d

Browse files
authored
Fix onnx 1.19.0 issue in graph surgery (microsoft#2129)
## Describe your changes 1. Fix onnx 1.19.0 issue in graph surgery 1. Pin onnx version in test requirements.txt ## Checklist before requesting a review - [ ] Add unit tests for this change. - [ ] Make sure all tests can pass. - [ ] Update documents if necessary. - [ ] Lint and apply fixes to your code by running `lintrunner -a` - [ ] Is this a user-facing change? If yes, give a description of this change to be included in the release notes. - [ ] Is this PR including examples changes? If yes, please remember to update [example documentation](https://github.com/microsoft/Olive/blob/main/docs/source/examples.md) in a follow-up PR. ## (Optional) Issue link
1 parent 81697ba commit b115d5d

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

olive/passes/onnx/graph_surgeries.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ def __init__(self, node_name, input_idx):
247247
self.input_idx = input_idx
248248

249249
def __call__(self, model: ModelProto):
250-
from onnx.helper import make_node
251-
from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE
250+
from onnx.helper import make_node, tensor_dtype_to_np_dtype
252251

253252
node = self.get_node_by_name(model, self.node_name)
254253
if node is None:
@@ -292,7 +291,7 @@ def __call__(self, model: ModelProto):
292291
if target_shape is None or target_type is None:
293292
raise ValueError(f"Cannot determine shape and type for input '{input_name}'.")
294293

295-
zero_values = np.zeros(target_shape, dtype=TENSOR_TYPE_TO_NP_TYPE[target_type])
294+
zero_values = np.zeros(target_shape, dtype=tensor_dtype_to_np_dtype(target_type))
296295

297296
zero_tensor = make_tensor(
298297
name=f"{self.node_name}_zero_tensor",

test/requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ neural-compressor<2.4
1616
nncf>=2.16.0
1717
numpy<2.0.0
1818
nvidia-modelopt
19-
onnx>=1.18.0
19+
onnx==1.18.0
2020
onnx-graphsurgeon
2121
onnxconverter_common
2222
onnxmltools

0 commit comments

Comments
 (0)