Skip to content

Commit 6e5e320

Browse files
authored
Refactor one test function in MatMul_test (#22432)
### Description <!-- Describe your changes. --> ### Motivation and Context <!-- - Why is this change required? What problem does it solve?
1 parent 7d17c46 commit 6e5e320

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

onnxruntime/test/providers/cpu/math/matmul_test.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,17 +314,18 @@ TEST(MathOpTest, MatMul_Float16) {
314314
ConvertFloatToMLFloat16(B.data(), f_B.data(), 12);
315315
ConvertFloatToMLFloat16(Y.data(), f_Y.data(), 6);
316316

317-
for (int i = 0; i < 2; i++) {
317+
auto run_test = [&](bool B_is_constant) {
318318
// it needs Matrix B as constant to test XNNPack
319-
bool b_is_constant = i == 0 ? false : true;
320319
OpTester test("MatMul", 14);
321320
test.AddInput<MLFloat16>("A", {2, 4}, f_A);
322-
test.AddInput<MLFloat16>("B", {4, 3}, f_B, b_is_constant);
321+
test.AddInput<MLFloat16>("B", {4, 3}, f_B, B_is_constant);
323322
test.AddOutput<MLFloat16>("Y", {2, 3}, f_Y);
324323
test.ConfigExcludeEps({kTensorrtExecutionProvider}) // TensorRT: fp16 is not supported
325324
.Config(run_with_tunable_op)
326325
.RunWithConfig();
327-
}
326+
};
327+
run_test(true);
328+
run_test(false);
328329
}
329330
#endif
330331

0 commit comments

Comments
 (0)