diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2017-07-05 17:02:25 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:15:39 +0100 |
commit | ac4e873dad6aa6291fc36aff62047a896db04f6a (patch) | |
tree | 2c5397c6c04b97cedb88ff809f5d40cbe7dc79c9 /tests/validation/TensorOperations.h | |
parent | df24618b53cffed1c574e11e9fd4ba7740f8c009 (diff) | |
download | ComputeLibrary-ac4e873dad6aa6291fc36aff62047a896db04f6a.tar.gz |
COMPMID-417: Port DepthConcatenate to QS8/QS16 for NEON/CL.
Change-Id: I3dddae63043c7aa18d908a4fc8abacf3c64f98ca
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/80081
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Steven Niu <steven.niu@arm.com>
Diffstat (limited to 'tests/validation/TensorOperations.h')
-rw-r--r-- | tests/validation/TensorOperations.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/validation/TensorOperations.h b/tests/validation/TensorOperations.h index adac70901d..bf9bceff0a 100644 --- a/tests/validation/TensorOperations.h +++ b/tests/validation/TensorOperations.h @@ -41,6 +41,7 @@ #include <array> #include <cmath> #include <random> +#include <string> #include <vector> namespace arm_compute @@ -1003,6 +1004,53 @@ void batch_normalization_layer(const Tensor<T> &in, Tensor<T> &out, const Tensor } } +// Depth Concatenate layer +template <typename T> +void depth_concatenate_layer(const std::vector<const Tensor<T> *> &srcs, Tensor<T> &out) +{ + unsigned depth_offset = 0; + const int width_out = out.shape().x(); + const int height_out = out.shape().y(); + const int depth_out = out.shape().z(); + const int out_stride_z = width_out * height_out; + const int batches = out.shape().total_size_upper(3); + + // Set output tensor to 0 + memset(out.data(), 0, out.num_elements() * element_size_from_data_type(out.data_type())); + + for(unsigned int i = 0; i < srcs.size(); ++i) + { + ARM_COMPUTE_ERROR_ON(srcs[i] == nullptr); + ARM_COMPUTE_ERROR_ON(srcs[i]->data_type() != out.data_type()); + ARM_COMPUTE_ERROR_ON(depth_offset >= out.shape().z()); + ARM_COMPUTE_ERROR_ON(batches != static_cast<int>(srcs[i]->shape().total_size_upper(3))); + + const Tensor<T> *src = srcs[i]; + const int width = src->shape().x(); + const int height = src->shape().y(); + const int depth = src->shape().z(); + const unsigned int x_diff = (width_out - width) / 2; + const unsigned int y_diff = (height_out - height) / 2; + + const T *src_ptr = src->data(); + for(int b = 0; b < batches; ++b) + { + const unsigned int offset_to_first_element = b * out_stride_z * depth_out + depth_offset * out_stride_z + + y_diff * width_out + x_diff; + for(int d = 0; d < depth; ++d) + { + for(int r = 0; r < height; ++r) + { + std::copy(src_ptr, src_ptr + width, out.data() + offset_to_first_element + d * out_stride_z + r * width_out); + src_ptr += width; + } + } + } + + depth_offset += depth; + } +} + // Convolution layer template <typename T> void convolution_layer(const Tensor<T> &in, const Tensor<T> &weights, const Tensor<T> &bias, Tensor<T> &out, const PadStrideInfo &conv_info) |