diff options
Diffstat (limited to 'tests/validation/reference/Gather.cpp')
-rw-r--r-- | tests/validation/reference/Gather.cpp | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/tests/validation/reference/Gather.cpp b/tests/validation/reference/Gather.cpp index 93ac09cf95..02292fb74e 100644 --- a/tests/validation/reference/Gather.cpp +++ b/tests/validation/reference/Gather.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 Arm Limited. + * Copyright (c) 2018-2019, 2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -45,22 +45,39 @@ SimpleTensor<T> gather(const SimpleTensor<T> &src, const SimpleTensor<uint32_t> Window win; win.use_tensor_dimensions(dst_shape); - execute_window_loop(win, [&](const Coordinates & id) + if(indices.shape().num_dimensions() == 1u) { - Coordinates offset; - for(unsigned int dim = 0; dim < id.num_dimensions(); ++dim) + execute_window_loop(win, [&](const Coordinates & id) { - if(dim == actual_axis) + Coordinates offset; + for(unsigned int dim = 0; dim < id.num_dimensions(); ++dim) { - offset.set(dim, indices_ptr[id[dim]]); + if(dim == actual_axis) + { + offset.set(dim, indices_ptr[id[dim]]); + } + else + { + offset.set(dim, id[dim]); + } } - else + *reinterpret_cast<T *>(dst(id)) = *reinterpret_cast<const T *>(src(offset)); + }); + } + else + { + if(actual_axis == 0) + { + win.set(Window::DimX, Window::Dimension(0, 1, 1)); + uint32_t index = 0; + execute_window_loop(win, [&](const Coordinates & id) { - offset.set(dim, id[dim]); - } + auto *dst_ptr = reinterpret_cast<T *>(dst(id)); + const int row_to_copy = indices[index++]; + std::copy_n(src.data() + row_to_copy * src.shape()[0], src.shape()[0], dst_ptr); + }); } - *reinterpret_cast<T *>(dst(id)) = *reinterpret_cast<const T *>(src(offset)); - }); + } return dst; } @@ -72,4 +89,4 @@ template SimpleTensor<uint8_t> gather(const SimpleTensor<uint8_t> &src, const Si } // namespace reference } // namespace validation } // namespace test -} // namespace arm_compute
\ No newline at end of file +} // namespace arm_compute |