diff --git a/testdata/cv/imgproc/adaptive_threshold1.png b/testdata/cv/imgproc/adaptive_threshold1.png new file mode 100644 index 000000000..12230d35c Binary files /dev/null and b/testdata/cv/imgproc/adaptive_threshold1.png differ diff --git a/testdata/cv/imgproc/adaptive_threshold2.png b/testdata/cv/imgproc/adaptive_threshold2.png new file mode 100644 index 000000000..8615165c5 Binary files /dev/null and b/testdata/cv/imgproc/adaptive_threshold2.png differ diff --git a/testdata/dnn/onnx/data/input_clip_div_shared_constant.npy b/testdata/dnn/onnx/data/input_clip_div_shared_constant.npy new file mode 100644 index 000000000..fef28afbd Binary files /dev/null and b/testdata/dnn/onnx/data/input_clip_div_shared_constant.npy differ diff --git a/testdata/dnn/onnx/data/output_clip_div_shared_constant.npy b/testdata/dnn/onnx/data/output_clip_div_shared_constant.npy new file mode 100644 index 000000000..e2c13e8f9 Binary files /dev/null and b/testdata/dnn/onnx/data/output_clip_div_shared_constant.npy differ diff --git a/testdata/dnn/onnx/generate_onnx_models_with_onnxscript.py b/testdata/dnn/onnx/generate_onnx_models_with_onnxscript.py index 0b125ff95..35cf57eb5 100644 --- a/testdata/dnn/onnx/generate_onnx_models_with_onnxscript.py +++ b/testdata/dnn/onnx/generate_onnx_models_with_onnxscript.py @@ -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 ############### @@ -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 -> Add -> Clip -> Add -> [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)) diff --git a/testdata/dnn/onnx/models/clip_div_shared_constant.onnx b/testdata/dnn/onnx/models/clip_div_shared_constant.onnx new file mode 100644 index 000000000..2b4ac5e5c Binary files /dev/null and b/testdata/dnn/onnx/models/clip_div_shared_constant.onnx differ