-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If an initializer is used as graph outputs, we should keep its name, instead of renaming it as constant sharing transformer did currently. To fix #14488
- Loading branch information
Showing
4 changed files
with
98 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
onnxruntime/test/testdata/transform/scalar_const_not_share.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import numpy as np | ||
import onnx | ||
import onnxscript | ||
from onnx import numpy_helper | ||
from onnxscript import opset17 as op | ||
|
||
|
||
@onnxscript.script() | ||
def build_model(x: onnxscript.FLOAT): | ||
y_scale = op.Constant(value_float=1.0) | ||
y_zero_point = op.Constant(value=numpy_helper.from_array(np.array(1, dtype=np.uint8))) | ||
return op.Add(x, y_scale), y_scale, y_zero_point | ||
|
||
|
||
model: onnx.ModelProto = build_model.to_model_proto() | ||
onnx.save(model, "scalar_const_not_share.onnx") |