Skip to content

Commit 2ff711d

Browse files
Edit test onnx model to properly test mutable alias (buffer reuse for Relu).
1 parent 5aa4f75 commit 2ff711d

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

onnxruntime/test/autoep/test_execution.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,16 @@ TEST(OrtEpLibrary, KernelPluginEp_Inference) {
251251
std::unordered_map<std::string, std::string> ep_options;
252252
session_options.AppendExecutionProvider_V2(*ort_env, {plugin_ep_device}, ep_options);
253253

254-
// This model has Squeeze -> Mul. The example plugin EP supports both using registered kernels.
254+
// This model has Squeeze, Mul, and Relu nodes. The example plugin EP supports all nodes using registered kernels.
255255
Ort::Session session(*ort_env, ORT_TSTR("testdata/squeeze_mul_relu.onnx"), session_options);
256256

257257
// Create inputs
258258
Ort::MemoryInfo memory_info = Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU);
259259
std::array<int64_t, 3> a_shape = {3, 1, 2};
260260
std::array<int64_t, 2> b_shape = {3, 2};
261261

262-
std::array<float, 6> a_data = {1.f, 2.f, 3.f, 4.f, 5.f, 6.f};
263-
std::array<float, 6> b_data = {2.f, 3.f, 4.f, -5.f, -6.f, 7.f};
262+
std::array<float, 6> a_data = {1.f, -2.f, 3.f, 4.f, -5.f, 6.f};
263+
std::array<float, 6> b_data = {2.f, 3.f, 4.f, -5.f, 6.f, 7.f};
264264

265265
std::vector<Ort::Value> ort_inputs{};
266266
ort_inputs.emplace_back(
@@ -279,7 +279,7 @@ TEST(OrtEpLibrary, KernelPluginEp_Inference) {
279279
Ort::Value& ort_output = ort_outputs[0];
280280
const float* output_data = ort_output.GetTensorData<float>();
281281
gsl::span<const float> output_span(output_data, 6);
282-
EXPECT_THAT(output_span, ::testing::ElementsAre(2, 6, 12, 0, 0, 42));
282+
EXPECT_THAT(output_span, ::testing::ElementsAre(4, 0, 24, 0, 0, 84));
283283
}
284284
} // namespace test
285285
} // namespace onnxruntime
130 Bytes
Binary file not shown.

onnxruntime/test/testdata/squeeze_mul_relu.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from onnx import TensorProto, checker, helper, save, shape_inference
22

3-
# A --> Squeeze --> Mul --> Relu --> C
3+
# A --> Squeeze --> Mul --> Relu --> Mul(2x) --> C
44
# ^
55
# |
66
# B ----------------+
@@ -9,21 +9,27 @@
99
helper.make_node(
1010
"Squeeze",
1111
inputs=["A"],
12-
outputs=["squeeze_output"],
12+
outputs=["squeeze0_output"],
1313
name="squeeze_0",
1414
),
1515
helper.make_node(
1616
"Mul",
17-
inputs=["squeeze_output", "B"],
18-
outputs=["mul_output"],
17+
inputs=["squeeze0_output", "B"],
18+
outputs=["mul0_output"],
1919
name="mul_0",
2020
),
2121
helper.make_node(
2222
"Relu",
23-
inputs=["mul_output"],
24-
outputs=["C"],
23+
inputs=["mul0_output"],
24+
outputs=["relu0_output"],
2525
name="relu_0",
2626
),
27+
helper.make_node(
28+
"Mul",
29+
inputs=["relu0_output", "Const2"],
30+
outputs=["C"],
31+
name="mul_1",
32+
),
2733
],
2834
name="Main_graph",
2935
inputs=[
@@ -33,6 +39,9 @@
3339
outputs=[
3440
helper.make_tensor_value_info("C", TensorProto.FLOAT, [3, 2]),
3541
],
42+
initializer=[
43+
helper.make_tensor("Const2", TensorProto.FLOAT, [3, 2], [2.0] * 6),
44+
],
3645
)
3746

3847
model = helper.make_model(graph_proto)

0 commit comments

Comments
 (0)