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

(5.x) Merge 4.x #1169

Merged
merged 4 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added testdata/cv/imgproc/adaptive_threshold1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/cv/imgproc/adaptive_threshold2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
21 changes: 18 additions & 3 deletions testdata/dnn/onnx/generate_onnx_models_with_onnxscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

###############
### CAUTION!!!
### Be sure to put constant numpy arrays out of @ost.script() decorated fucntion.
### Otherwise random values change each time eager mode is enter.
### Be sure to put random-generated constant numpy arrays out of @ost.script() decorated fucntion.
### Otherwise random values change each time eager mode is entereded.
### See discussions in https://github.com/microsoft/onnxscript/issues/1313
###############

Expand Down Expand Up @@ -364,4 +364,19 @@ def biased_matmul(x: ost.FLOAT[b, m, k]) -> ost.FLOAT[b, m, n]:
matmul = op.MatMul(x, weight)
bias = op.Constant(value=onnx.helper.make_tensor("", onnx.TensorProto.FLOAT, [n], bias_data))
return op.Add(bias, matmul)
make_model_and_data(biased_matmul, np.random.rand(b, m, k).astype(np.float32), use_ort=True, ort_input_keys=["x"])
make_model_and_data(biased_matmul, np.random.rand(b, m, k).astype(np.float32))

''' Subgraph: [Input] -> Clip<min=0, max=6> -> Add<B=6> -> Clip<min=0, max=6> -> Add<B=6> -> [Output]

Here max=6 and B=6 shares the same Constant node.
'''

@ost.script()
def clip_div_shared_constant(x: ost.FLOAT[1, 8, 12, 10]) -> ost.FLOAT[1, 8, 12, 10]:
Constant_output_0 = op.Constant(value=onnx.helper.make_tensor("", onnx.TensorProto.FLOAT, [], np.array([0], dtype=np.float32)))
Constant_1_output_0 = op.Constant(value=onnx.helper.make_tensor("", onnx.TensorProto.FLOAT, [], np.array([6], dtype=np.float32)))

div = op.Div(x, Constant_1_output_0)
clip = op.Clip(div, Constant_output_0, Constant_1_output_0)
return clip
make_model_and_data(clip_div_shared_constant, np.random.rand(1, 8, 12, 10).astype(np.float32))
Binary file not shown.