40 std::vector<TensorShape> shapes;
41 shapes.reserve(srcs.size());
42 for(
const auto &
src : srcs)
44 shapes.emplace_back(
src.shape());
49 const int width_out =
dst.shape().x();
50 const int height_out =
dst.shape().y();
51 const int depth_out =
dst.shape().z();
52 const int out_stride_z = width_out * height_out;
53 const int batches =
dst.shape().total_size_upper(3);
54 auto have_different_quantization_info = [&](
const SimpleTensor<T> &tensor)
56 return tensor.quantization_info() !=
dst.quantization_info();
62 #pragma omp parallel for 69 for(
const auto &
src : srcs)
72 const auto num_elems_in_slice((
dst.num_elements() / depth_out) *
src.shape().z());
76 std::transform(ptr_slice, ptr_slice + num_elems_in_slice, ptr_slice, [&](T)
86 std::fill_n(
dst.data(),
dst.num_elements(), 0);
89 for(
const auto &
src : srcs)
94 const int width =
src.shape().x();
95 const int height =
src.shape().y();
96 const int depth =
src.shape().z();
97 const int x_diff = (width_out - width) / 2;
98 const int y_diff = (height_out - height) / 2;
100 const T *src_ptr =
src.data();
104 const size_t offset_to_first_element =
b * out_stride_z * depth_out + depth_offset * out_stride_z + y_diff * width_out + x_diff;
106 for(
int d = 0; d < depth; ++d)
108 for(
int r = 0; r < height; ++r)
114 std::transform(src_ptr, src_ptr + width,
dst.data() + offset_to_first_element + d * out_stride_z + r * width_out, [&](T
t)
123 std::copy(src_ptr, src_ptr + width,
dst.data() + offset_to_first_element + d * out_stride_z + r * width_out);
130 depth_offset += depth;
float dequantize_qasymm8(uint8_t value, const INFO_TYPE &qinfo)
Dequantize a value given an unsigned 8-bit asymmetric quantization scheme.
uint8_t quantize_qasymm8(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given an unsigned 8-bit asymmetric quantization scheme.
SimpleTensor< T > depthconcatenate_layer(const std::vector< SimpleTensor< T >> &srcs, SimpleTensor< T > &dst)
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
SimpleTensor< T > copy(const SimpleTensor< T > &src, const TensorShape &output_shape)
SimpleTensor< float > src
Copyright (c) 2017-2021 Arm Limited.
quantized, asymmetric fixed-point 8-bit number unsigned
Simple tensor object that stores elements in a consecutive chunk of memory.
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)