Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix test_gather.cpp&&test_gather.json #1084

Merged
merged 6 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tests/kernels/test_gather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class GatherTest : public KernelTest,
READY_SUBCASE()

auto shape = GetShapeArray("lhs_shape");
auto indices_shape = GetShapeArray("indices_shape");
auto value = GetNumber("axis");
auto typecode = GetDataType("lhs_type");

Expand All @@ -43,7 +44,7 @@ class GatherTest : public KernelTest,
init_tensor(input);

int64_t indices_array[] = {0, 0, -1, -1};
HeJunchao100813 marked this conversation as resolved.
Show resolved Hide resolved
indices = hrt::create(dt_int64, {4},
indices = hrt::create(dt_int64, indices_shape,
{reinterpret_cast<gsl::byte *>(indices_array),
sizeof(indices_array)},
true, host_runtime_tensor::pool_cpu_only)
Expand Down Expand Up @@ -112,15 +113,18 @@ TEST_P(GatherTest, gather) {
int main(int argc, char *argv[]) {
READY_TEST_CASE_GENERATE()
FOR_LOOP(lhs_shape, i)
FOR_LOOP(indices_shape, l)
FOR_LOOP(axis, j)
FOR_LOOP(lhs_type, k)
SPLIT_ELEMENT(lhs_shape, i)
SPLIT_ELEMENT(indices_shape, l)
SPLIT_ELEMENT(axis, j)
SPLIT_ELEMENT(lhs_type, k)
WRITE_SUB_CASE()
FOR_LOOP_END()
FOR_LOOP_END()
FOR_LOOP_END()
FOR_LOOP_END()

::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
Expand Down
1 change: 1 addition & 0 deletions tests/kernels/test_gather.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,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],
"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"]
}
6 changes: 5 additions & 1 deletion tests/kernels/test_gather_elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class GatherElementsTest : public KernelTest,
READY_SUBCASE()

auto shape = GetShapeArray("lhs_shape");
auto indices_shape = GetShapeArray("indices_shape");
auto value = GetNumber("axis");
auto typecode = GetDataType("lhs_type");

Expand All @@ -43,7 +44,7 @@ class GatherElementsTest : public KernelTest,
init_tensor(input);

int64_t indices_array[] = {0, 0, 1, 1};
indices = hrt::create(dt_int64, {2, 2},
indices = hrt::create(dt_int64, indices_shape,
{reinterpret_cast<gsl::byte *>(indices_array),
sizeof(indices_array)},
true, host_runtime_tensor::pool_cpu_only)
Expand Down Expand Up @@ -110,15 +111,18 @@ TEST_P(GatherElementsTest, gather_elements) {
int main(int argc, char *argv[]) {
READY_TEST_CASE_GENERATE()
FOR_LOOP(lhs_shape, i)
FOR_LOOP(indices_shape, l)
FOR_LOOP(axis, j)
FOR_LOOP(lhs_type, k)
SPLIT_ELEMENT(lhs_shape, i)
SPLIT_ELEMENT(indices_shape, l)
SPLIT_ELEMENT(axis, j)
SPLIT_ELEMENT(lhs_type, k)
WRITE_SUB_CASE()
FOR_LOOP_END()
FOR_LOOP_END()
FOR_LOOP_END()
FOR_LOOP_END()

::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
Expand Down
1 change: 1 addition & 0 deletions tests/kernels/test_gather_elements.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"lhs_shape":[[2, 2]],
"axis":[0],
"indices_shape":[[2, 2], [4, 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"]
}
6 changes: 5 additions & 1 deletion tests/kernels/test_gather_nd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class GatherNDTest : public KernelTest,
READY_SUBCASE()

auto shape = GetShapeArray("lhs_shape");
auto indices_shape = GetShapeArray("indices_shape");
auto value = GetNumber("axis");
auto typecode = GetDataType("lhs_type");

Expand All @@ -43,7 +44,7 @@ class GatherNDTest : public KernelTest,
init_tensor(input);

int64_t indices_array[] = {0, 0, 0, 0};
indices = hrt::create(dt_int64, {2, 2},
indices = hrt::create(dt_int64, indices_shape,
{reinterpret_cast<gsl::byte *>(indices_array),
sizeof(indices_array)},
true, host_runtime_tensor::pool_cpu_only)
Expand Down Expand Up @@ -109,15 +110,18 @@ TEST_P(GatherNDTest, gather_nd) {
int main(int argc, char *argv[]) {
READY_TEST_CASE_GENERATE()
FOR_LOOP(lhs_shape, i)
FOR_LOOP(indices_shape, l)
FOR_LOOP(axis, j)
FOR_LOOP(lhs_type, k)
SPLIT_ELEMENT(lhs_shape, i)
SPLIT_ELEMENT(indices_shape, l)
SPLIT_ELEMENT(axis, j)
SPLIT_ELEMENT(lhs_type, k)
WRITE_SUB_CASE()
FOR_LOOP_END()
FOR_LOOP_END()
FOR_LOOP_END()
FOR_LOOP_END()

::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
Expand Down
1 change: 1 addition & 0 deletions tests/kernels/test_gather_nd.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"lhs_shape":[[3, 5], [2, 2], [2, 3, 1], [5, 5, 7, 7]],
"axis":[0],
"indices_shape":[[2, 2], [4, 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"]
}
Loading