Skip to content

Commit

Permalink
Amend tests so bias cannot be ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
yihonglyu committed Jul 27, 2024
1 parent f479051 commit 8fbe6df
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 46 deletions.
60 changes: 30 additions & 30 deletions onnxruntime/test/providers/cpu/nn/conv_fp16_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -910,39 +910,39 @@ TEST(ConvFp16Test, Depthwise2D_Bias_Group15) {
MLFloat16(58.0f), MLFloat16(59.0f)};
vector<int64_t> W_shape = {15, 1, 2, 2};
vector<MLFloat16> 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<int64_t> B_shape = {15};
vector<int64_t> 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);
Expand Down
47 changes: 31 additions & 16 deletions onnxruntime/test/providers/cpu/nn/conv_op_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -842,25 +842,40 @@ TEST(ConvTest, Depthwise2D_Bias_Group15) {
56.0f, 57.0f,
58.0f, 59.0f};
vector<int64_t> W_shape = {15, 1, 2, 2};
vector<float> 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<float> 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<int64_t> B_shape = {15};
vector<int64_t> 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);
Expand Down

0 comments on commit 8fbe6df

Please sign in to comment.