From 8fbe6dfb10a0760ffd3eac9d8bde34ff568b297c Mon Sep 17 00:00:00 2001 From: Yi-Hong Lyu Date: Sat, 27 Jul 2024 22:57:11 +0000 Subject: [PATCH] Amend tests so bias cannot be ignored --- .../test/providers/cpu/nn/conv_fp16_test.cc | 60 +++++++++---------- .../test/providers/cpu/nn/conv_op_test.cc | 47 ++++++++++----- 2 files changed, 61 insertions(+), 46 deletions(-) diff --git a/onnxruntime/test/providers/cpu/nn/conv_fp16_test.cc b/onnxruntime/test/providers/cpu/nn/conv_fp16_test.cc index b1bbe9b865178..95b274966fbbb 100644 --- a/onnxruntime/test/providers/cpu/nn/conv_fp16_test.cc +++ b/onnxruntime/test/providers/cpu/nn/conv_fp16_test.cc @@ -910,39 +910,39 @@ TEST(ConvFp16Test, Depthwise2D_Bias_Group15) { MLFloat16(58.0f), MLFloat16(59.0f)}; vector W_shape = {15, 1, 2, 2}; vector B = { - MLFloat16(1.0f), - MLFloat16(2.0f), - MLFloat16(3.0f), - MLFloat16(4.0f), - MLFloat16(5.0f), - MLFloat16(6.0f), - MLFloat16(7.0f), - MLFloat16(8.0f), - MLFloat16(9.0f), - MLFloat16(10.0f), - MLFloat16(11.0f), - MLFloat16(12.0f), - MLFloat16(13.0f), - MLFloat16(14.0f), - MLFloat16(15.0f)}; + MLFloat16(101.0f), + MLFloat16(102.0f), + MLFloat16(103.0f), + MLFloat16(104.0f), + MLFloat16(105.0f), + MLFloat16(106.0f), + MLFloat16(107.0f), + MLFloat16(108.0f), + MLFloat16(109.0f), + MLFloat16(110.0f), + MLFloat16(111.0f), + MLFloat16(112.0f), + MLFloat16(113.0f), + MLFloat16(114.0f), + MLFloat16(115.0f)}; vector B_shape = {15}; vector Y_shape = {1, 15, 1, 1}; auto expected_vals = { - MLFloat16(15.0f), // 0.0*0.0 + 1.0*1.0 + 2.0*2.0 + 3.0*3.0 + 1.0 - MLFloat16(128.0f), - MLFloat16(369.0f), - MLFloat16(738.0f), - MLFloat16(1235.0f), - MLFloat16(1860.0f), - MLFloat16(2613.0f), // 24.0*24.0 + 25.0*25.0 + 26.0*26.0 + 27.0*27.0 + 7.0 - MLFloat16(3494.0f), - MLFloat16(4503.0f), - MLFloat16(5640.0f), - MLFloat16(6905.0f), - MLFloat16(8298.0f), - MLFloat16(9819.0f), // 48.0*48.0 + 49.0*49.0 + 50.0*50.0 + 51.0*51.0 + 13.0 - MLFloat16(11468.0f), // 52.0*52.0 + 53.0*53.0 + 54.0*54.0 + 55.0*55.0 + 14.0 - MLFloat16(13245.0f) // 56.0*56.0 + 57.0*57.0 + 58.0*58.0 + 59.0*59.0 + 15.0 + MLFloat16(115.0f), // 0.0*0.0 + 1.0*1.0 + 2.0*2.0 + 3.0*3.0 + 101.0 + MLFloat16(228.0f), + MLFloat16(469.0f), + MLFloat16(838.0f), + MLFloat16(1335.0f), + MLFloat16(1960.0f), + MLFloat16(2713.0f), // 24.0*24.0 + 25.0*25.0 + 26.0*26.0 + 27.0*27.0 + 107.0 + MLFloat16(3594.0f), + MLFloat16(4603.0f), + MLFloat16(5740.0f), + MLFloat16(7005.0f), + MLFloat16(8398.0f), + MLFloat16(9919.0f), // 48.0*48.0 + 49.0*49.0 + 50.0*50.0 + 51.0*51.0 + 113.0 + MLFloat16(11568.0f), // 52.0*52.0 + 53.0*53.0 + 54.0*54.0 + 55.0*55.0 + 114.0 + MLFloat16(13345.0f) // 56.0*56.0 + 57.0*57.0 + 58.0*58.0 + 59.0*59.0 + 115.0 }; TestConvFp16Op(attrs, {X, W, B}, {X_shape, W_shape, B_shape}, expected_vals, Y_shape); diff --git a/onnxruntime/test/providers/cpu/nn/conv_op_test.cc b/onnxruntime/test/providers/cpu/nn/conv_op_test.cc index 418f9bd7794ac..2d885ee9d479f 100644 --- a/onnxruntime/test/providers/cpu/nn/conv_op_test.cc +++ b/onnxruntime/test/providers/cpu/nn/conv_op_test.cc @@ -842,25 +842,40 @@ TEST(ConvTest, Depthwise2D_Bias_Group15) { 56.0f, 57.0f, 58.0f, 59.0f}; vector W_shape = {15, 1, 2, 2}; - vector B = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f}; + vector B = { + 101.0f, + 102.0f, + 103.0f, + 104.0f, + 105.0f, + 106.0f, + 107.0f, + 108.0f, + 109.0f, + 110.0f, + 111.0f, + 112.0f, + 113.0f, + 114.0f, + 115.0f}; vector B_shape = {15}; vector Y_shape = {1, 15, 1, 1}; auto expected_vals = { - 15.0f, // 0.0*0.0 + 1.0*1.0 + 2.0*2.0 + 3.0*3.0 + 1.0 - 128.0f, - 369.0f, - 738.0f, - 1235.0f, - 1860.0f, - 2613.0f, // 24.0*24.0 + 25.0*25.0 + 26.0*26.0 + 27.0*27.0 + 7.0 - 3494.0f, - 4503.0f, - 5640.0f, - 6905.0f, - 8298.0f, - 9819.0f, // 48.0*48.0 + 49.0*49.0 + 50.0*50.0 + 51.0*51.0 + 13.0 - 11468.0f, // 52.0*52.0 + 53.0*53.0 + 54.0*54.0 + 55.0*55.0 + 14.0 - 13245.0f // 56.0*56.0 + 57.0*57.0 + 58.0*58.0 + 59.0*59.0 + 15.0 + 115.0f, // 0.0*0.0 + 1.0*1.0 + 2.0*2.0 + 3.0*3.0 + 101.0 + 228.0f, + 469.0f, + 838.0f, + 1335.0f, + 1960.0f, + 2713.0f, // 24.0*24.0 + 25.0*25.0 + 26.0*26.0 + 27.0*27.0 + 107.0 + 3594.0f, + 4603.0f, + 5740.0f, + 7005.0f, + 8398.0f, + 9919.0f, // 48.0*48.0 + 49.0*49.0 + 50.0*50.0 + 51.0*51.0 + 113.0 + 11568.0f, // 52.0*52.0 + 53.0*53.0 + 54.0*54.0 + 55.0*55.0 + 114.0 + 13345.0f // 56.0*56.0 + 57.0*57.0 + 58.0*58.0 + 59.0*59.0 + 115.0 }; TestConvOp(attrs, {X, W, B}, {X_shape, W_shape, B_shape}, expected_vals, Y_shape);