Use designated initializers for TensorsToSegmentationCalculator tests.

PiperOrigin-RevId: 576671943
This commit is contained in:
Youchuan Hu 2023-10-25 16:00:45 -07:00 committed by Copybara-Service
parent a277d853ea
commit e7121e4feb

View File

@ -152,103 +152,96 @@ TEST_P(TensorsToSegmentationCalculatorTest, ParameterizedTests) {
INSTANTIATE_TEST_SUITE_P(
TensorsToSegmentationCalculatorTests, TensorsToSegmentationCalculatorTest,
testing::ValuesIn<FormattingTestCase>({
{/*test_name=*/"NoActivationAndNoOutputResize",
/*inputs=*/
{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
14.0, 15.0, 16.0},
/*expected_outputs=*/
{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
14.0, 15.0, 16.0},
/*activation=*/Options::NONE,
/*rows=*/4,
/*cols=*/4,
/*rows_new=*/4,
/*cols_new=*/4,
/*channels=*/1,
/*max_abs_diff=*/1e-7},
{/*test_name=*/"OutputResizeOnly",
/*inputs=*/
{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
14.0, 15.0, 16.0},
/*expected_outputs=*/
{1, 1.5, 2.166667, 2.833333, 3.5, 4,
3.8, 4.3, 4.966667, 5.633333, 6.3, 6.8,
7, 7.5, 8.166667, 8.833333, 9.5, 10,
10.2, 10.7, 11.366667, 12.033333, 12.7, 13.2,
13, 13.5, 14.166667, 14.833333, 15.5, 16},
/*activation=*/Options::NONE,
/*rows=*/4,
/*cols=*/4,
/*rows_new=*/5,
/*cols_new=*/6,
/*channels=*/1,
/*max_abs_diff=*/1e-6},
{/*test_name=*/"SigmoidActivationWithNoOutputResize",
/*inputs=*/
{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
14.0, 15.0, 16.0},
/*expected_outputs=*/
{0.731059, 0.880797, 0.952574, 0.982014, 0.993307, 0.997527, 0.999089,
0.999665, 0.999877, 0.999955, 0.999983, 0.999994, 0.999998, 0.999999,
1.0, 1.0},
/*activation=*/Options::SIGMOID,
/*rows=*/4,
/*cols=*/4,
/*rows_new=*/4,
/*cols_new=*/4,
/*channels=*/1,
/*max_abs_diff=*/1e-6},
{/*test_name=*/"SigmoidActivationWithOutputResize",
/*inputs=*/
{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
14.0, 15.0, 16.0},
/*expected_outputs=*/
{0.731059, 0.805928, 0.89276, 0.940611, 0.967294, 0.982014,
0.914633, 0.93857, 0.966279, 0.981363, 0.989752, 0.994369,
0.996592, 0.997666, 0.998873, 0.999404, 0.999683, 0.999829,
0.999913, 0.99994, 0.999971, 0.999985, 0.999992, 0.999996,
0.999998, 0.999998, 0.999999, 1.0, 1.0, 1.0},
/*activation=*/Options::SIGMOID,
/*rows=*/4,
/*cols=*/4,
/*rows_new=*/5,
/*cols_new=*/6,
/*channels=*/1,
/*max_abs_diff=*/1e-6},
{/*test_name=*/"SoftmaxActivationWithNoOutputResize",
/*inputs=*/
{1.0, 2.0, 4.0, 2.0, 3.0, 5.0, 6.0, 1.5, 7.0, 10.0, 11.0,
4.0, 12.0, 15.0, 16.0, 18.5, 19.0, 20.0, 22.0, 23.0, 24.5, 23.4,
25.6, 28.3, 29.2, 30.0, 24.6, 29.2, 30.0, 24.9, 31.2, 30.3},
/*expected_outputs=*/
{0.731059, 0.119203, 0.880797, 0.0109869, 0.952574, 0.000911051,
0.952574, 0.924142, 0.731059, 0.731059, 0.24974, 0.937027, 0.689974,
0.990048, 0.0060598, 0.28905},
/*activation=*/Options::SOFTMAX,
/*rows=*/4,
/*cols=*/4,
/*rows_new=*/4,
/*cols_new=*/4,
/*channels=*/2,
/*max_abs_diff=*/1e-6},
{/*test_name=*/"SoftmaxActivationWithOutputResize",
/*inputs=*/
{1.0, 2.0, 4.0, 2.0, 3.0, 5.0, 6.0, 1.5, 7.0, 10.0, 11.0,
4.0, 12.0, 15.0, 16.0, 18.5, 19.0, 20.0, 22.0, 23.0, 24.5, 23.4,
25.6, 28.3, 29.2, 30.0, 24.6, 29.2, 30.0, 24.9, 31.2, 30.3},
/*expected_outputs=*/
{0.731059, 0.425131, 0.246135, 0.753865, 0.445892, 0.0109869,
0.886119, 0.461259, 0.185506, 0.781934, 0.790618, 0.650195,
0.841816, 0.603901, 0.40518, 0.561962, 0.765871, 0.930584,
0.718733, 0.763744, 0.703402, 0.281989, 0.459635, 0.742634,
0.689974, 0.840011, 0.82605, 0.170058, 0.147555, 0.28905},
/*activation=*/Options::SOFTMAX,
/*rows=*/4,
/*cols=*/4,
/*rows_new=*/5,
/*cols_new=*/6,
/*channels=*/2,
/*max_abs_diff=*/1e-6},
{.test_name = "NoActivationAndNoOutputResize",
.inputs = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0,
12.0, 13.0, 14.0, 15.0, 16.0},
.expected_outputs = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0,
11.0, 12.0, 13.0, 14.0, 15.0, 16.0},
.activation = Options::NONE,
.rows = 4,
.cols = 4,
.rows_new = 4,
.cols_new = 4,
.channels = 1,
.max_abs_diff = 1e-7},
{.test_name = "OutputResizeOnly",
.inputs = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0,
12.0, 13.0, 14.0, 15.0, 16.0},
.expected_outputs = {1, 1.5, 2.166667, 2.833333, 3.5, 4,
3.8, 4.3, 4.966667, 5.633333, 6.3, 6.8,
7, 7.5, 8.166667, 8.833333, 9.5, 10,
10.2, 10.7, 11.366667, 12.033333, 12.7, 13.2,
13, 13.5, 14.166667, 14.833333, 15.5, 16},
.activation = Options::NONE,
.rows = 4,
.cols = 4,
.rows_new = 5,
.cols_new = 6,
.channels = 1,
.max_abs_diff = 1e-6},
{.test_name = "SigmoidActivationWithNoOutputResize",
.inputs = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0,
12.0, 13.0, 14.0, 15.0, 16.0},
.expected_outputs = {0.731059, 0.880797, 0.952574, 0.982014, 0.993307,
0.997527, 0.999089, 0.999665, 0.999877, 0.999955,
0.999983, 0.999994, 0.999998, 0.999999, 1.0, 1.0},
.activation = Options::SIGMOID,
.rows = 4,
.cols = 4,
.rows_new = 4,
.cols_new = 4,
.channels = 1,
.max_abs_diff = 1e-6},
{.test_name = "SigmoidActivationWithOutputResize",
.inputs = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0,
12.0, 13.0, 14.0, 15.0, 16.0},
.expected_outputs = {0.731059, 0.805928, 0.89276, 0.940611, 0.967294,
0.982014, 0.914633, 0.93857, 0.966279, 0.981363,
0.989752, 0.994369, 0.996592, 0.997666, 0.998873,
0.999404, 0.999683, 0.999829, 0.999913, 0.99994,
0.999971, 0.999985, 0.999992, 0.999996, 0.999998,
0.999998, 0.999999, 1.0, 1.0, 1.0},
.activation = Options::SIGMOID,
.rows = 4,
.cols = 4,
.rows_new = 5,
.cols_new = 6,
.channels = 1,
.max_abs_diff = 1e-6},
{.test_name = "SoftmaxActivationWithNoOutputResize",
.inputs = {1.0, 2.0, 4.0, 2.0, 3.0, 5.0, 6.0, 1.5,
7.0, 10.0, 11.0, 4.0, 12.0, 15.0, 16.0, 18.5,
19.0, 20.0, 22.0, 23.0, 24.5, 23.4, 25.6, 28.3,
29.2, 30.0, 24.6, 29.2, 30.0, 24.9, 31.2, 30.3},
.expected_outputs = {0.731059, 0.119203, 0.880797, 0.0109869, 0.952574,
0.000911051, 0.952574, 0.924142, 0.731059,
0.731059, 0.24974, 0.937027, 0.689974, 0.990048,
0.0060598, 0.28905},
.activation = Options::SOFTMAX,
.rows = 4,
.cols = 4,
.rows_new = 4,
.cols_new = 4,
.channels = 2,
.max_abs_diff = 1e-6},
{.test_name = "SoftmaxActivationWithOutputResize",
.inputs = {1.0, 2.0, 4.0, 2.0, 3.0, 5.0, 6.0, 1.5,
7.0, 10.0, 11.0, 4.0, 12.0, 15.0, 16.0, 18.5,
19.0, 20.0, 22.0, 23.0, 24.5, 23.4, 25.6, 28.3,
29.2, 30.0, 24.6, 29.2, 30.0, 24.9, 31.2, 30.3},
.expected_outputs = {0.731059, 0.425131, 0.246135, 0.753865, 0.445892,
0.0109869, 0.886119, 0.461259, 0.185506, 0.781934,
0.790618, 0.650195, 0.841816, 0.603901, 0.40518,
0.561962, 0.765871, 0.930584, 0.718733, 0.763744,
0.703402, 0.281989, 0.459635, 0.742634, 0.689974,
0.840011, 0.82605, 0.170058, 0.147555, 0.28905},
.activation = Options::SOFTMAX,
.rows = 4,
.cols = 4,
.rows_new = 5,
.cols_new = 6,
.channels = 2,
.max_abs_diff = 1e-6},
}),
[](const testing::TestParamInfo<
TensorsToSegmentationCalculatorTest::ParamType>& info) {