diff --git a/tests/kernels/test_gather.cpp b/tests/kernels/test_gather.cpp index 08d40b1b84..819f315c06 100644 --- a/tests/kernels/test_gather.cpp +++ b/tests/kernels/test_gather.cpp @@ -36,6 +36,7 @@ class GatherTest : public KernelTest, auto shape = GetShapeArray("lhs_shape"); auto indices_shape = GetShapeArray("indices_shape"); + auto indices_value = GetDataArray("indices_value"); auto value = GetNumber("axis"); auto typecode = GetDataType("lhs_type"); @@ -43,10 +44,13 @@ class GatherTest : public KernelTest, .expect("create tensor failed"); init_tensor(input); - int64_t indices_array[] = {0, 0, -1, -1}; + size_t indices_value_size = indices_value.size(); + auto *indices_array = + (int64_t *)malloc(indices_value_size * sizeof(int64_t)); + std::copy(indices_value.begin(), indices_value.end(), indices_array); indices = hrt::create(dt_int64, indices_shape, {reinterpret_cast(indices_array), - sizeof(indices_array)}, + indices_value_size * sizeof(int64_t)}, true, host_runtime_tensor::pool_cpu_only) .expect("create tensor failed"); @@ -114,10 +118,12 @@ int main(int argc, char *argv[]) { READY_TEST_CASE_GENERATE() FOR_LOOP(lhs_shape, i) FOR_LOOP(indices_shape, l) + FOR_LOOP(indices_value, h) FOR_LOOP(axis, j) FOR_LOOP(lhs_type, k) SPLIT_ELEMENT(lhs_shape, i) SPLIT_ELEMENT(indices_shape, l) + SPLIT_ELEMENT(indices_value, h) SPLIT_ELEMENT(axis, j) SPLIT_ELEMENT(lhs_type, k) WRITE_SUB_CASE() @@ -125,6 +131,7 @@ int main(int argc, char *argv[]) { 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_gather.json b/tests/kernels/test_gather.json index 90d7269151..c294a31800 100644 --- a/tests/kernels/test_gather.json +++ b/tests/kernels/test_gather.json @@ -2,5 +2,6 @@ "lhs_shape":[[2, 3, 5, 7], [2, 2], [2, 3, 1], [5, 5, 7, 7], [11]], "indices_shape":[[4], [2, 2], [4, 1]], "axis":[0, 1, -1, 2, 3, -2, -3, -4], + "indices_value": [[0, 0, -1, -1]], "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 31f95e2d50..748c06256e 100644 --- a/tests/kernels/test_gather_elements.cpp +++ b/tests/kernels/test_gather_elements.cpp @@ -36,6 +36,7 @@ class GatherElementsTest : public KernelTest, auto shape = GetShapeArray("lhs_shape"); auto indices_shape = GetShapeArray("indices_shape"); + auto indices_value = GetDataArray("indices_value"); auto value = GetNumber("axis"); auto typecode = GetDataType("lhs_type"); @@ -43,10 +44,13 @@ class GatherElementsTest : public KernelTest, .expect("create tensor failed"); init_tensor(input); - int64_t indices_array[] = {0, 0, 1, 1}; + size_t indices_value_size = indices_value.size(); + auto *indices_array = + (int64_t *)malloc(indices_value_size * sizeof(int64_t)); + std::copy(indices_value.begin(), indices_value.end(), indices_array); indices = hrt::create(dt_int64, indices_shape, {reinterpret_cast(indices_array), - sizeof(indices_array)}, + indices_value_size * sizeof(int64_t)}, true, host_runtime_tensor::pool_cpu_only) .expect("create tensor failed"); @@ -112,10 +116,12 @@ int main(int argc, char *argv[]) { READY_TEST_CASE_GENERATE() FOR_LOOP(lhs_shape, i) FOR_LOOP(indices_shape, l) + FOR_LOOP(indices_value, h) FOR_LOOP(axis, j) FOR_LOOP(lhs_type, k) SPLIT_ELEMENT(lhs_shape, i) SPLIT_ELEMENT(indices_shape, l) + SPLIT_ELEMENT(indices_value, h) SPLIT_ELEMENT(axis, j) SPLIT_ELEMENT(lhs_type, k) WRITE_SUB_CASE() @@ -123,6 +129,7 @@ int main(int argc, char *argv[]) { 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_gather_elements.json b/tests/kernels/test_gather_elements.json index 5f0eaf8665..810930883f 100644 --- a/tests/kernels/test_gather_elements.json +++ b/tests/kernels/test_gather_elements.json @@ -2,5 +2,6 @@ "lhs_shape":[[2, 2]], "axis":[0], "indices_shape":[[2, 2], [4, 1]], + "indices_value": [[0, 0, 1, 1]], "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 33f96a71a1..96706b62b4 100644 --- a/tests/kernels/test_gather_nd.cpp +++ b/tests/kernels/test_gather_nd.cpp @@ -36,6 +36,7 @@ class GatherNDTest : public KernelTest, auto shape = GetShapeArray("lhs_shape"); auto indices_shape = GetShapeArray("indices_shape"); + auto indices_value = GetDataArray("indices_value"); auto value = GetNumber("axis"); auto typecode = GetDataType("lhs_type"); @@ -43,10 +44,13 @@ class GatherNDTest : public KernelTest, .expect("create tensor failed"); init_tensor(input); - int64_t indices_array[] = {0, 0, 0, 0}; + size_t indices_value_size = indices_value.size(); + auto *indices_array = + (int64_t *)malloc(indices_value_size * sizeof(int64_t)); + std::copy(indices_value.begin(), indices_value.end(), indices_array); indices = hrt::create(dt_int64, indices_shape, {reinterpret_cast(indices_array), - sizeof(indices_array)}, + indices_value_size * sizeof(int64_t)}, true, host_runtime_tensor::pool_cpu_only) .expect("create tensor failed"); @@ -111,10 +115,12 @@ int main(int argc, char *argv[]) { READY_TEST_CASE_GENERATE() FOR_LOOP(lhs_shape, i) FOR_LOOP(indices_shape, l) + FOR_LOOP(indices_value, h) FOR_LOOP(axis, j) FOR_LOOP(lhs_type, k) SPLIT_ELEMENT(lhs_shape, i) SPLIT_ELEMENT(indices_shape, l) + SPLIT_ELEMENT(indices_value, h) SPLIT_ELEMENT(axis, j) SPLIT_ELEMENT(lhs_type, k) WRITE_SUB_CASE() @@ -122,6 +128,7 @@ int main(int argc, char *argv[]) { 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_gather_nd.json b/tests/kernels/test_gather_nd.json index 347d31da32..a9af374f7d 100644 --- a/tests/kernels/test_gather_nd.json +++ b/tests/kernels/test_gather_nd.json @@ -2,5 +2,6 @@ "lhs_shape":[[3, 5], [2, 2], [2, 3, 1], [5, 5, 7, 7]], "axis":[0], "indices_shape":[[2, 2], [4, 1]], + "indices_value": [[0, 0, 0, 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