diff --git a/tests/kernels/test_conv2d.cpp b/tests/kernels/test_conv2d.cpp index 3d4cf62f78..e20ac27a4f 100644 --- a/tests/kernels/test_conv2d.cpp +++ b/tests/kernels/test_conv2d.cpp @@ -22,18 +22,26 @@ #include #include +#define TEST_CASE_NAME "test_conv2d" + using namespace nncase; using namespace nncase::runtime; using namespace ortki; class Conv2DTest : public KernelTest, - public ::testing::TestWithParam< - std::tuple> { + public ::testing::TestWithParam> { public: void SetUp() override { - auto &&[typecode, input_shape, weight_shape, bias_shape, value1, value2, - value3, value4] = GetParam(); + READY_SUBCASE() + + auto typecode = GetDataType("lhs_type"); + auto input_shape = GetShapeArray("lhs_shape"); + auto weight_shape = GetShapeArray("weight_shape"); + auto bias_shape = GetShapeArray("bias_shape"); + dilations_value = GetShapeArray("dilations_value"); + pad_value = GetShapeArray("pad_value"); + strides_value = GetShapeArray("strides_value"); + group_value = GetNumber("group_value"); input = hrt::create(typecode, input_shape, host_runtime_tensor::pool_cpu_only) @@ -49,14 +57,9 @@ class Conv2DTest : public KernelTest, host_runtime_tensor::pool_cpu_only) .expect("create tensor failed"); init_tensor(bais); - - dilations_value = value1; - pad_value = value2; - strides_value = value3; - group_value = value4; } - void TearDown() override {} + void TearDown() override { CLEAR_SUBCASE() } protected: runtime_tensor input; @@ -68,16 +71,8 @@ class Conv2DTest : public KernelTest, int64_t group_value; }; -INSTANTIATE_TEST_SUITE_P( - conv2d, Conv2DTest, - testing::Combine( - testing::Values(dt_float32), - testing::Values(dims_t{1, 4, 5, 5}, dims_t{1, 4, 16, 16}), - testing::Values(dims_t{8, 4, 3, 3}, dims_t{8, 4, 1, 1}), - testing::Values(dims_t{8}), testing::Values(dims_t{2, 2}, dims_t{1, 1}), - testing::Values(dims_t{1, 1, 1, 1} /*, dims_t{0, 0, 1, 0}*/), - testing::Values(dims_t{1, 1}, dims_t{2, 2}), - testing::Values(1 /*, 2*/))); // todo result error +INSTANTIATE_TEST_SUITE_P(conv2d, Conv2DTest, + testing::Combine(testing::Range(0, MAX_CASE_NUM))); TEST_P(Conv2DTest, conv2d) { auto input_ort = runtime_tensor_2_ort_tensor(input); @@ -181,6 +176,33 @@ TEST_P(Conv2DTest, conv2d) { } int main(int argc, char *argv[]) { + READY_TEST_CASE_GENERATE() + FOR_LOOP(lhs_type, i) + FOR_LOOP(lhs_shape, j) + FOR_LOOP(weight_shape, k) + FOR_LOOP(bias_shape, l) + FOR_LOOP(dilations_value, m) + FOR_LOOP(pad_value, n) + FOR_LOOP(strides_value, o) + FOR_LOOP(group_value, p) + SPLIT_ELEMENT(lhs_type, i) + SPLIT_ELEMENT(lhs_shape, j) + SPLIT_ELEMENT(weight_shape, k) + SPLIT_ELEMENT(bias_shape, l) + SPLIT_ELEMENT(dilations_value, m) + SPLIT_ELEMENT(pad_value, n) + SPLIT_ELEMENT(strides_value, o) + SPLIT_ELEMENT(group_value, p) + WRITE_SUB_CASE() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/tests/kernels/test_conv2d.json b/tests/kernels/test_conv2d.json new file mode 100644 index 0000000000..ccba39b078 --- /dev/null +++ b/tests/kernels/test_conv2d.json @@ -0,0 +1,10 @@ +{ + "lhs_type":["dt_float32"], + "lhs_shape":[[1, 4, 5, 5], [1, 4, 16, 16]], + "weight_shape":[[8, 4, 3, 3], [8, 4, 1, 1]], + "bias_shape":[[8]], + "dilations_value":[[2, 2], [1, 1]], + "pad_value":[[1, 1, 1, 1]], + "strides_value":[[1, 1], [2, 2]], + "group_value":[1] +} \ No newline at end of file diff --git a/tests/kernels/test_conv2d_transpose.cpp b/tests/kernels/test_conv2d_transpose.cpp index 96e60a1d86..24331e757c 100644 --- a/tests/kernels/test_conv2d_transpose.cpp +++ b/tests/kernels/test_conv2d_transpose.cpp @@ -22,19 +22,28 @@ #include #include +#define TEST_CASE_NAME "test_conv2d_transpose" + using namespace nncase; using namespace nncase::runtime; using namespace ortki; -class Conv2DTransposeTest - : public KernelTest, - public ::testing::TestWithParam< - std::tuple> { +class Conv2DTransposeTest : public KernelTest, + public ::testing::TestWithParam> { public: void SetUp() override { - auto &&[typecode, input_shape, weight_shape, bias_shape, value1, value2, - value3, value4, value5, value6] = GetParam(); + READY_SUBCASE() + + auto typecode = GetDataType("lhs_type"); + auto input_shape = GetShapeArray("lhs_shape"); + auto weight_shape = GetShapeArray("weight_shape"); + auto bias_shape = GetShapeArray("bias_shape"); + dilations_value = GetShapeArray("dilations_value"); + pad_value = GetShapeArray("pad_value"); + strides_value = GetShapeArray("strides_value"); + group_value = GetNumber("group_value"); + output_padding_value = GetShapeArray("output_padding_value"); + output_shape_value = GetShapeArray("output_shape_value"); input = hrt::create(typecode, input_shape, host_runtime_tensor::pool_cpu_only) @@ -50,16 +59,9 @@ class Conv2DTransposeTest host_runtime_tensor::pool_cpu_only) .expect("create tensor failed"); init_tensor(bais); - - dilations_value = value1; - pad_value = value2; - strides_value = value3; - group_value = value4; - output_padding_value = value5; - output_shape_value = value6; } - void TearDown() override {} + void TearDown() override { CLEAR_SUBCASE() } protected: runtime_tensor input; @@ -73,16 +75,8 @@ class Conv2DTransposeTest int64_t group_value; }; -INSTANTIATE_TEST_SUITE_P( - conv2d_transpose, Conv2DTransposeTest, - testing::Combine( - testing::Values(dt_float32), testing::Values(dims_t{1, 1, 5, 5}), - testing::Values(dims_t{1, 2, 3, 3}), testing::Values(dims_t{2}), - testing::Values(/*dims_t{2, 2} ,*/ dims_t{1, 1}), - testing::Values(dims_t{1, 1, 1, 1} /*, dims_t{0, 0, 1, 0}*/), - testing::Values(dims_t{1, 1} /*, dims_t{2, 2}*/), - testing::Values(1 /*, 2*/), testing::Values(dims_t{0, 0}), - testing::Values(dims_t{1, 2, 5, 5}))); +INSTANTIATE_TEST_SUITE_P(conv2d_transpose, Conv2DTransposeTest, + testing::Combine(testing::Range(0, MAX_CASE_NUM))); TEST_P(Conv2DTransposeTest, conv2d_transpose) { auto input_ort = runtime_tensor_2_ort_tensor(input); @@ -210,17 +204,38 @@ TEST_P(Conv2DTransposeTest, conv2d_transpose) { } int main(int argc, char *argv[]) { - // READY_TEST_CASE_GENERATE() - // FOR_LOOP(lhs_shape, i) - // FOR_LOOP(lhs_type, j) - // FOR_LOOP(rhs_type, k) - // SPLIT_ELEMENT(lhs_shape, i) - // SPLIT_ELEMENT(lhs_type, j) - // SPLIT_ELEMENT(rhs_type, k) - // WRITE_SUB_CASE() - // FOR_LOOP_END() - // FOR_LOOP_END() - // FOR_LOOP_END() + READY_TEST_CASE_GENERATE() + FOR_LOOP(lhs_type, i) + FOR_LOOP(lhs_shape, j) + FOR_LOOP(weight_shape, k) + FOR_LOOP(bias_shape, l) + FOR_LOOP(dilations_value, m) + FOR_LOOP(pad_value, n) + FOR_LOOP(strides_value, o) + FOR_LOOP(group_value, p) + FOR_LOOP(output_padding_value, r) + FOR_LOOP(output_shape_value, s) + SPLIT_ELEMENT(lhs_type, i) + SPLIT_ELEMENT(lhs_shape, j) + SPLIT_ELEMENT(weight_shape, k) + SPLIT_ELEMENT(bias_shape, l) + SPLIT_ELEMENT(dilations_value, m) + SPLIT_ELEMENT(pad_value, n) + SPLIT_ELEMENT(strides_value, o) + SPLIT_ELEMENT(group_value, p) + SPLIT_ELEMENT(output_padding_value, r) + SPLIT_ELEMENT(output_shape_value, s) + WRITE_SUB_CASE() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/tests/kernels/test_conv2d_transpose.json b/tests/kernels/test_conv2d_transpose.json index 8ddf991217..89b32ebb48 100644 --- a/tests/kernels/test_conv2d_transpose.json +++ b/tests/kernels/test_conv2d_transpose.json @@ -1,4 +1,12 @@ { - "lhs_shape":[[1, 8, 24, 24], [1, 3, 3, 16], [2, 4, 8, 8], [8, 8], [1, 3, 16, 1], [1, 1], [16]], - "lhs_type":["dt_int32"] + "lhs_type":["dt_float32"], + "lhs_shape":[[1, 1, 5, 5]], + "weight_shape":[[1, 2, 3, 3]], + "bias_shape":[[2]], + "dilations_value":[[1, 1]], + "pad_value":[[1, 1, 1, 1]], + "strides_value":[[1, 1]], + "group_value":[1], + "output_padding_value":[[0, 0]], + "output_shape_value":[[1, 2, 5, 5]] } \ No newline at end of file diff --git a/tests/kernels/test_gather.cpp b/tests/kernels/test_gather.cpp index b988fe4b3d..15a3dbc797 100644 --- a/tests/kernels/test_gather.cpp +++ b/tests/kernels/test_gather.cpp @@ -22,16 +22,21 @@ #include #include +#define TEST_CASE_NAME "test_gather" + using namespace nncase; using namespace nncase::runtime; using namespace ortki; class GatherTest : public KernelTest, - public ::testing::TestWithParam< - std::tuple> { + public ::testing::TestWithParam> { public: void SetUp() override { - auto &&[typecode, shape, value] = GetParam(); + READY_SUBCASE() + + auto shape = GetShapeArray("lhs_shape"); + auto value = GetNumber("axis"); + auto typecode = GetDataType("lhs_type"); input = hrt::create(typecode, shape, host_runtime_tensor::pool_cpu_only) .expect("create tensor failed"); @@ -57,7 +62,7 @@ class GatherTest : public KernelTest, .expect("create tensor failed"); } - void TearDown() override {} + void TearDown() override { CLEAR_SUBCASE() } protected: runtime_tensor input; @@ -66,16 +71,8 @@ class GatherTest : public KernelTest, int64_t batchDims_value; }; -INSTANTIATE_TEST_SUITE_P( - gather, GatherTest, - testing::Combine(testing::Values(dt_int32, dt_int64, dt_float32, dt_uint64, - dt_int8, dt_int16, dt_uint8, dt_uint16, - dt_uint32, dt_float16, dt_float64, - dt_bfloat16, dt_boolean), - testing::Values(dims_t{2, 3, 5, 7}, dims_t{2, 2}, - dims_t{2, 3, 1}, dims_t{5, 5, 7, 7}, - dims_t{11}), - testing::Values(-1, 0, 1, -2, -3, 2, 3, -4))); +INSTANTIATE_TEST_SUITE_P(gather, GatherTest, + testing::Combine(testing::Range(0, MAX_CASE_NUM))); TEST_P(GatherTest, gather) { auto input_ort = runtime_tensor_2_ort_tensor(input); @@ -113,6 +110,18 @@ TEST_P(GatherTest, gather) { } int main(int argc, char *argv[]) { + READY_TEST_CASE_GENERATE() + FOR_LOOP(lhs_shape, i) + FOR_LOOP(axis, j) + FOR_LOOP(lhs_type, k) + SPLIT_ELEMENT(lhs_shape, i) + SPLIT_ELEMENT(axis, j) + SPLIT_ELEMENT(lhs_type, k) + WRITE_SUB_CASE() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/tests/kernels/test_gather.json b/tests/kernels/test_gather.json new file mode 100644 index 0000000000..b39845f716 --- /dev/null +++ b/tests/kernels/test_gather.json @@ -0,0 +1,5 @@ +{ + "lhs_shape":[[2, 3, 5, 7], [2, 2], [2, 3, 1], [5, 5, 7, 7], [11]], + "axis":[0, 1, -1, 2, 3, -2, -3, -4], + "lhs_type":["dt_float32", "dt_int8", "dt_int32", "dt_uint8", "dt_int16", "dt_uint16", "dt_uint32", "dt_uint64", "dt_int64", "dt_float16", "dt_float64", "dt_bfloat16", "dt_boolean"] +} \ No newline at end of file diff --git a/tests/kernels/test_gather_elements.cpp b/tests/kernels/test_gather_elements.cpp index 1a17edaecf..9535851933 100644 --- a/tests/kernels/test_gather_elements.cpp +++ b/tests/kernels/test_gather_elements.cpp @@ -22,17 +22,21 @@ #include #include +#define TEST_CASE_NAME "test_gather_elements" + using namespace nncase; using namespace nncase::runtime; using namespace ortki; -class GatherElementsTest - : public KernelTest, - public ::testing::TestWithParam< - std::tuple> { +class GatherElementsTest : public KernelTest, + public ::testing::TestWithParam> { public: void SetUp() override { - auto &&[typecode, shape, value] = GetParam(); + READY_SUBCASE() + + auto shape = GetShapeArray("lhs_shape"); + auto value = GetNumber("axis"); + auto typecode = GetDataType("lhs_type"); input = hrt::create(typecode, shape, host_runtime_tensor::pool_cpu_only) .expect("create tensor failed"); @@ -46,7 +50,8 @@ class GatherElementsTest .expect("create tensor failed"); batchDims_value = value; - int64_t batchDims_array[1] = {value}; + + int64_t batchDims_array[1] = {batchDims_value}; batchDims = hrt::create(dt_int64, dims_t{1}, {reinterpret_cast(batchDims_array), sizeof(batchDims_array)}, @@ -54,7 +59,7 @@ class GatherElementsTest .expect("create tensor failed"); } - void TearDown() override {} + void TearDown() override { CLEAR_SUBCASE() } protected: runtime_tensor input; @@ -63,19 +68,8 @@ class GatherElementsTest int64_t batchDims_value; }; -INSTANTIATE_TEST_SUITE_P( - gather_elements, GatherElementsTest, - testing::Combine(testing::Values(dt_int32, dt_int64, dt_float32, dt_uint64, - dt_int8, dt_int16, dt_uint8, dt_uint16, - dt_uint32, dt_float16, dt_float64, - dt_bfloat16, dt_boolean), - testing::Values(dims_t{ - 2, - 2} /*, dims_t{3, 5}, - dims_t{2, 3, 1}, dims_t{5, 7, 5}, - dims_t{5, 4, 3, 2}, dims_t{5, 5, 7, 7}, - dims_t{2, 3, 3, 5}*/), - testing::Values(-1, 0, 1))); +INSTANTIATE_TEST_SUITE_P(gather_elements, GatherElementsTest, + testing::Combine(testing::Range(0, MAX_CASE_NUM))); TEST_P(GatherElementsTest, gather_elements) { auto input_ort = runtime_tensor_2_ort_tensor(input); @@ -114,6 +108,18 @@ TEST_P(GatherElementsTest, gather_elements) { } int main(int argc, char *argv[]) { + READY_TEST_CASE_GENERATE() + FOR_LOOP(lhs_shape, i) + FOR_LOOP(axis, j) + FOR_LOOP(lhs_type, k) + SPLIT_ELEMENT(lhs_shape, i) + SPLIT_ELEMENT(axis, j) + SPLIT_ELEMENT(lhs_type, k) + WRITE_SUB_CASE() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/tests/kernels/test_gather_elements.json b/tests/kernels/test_gather_elements.json new file mode 100644 index 0000000000..b12b58e166 --- /dev/null +++ b/tests/kernels/test_gather_elements.json @@ -0,0 +1,5 @@ +{ + "lhs_shape":[[2, 2]], + "axis":[0], + "lhs_type":["dt_float32", "dt_int8", "dt_int32", "dt_uint8", "dt_int16", "dt_uint16", "dt_uint32", "dt_uint64", "dt_int64", "dt_float16", "dt_float64", "dt_bfloat16", "dt_boolean"] +} \ No newline at end of file diff --git a/tests/kernels/test_gather_nd.cpp b/tests/kernels/test_gather_nd.cpp index fb4687f5f7..8e95c443d7 100644 --- a/tests/kernels/test_gather_nd.cpp +++ b/tests/kernels/test_gather_nd.cpp @@ -22,30 +22,36 @@ #include #include +#define TEST_CASE_NAME "test_gather_nd" + using namespace nncase; using namespace nncase::runtime; using namespace ortki; class GatherNDTest : public KernelTest, - public ::testing::TestWithParam< - std::tuple> { + public ::testing::TestWithParam> { public: void SetUp() override { - auto &&[typecode, shape, value] = GetParam(); + READY_SUBCASE() + + auto shape = GetShapeArray("lhs_shape"); + auto value = GetNumber("axis"); + auto typecode = GetDataType("lhs_type"); input = hrt::create(typecode, shape, host_runtime_tensor::pool_cpu_only) .expect("create tensor failed"); init_tensor(input); - int64_t indices_array[] = {0, 0, 1, 1}; - indices = hrt::create(dt_int64, shape, + int64_t indices_array[] = {0, 0, 0, 0}; + indices = hrt::create(dt_int64, {2, 2}, {reinterpret_cast(indices_array), sizeof(indices_array)}, true, host_runtime_tensor::pool_cpu_only) .expect("create tensor failed"); batchDims_value = value; - int64_t batchDims_array[1] = {value}; + + int64_t batchDims_array[1] = {batchDims_value}; batchDims = hrt::create(dt_int64, dims_t{1}, {reinterpret_cast(batchDims_array), sizeof(batchDims_array)}, @@ -53,7 +59,7 @@ class GatherNDTest : public KernelTest, .expect("create tensor failed"); } - void TearDown() override {} + void TearDown() override { CLEAR_SUBCASE() } protected: runtime_tensor input; @@ -62,16 +68,8 @@ class GatherNDTest : public KernelTest, int64_t batchDims_value; }; -INSTANTIATE_TEST_SUITE_P( - gather_nd, GatherNDTest, - testing::Combine(testing::Values(dt_int32, dt_int64, dt_float32, dt_uint64, - dt_int8, dt_int16, dt_uint8, dt_uint16, - dt_uint32, dt_float16, dt_float64, - dt_bfloat16, dt_boolean), - testing::Values(dims_t{2, 2} /*, dims_t{3, 5}, - dims_t{2, 3, 1}, dims_t{5, 7, 5}, - dims_t{5, 4, 3, 2}, dims_t{5, 5, 7, 7}, - dims_t{2, 3, 3, 5}*/), testing::Values(0 /*, -1, 1*/))); +INSTANTIATE_TEST_SUITE_P(gather_nd, GatherNDTest, + testing::Combine(testing::Range(0, MAX_CASE_NUM))); TEST_P(GatherNDTest, gather_nd) { auto input_ort = runtime_tensor_2_ort_tensor(input); @@ -109,6 +107,18 @@ TEST_P(GatherNDTest, gather_nd) { } int main(int argc, char *argv[]) { + READY_TEST_CASE_GENERATE() + FOR_LOOP(lhs_shape, i) + FOR_LOOP(axis, j) + FOR_LOOP(lhs_type, k) + SPLIT_ELEMENT(lhs_shape, i) + SPLIT_ELEMENT(axis, j) + SPLIT_ELEMENT(lhs_type, k) + WRITE_SUB_CASE() + FOR_LOOP_END() + FOR_LOOP_END() + FOR_LOOP_END() + ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/tests/kernels/test_gather_nd.json b/tests/kernels/test_gather_nd.json new file mode 100644 index 0000000000..64c54990be --- /dev/null +++ b/tests/kernels/test_gather_nd.json @@ -0,0 +1,5 @@ +{ + "lhs_shape":[[3, 5], [2, 2], [2, 3, 1], [5, 5, 7, 7]], + "axis":[0], + "lhs_type":["dt_float32", "dt_int8", "dt_int32", "dt_uint8", "dt_int16", "dt_uint16", "dt_uint32", "dt_uint64", "dt_int64", "dt_float16", "dt_float64", "dt_bfloat16", "dt_boolean"] +} \ No newline at end of file diff --git a/tests/kernels/test_get_item.cpp b/tests/kernels/test_get_item.cpp index 2bd4f08365..009044becb 100644 --- a/tests/kernels/test_get_item.cpp +++ b/tests/kernels/test_get_item.cpp @@ -22,16 +22,20 @@ #include #include +#define TEST_CASE_NAME "test_get_item" + using namespace nncase; using namespace nncase::runtime; using namespace ortki; -class GetItemTest - : public KernelTest, - public ::testing::TestWithParam> { +class GetItemTest : public KernelTest, + public ::testing::TestWithParam> { public: void SetUp() override { - auto &&[typecode, l_shape] = GetParam(); + READY_SUBCASE() + + auto l_shape = GetShapeArray("lhs_shape"); + auto typecode = GetDataType("lhs_type"); input = hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only) @@ -46,8 +50,7 @@ class GetItemTest }; INSTANTIATE_TEST_SUITE_P(get_item, GetItemTest, - testing::Combine(testing::Values(dt_float32), - testing::Values(dims_t{1}))); + testing::Combine(testing::Range(0, MAX_CASE_NUM))); TEST_P(GetItemTest, get_item) { @@ -62,19 +65,11 @@ TEST_P(GetItemTest, get_item) { true, host_runtime_tensor::pool_cpu_only) .expect("create tensor failed"); - int64_t shape_ort[] = {1}; - auto shape = hrt::create(dt_int64, {1}, - {reinterpret_cast(shape_ort), - sizeof(shape_ort)}, - true, host_runtime_tensor::pool_cpu_only) - .expect("create tensor failed"); - auto get_item_output = kernels::stackvm::get_item(input.impl(), index.impl()) .expect("get_item failed"); - auto output = kernels::stackvm::reshape(get_item_output, shape.impl()) - .expect("get_item failed"); + auto output = get_item_output; runtime_tensor actual(output.as().expect("as tensor failed")); bool result = is_same_tensor(expected, actual) || @@ -92,6 +87,15 @@ TEST_P(GetItemTest, get_item) { } int main(int argc, char *argv[]) { + READY_TEST_CASE_GENERATE() + FOR_LOOP(lhs_shape, j) + FOR_LOOP(lhs_type, i) + SPLIT_ELEMENT(lhs_shape, j) + SPLIT_ELEMENT(lhs_type, i) + WRITE_SUB_CASE() + FOR_LOOP_END() + FOR_LOOP_END() + ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/tests/kernels/test_get_item.json b/tests/kernels/test_get_item.json new file mode 100644 index 0000000000..b981385e1c --- /dev/null +++ b/tests/kernels/test_get_item.json @@ -0,0 +1,4 @@ +{ + "lhs_shape":[[1]], + "lhs_type":["dt_float32"] +} \ No newline at end of file diff --git a/tests/kernels/test_instance_normalization.cpp b/tests/kernels/test_instance_normalization.cpp index 0f0d6efaaa..d4fb672f8a 100644 --- a/tests/kernels/test_instance_normalization.cpp +++ b/tests/kernels/test_instance_normalization.cpp @@ -22,16 +22,21 @@ #include #include +#define TEST_CASE_NAME "test_instance_normalization" + using namespace nncase; using namespace nncase::runtime; using namespace ortki; class InstanceNormalizationTest : public KernelTest, - public ::testing::TestWithParam> { + public ::testing::TestWithParam> { public: void SetUp() override { - auto &&[typecode, l_shape] = GetParam(); + READY_SUBCASE() + + auto l_shape = GetShapeArray("lhs_shape"); + auto typecode = GetDataType("lhs_type"); input = hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only) @@ -49,7 +54,7 @@ class InstanceNormalizationTest init_tensor(b); } - void TearDown() override {} + void TearDown() override { CLEAR_SUBCASE() } protected: runtime_tensor input; @@ -57,14 +62,8 @@ class InstanceNormalizationTest runtime_tensor b; }; -INSTANTIATE_TEST_SUITE_P( - instance_normalization, InstanceNormalizationTest, - testing::Combine(testing::Values(dt_float32), - testing::Values(dims_t{3, 3, 16, 16}, dims_t{64, 2, 4, 8}, - dims_t{1, 2, 4, 8}, - dims_t{24, 3, - 16} /*, dims_t{24, 16, 16}*/))); -// todo when in_shape[0] is not 1,cos is about 0.96 +INSTANTIATE_TEST_SUITE_P(instance_normalization, InstanceNormalizationTest, + testing::Combine(testing::Range(0, MAX_CASE_NUM))); TEST_P(InstanceNormalizationTest, instance_normalization) { auto l_ort = runtime_tensor_2_ort_tensor(input); @@ -110,6 +109,15 @@ TEST_P(InstanceNormalizationTest, instance_normalization) { } int main(int argc, char *argv[]) { + READY_TEST_CASE_GENERATE() + FOR_LOOP(lhs_shape, i) + FOR_LOOP(lhs_type, j) + SPLIT_ELEMENT(lhs_shape, i) + SPLIT_ELEMENT(lhs_type, j) + WRITE_SUB_CASE() + FOR_LOOP_END() + FOR_LOOP_END() + ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/tests/kernels/test_instance_normalization.json b/tests/kernels/test_instance_normalization.json new file mode 100644 index 0000000000..e8478a0f2d --- /dev/null +++ b/tests/kernels/test_instance_normalization.json @@ -0,0 +1,4 @@ +{ + "lhs_shape":[[3, 3, 16, 16], [64, 2, 4, 8], [1, 2, 4, 8], [24, 16, 16], [24, 3, 16]], + "lhs_type":["dt_float32"], +} \ No newline at end of file diff --git a/tests/kernels/test_topK.cpp b/tests/kernels/test_topK.cpp index 7307abff03..de519de96b 100644 --- a/tests/kernels/test_topK.cpp +++ b/tests/kernels/test_topK.cpp @@ -49,7 +49,7 @@ class TopKTest : public KernelTest, axis_value = value1 > 0 ? value1 >= (int64_t)l_shape.size() ? 0 : value1 : -value1 > (int64_t)l_shape.size() ? 0 : value1; - int64_t axis_array[] = {value1}; + int64_t axis_array[] = {axis_value}; axis = hrt::create(dt_int64, {1}, {reinterpret_cast(axis_array), sizeof(axis_array)}, @@ -91,14 +91,6 @@ class TopKTest : public KernelTest, INSTANTIATE_TEST_SUITE_P(TopK, TopKTest, testing::Combine(testing::Range(0, MAX_CASE_NUM))); -// testing::Combine(testing::Values(dt_float32), -// testing::Values(dims_t{1, 2, 4, 8}, dims_t{1, 3, 16, 16}, -// dims_t{3, 3, 6}, dims_t{16, 16}, -// dims_t{1}, dims_t{1, 3}), -// testing::Values(0, -1 /*, 1, 2, 3*/), -// testing::Values(0, 1), testing::Values(0, 1), -// testing::Values(1 /*, 2, 4, 16*/))); - TEST_P(TopKTest, TopK) { auto l_ort = runtime_tensor_2_ort_tensor(input); diff --git a/tests/kernels/test_topk.json b/tests/kernels/test_topk.json index e81402d777..38dcf435b3 100644 --- a/tests/kernels/test_topk.json +++ b/tests/kernels/test_topk.json @@ -1,7 +1,7 @@ { - "lhs_shape":[[1, 2, 4, 8], [1, 3, 16, 16], [3, 3, 6], [16, 16], [1], [1, 3]], + "lhs_shape":[[2, 3, 16, 16], [2, 3, 16], [16, 16], [6], [1, 3, 16, 16]], "lhs_type":["dt_float32"], - "value1": [0, -1], + "value1": [0, 1, 2, 3, -1, -2, -3, -4], "value2": [0, 1], "value3": [0, 1], "value4": [1]