summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>2020-01-08 16:02:26 +0900
committer이한종/On-Device Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>2020-01-08 16:02:26 +0900
commit5d9914ec06fd880330be086b7623b05e4cd957dd (patch)
treeb7396a20c24bed2a49a1a884e20c1ca823653666
parent900d19c35f657cb82a1e04af64bfe1e86c6c28d3 (diff)
downloadnnfw-5d9914ec06fd880330be086b7623b05e4cd957dd.tar.gz
nnfw-5d9914ec06fd880330be086b7623b05e4cd957dd.tar.bz2
nnfw-5d9914ec06fd880330be086b7623b05e4cd957dd.zip
[neurun] Gather handle negative axis (#9839)
acl_cl, acl_neon, and cpu backend can handle gather's negative axis parameter Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
-rw-r--r--runtime/neurun/backend/acl_cl/KernelGenerator.cc3
-rw-r--r--runtime/neurun/backend/acl_neon/KernelGenerator.cc3
-rw-r--r--runtime/neurun/backend/cpu/KernelGenerator.cc6
-rw-r--r--tests/nnapi/nnapi_gtest.skip.armv7l-linux1
-rw-r--r--tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon1
-rw-r--r--tests/nnapi/nnapi_gtest.skip.armv7l-linux.cpu1
-rw-r--r--tests/nnapi/nnapi_gtest.skip.armv7l-tizen1
-rw-r--r--tests/nnapi/nnapi_gtest.skip.x86_64-linux1
8 files changed, 8 insertions, 9 deletions
diff --git a/runtime/neurun/backend/acl_cl/KernelGenerator.cc b/runtime/neurun/backend/acl_cl/KernelGenerator.cc
index 0fef47a4b..bffb60b61 100644
--- a/runtime/neurun/backend/acl_cl/KernelGenerator.cc
+++ b/runtime/neurun/backend/acl_cl/KernelGenerator.cc
@@ -1775,7 +1775,8 @@ void KernelGenerator::visit(const ir::operation::Gather &node)
const auto ifm_shape = _ctx.at(ifm_index).shape();
const auto ifm_rank = node.param().rank;
- const auto axis_value = node.param().axis;
+ const auto axis_raw = node.param().axis;
+ const auto axis_value = (axis_raw < 0 ? (ifm_rank + axis_raw) : axis_raw);
const int axis = ::neurun::backend::acl_common::ToARMComputeAxis(ifm_rank, axis_value).value();
auto ofm_alloc = _tensor_builder->at(ofm_index).get();
diff --git a/runtime/neurun/backend/acl_neon/KernelGenerator.cc b/runtime/neurun/backend/acl_neon/KernelGenerator.cc
index 86ca20184..85c6a0633 100644
--- a/runtime/neurun/backend/acl_neon/KernelGenerator.cc
+++ b/runtime/neurun/backend/acl_neon/KernelGenerator.cc
@@ -718,7 +718,8 @@ void KernelGenerator::visit(const ir::operation::Gather &node)
const auto ifm_shape = _ctx.at(ifm_index).shape();
const auto ifm_rank = node.param().rank;
- const auto axis_value = node.param().axis;
+ const auto axis_raw = node.param().axis;
+ const auto axis_value = (axis_raw < 0 ? (ifm_rank + axis_raw) : axis_raw);
// Converting in reverse order
const int axis = ::neurun::backend::acl_common::ToARMComputeAxis(ifm_rank, axis_value).value();
diff --git a/runtime/neurun/backend/cpu/KernelGenerator.cc b/runtime/neurun/backend/cpu/KernelGenerator.cc
index 57a4a7ea8..09bd1367d 100644
--- a/runtime/neurun/backend/cpu/KernelGenerator.cc
+++ b/runtime/neurun/backend/cpu/KernelGenerator.cc
@@ -414,11 +414,13 @@ void KernelGenerator::visit(const ir::operation::Gather &node)
UNUSED_RELEASE(input_shape);
assert(input_shape.rank() < 4 || _current_subg_layout == backend_layout);
+ const auto axis_raw = node.param().axis;
+ const auto axis_value = (axis_raw < 0 ? (input_shape.rank() + axis_raw) : axis_raw);
+
auto fn = nnfw::cpp14::make_unique<::neurun::backend::cpu::kernel::GatherLayer>();
fn->configure(input_alloc->buffer(), input_backend_descr, indices_alloc->buffer(),
- indices_backend_descr, output_alloc->buffer(), output_backend_descr,
- node.param().axis);
+ indices_backend_descr, output_alloc->buffer(), output_backend_descr, axis_value);
_execution_builder->append(std::move(fn));
}
diff --git a/tests/nnapi/nnapi_gtest.skip.armv7l-linux b/tests/nnapi/nnapi_gtest.skip.armv7l-linux
index d6abb3f55..b32bce781 100644
--- a/tests/nnapi/nnapi_gtest.skip.armv7l-linux
+++ b/tests/nnapi/nnapi_gtest.skip.armv7l-linux
@@ -3,7 +3,6 @@
#
# Not support operations
GeneratedTests.cast_*overflow*
-GeneratedTests.gather*_8
GeneratedTests.lsh_projection*
GeneratedTests.mobilenet*
GeneratedTests.svdf*
diff --git a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon
index c6c640560..2a8a9037f 100644
--- a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon
+++ b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon
@@ -3,7 +3,6 @@
#
# Not support operations
GeneratedTests.cast_*overflow*
-GeneratedTests.gather*_8
GeneratedTests.lsh_projection*
GeneratedTests.mobilenet*
GeneratedTests.svdf*
diff --git a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.cpu b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.cpu
index 88e7546f8..94626a64e 100644
--- a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.cpu
+++ b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.cpu
@@ -14,7 +14,6 @@ GeneratedTests.equal_ex*
GeneratedTests.exp_ex*
GeneratedTests.floor_
GeneratedTests.fully_connected_hybrid*
-GeneratedTests.gather*_8
GeneratedTests.greater_equal_ex*
GeneratedTests.hashtable_lookup*
GeneratedTests.l2_normalization*
diff --git a/tests/nnapi/nnapi_gtest.skip.armv7l-tizen b/tests/nnapi/nnapi_gtest.skip.armv7l-tizen
index 80b505e5e..05b48fd34 100644
--- a/tests/nnapi/nnapi_gtest.skip.armv7l-tizen
+++ b/tests/nnapi/nnapi_gtest.skip.armv7l-tizen
@@ -3,7 +3,6 @@
#
# Not support operations
GeneratedTests.cast_*overflow*
-GeneratedTests.gather*_8
GeneratedTests.lsh_projection*
GeneratedTests.mobilenet*
GeneratedTests.svdf*
diff --git a/tests/nnapi/nnapi_gtest.skip.x86_64-linux b/tests/nnapi/nnapi_gtest.skip.x86_64-linux
index 919a0606c..925aeb23f 100644
--- a/tests/nnapi/nnapi_gtest.skip.x86_64-linux
+++ b/tests/nnapi/nnapi_gtest.skip.x86_64-linux
@@ -14,7 +14,6 @@ GeneratedTests.equal_ex*
GeneratedTests.exp_ex*
GeneratedTests.floor_
GeneratedTests.fully_connected_hybrid*
-GeneratedTests.gather*_8
GeneratedTests.greater_equal_ex*
GeneratedTests.hashtable_lookup*
GeneratedTests.l2_normalization*