diff options
author | Moritz Pflanzer <moritz.pflanzer@arm.com> | 2017-09-24 12:09:41 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | 6c6597c1e17c32c6ad861780eee454a7deecfb75 (patch) | |
tree | 5df015557262a83e5e84a5fa365544bb1aa66762 /tests/validation/CPP/Utils.h | |
parent | c26ecf8ca13205cab2ce43d9f971e1569808e5bc (diff) | |
download | ComputeLibrary-6c6597c1e17c32c6ad861780eee454a7deecfb75.tar.gz |
COMPMID-500: Move HarrisCorners to new validation
Change-Id: I4e21ad98d029e360010c5927f04b716527700a00
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/88888
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'tests/validation/CPP/Utils.h')
-rw-r--r-- | tests/validation/CPP/Utils.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/validation/CPP/Utils.h b/tests/validation/CPP/Utils.h index 2d879c129b..91d1afe1d7 100644 --- a/tests/validation/CPP/Utils.h +++ b/tests/validation/CPP/Utils.h @@ -41,8 +41,31 @@ namespace test { namespace validation { +// Return a tensor element at a specified coordinate with different border modes template <typename T> -T tensor_elem_at(const SimpleTensor<T> &in, Coordinates coord, BorderMode border_mode, T constant_border_value); +T tensor_elem_at(const SimpleTensor<T> &src, Coordinates coord, BorderMode border_mode, T constant_border_value) +{ + const int x = coord.x(); + const int y = coord.y(); + const int width = src.shape().x(); + const int height = src.shape().y(); + + // If coordinates beyond range of tensor's width or height + if(x < 0 || y < 0 || x >= width || y >= height) + { + if(border_mode == BorderMode::REPLICATE) + { + coord.set(0, std::max(0, std::min(x, width - 1))); + coord.set(1, std::max(0, std::min(y, height - 1))); + } + else + { + return constant_border_value; + } + } + + return src[coord2index(src.shape(), coord)]; +} template <typename T> T bilinear_policy(const SimpleTensor<T> &in, Coordinates id, float xn, float yn, BorderMode border_mode, T constant_border_value); |