diff options
author | Moritz Pflanzer <moritz.pflanzer@arm.com> | 2017-09-08 09:53:14 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | cde1e8adeacea5c33a1682ef7b05a0ef643463b8 (patch) | |
tree | 47e58abdf5bb6ef39db362a2ac777c93b3f76666 /tests/validation/CPP/Utils.cpp | |
parent | 86b53339679e12c952a24a8845a5409ac3d52de6 (diff) | |
download | ComputeLibrary-cde1e8adeacea5c33a1682ef7b05a0ef643463b8.tar.gz |
COMPMID-415: Add tests for ConvolutionLayer reshaped weights
Change-Id: I6c1209a2afafccba2cbdbcda16aceb3ae0cc7b4b
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/87000
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Diffstat (limited to 'tests/validation/CPP/Utils.cpp')
-rw-r--r-- | tests/validation/CPP/Utils.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/validation/CPP/Utils.cpp b/tests/validation/CPP/Utils.cpp index 03d4eb7405..15e9fc3138 100644 --- a/tests/validation/CPP/Utils.cpp +++ b/tests/validation/CPP/Utils.cpp @@ -125,6 +125,34 @@ template void apply_2d_spatial_filter(Coordinates coord, const SimpleTensor<uint BorderMode border_mode, uint8_t constant_border_value); +RawTensor transpose(const RawTensor &src, int chunk_width) +{ + // Create reference + TensorShape dst_shape(src.shape()); + dst_shape.set(0, src.shape().y() * chunk_width); + dst_shape.set(1, std::ceil(src.shape().x() / static_cast<float>(chunk_width))); + + RawTensor dst{ dst_shape, src.data_type() }; + + // Compute reference + uint8_t *out_ptr = dst.data(); + + for(int i = 0; i < dst.num_elements(); i += chunk_width) + { + Coordinates coord = index2coord(dst.shape(), i); + size_t coord_x = coord.x(); + coord.set(0, coord.y() * chunk_width); + coord.set(1, coord_x / chunk_width); + + const int num_elements = std::min<int>(chunk_width, src.shape().x() - coord.x()); + + std::copy_n(static_cast<const uint8_t *>(src(coord)), num_elements * src.element_size(), out_ptr); + + out_ptr += chunk_width * dst.element_size(); + } + + return dst; +} } // namespace validation } // namespace test } // namespace arm_compute |