40 SimpleTensor<T> widthconcatenate_layer(
const std::vector<SimpleTensor<T>> &srcs, SimpleTensor<T> &
dst)
43 std::vector<TensorShape> shapes;
44 shapes.reserve(srcs.size());
45 for(
const auto &
src : srcs)
47 shapes.emplace_back(
src.shape());
51 const int width_out =
dst.shape().x();
53 std::fill_n(
dst.data(),
dst.num_elements(), 0);
54 for(
const auto &
src : srcs)
58 const int width =
src.shape().x();
59 const int height =
src.shape().y();
60 const int depth =
src.shape().z();
61 const int upper_dims =
src.shape().total_size() / (width * height * depth);
63 const T *src_ptr =
src.data();
64 T *dst_ptr =
dst.data();
66 for(
int u = 0; u < upper_dims; ++u)
68 for(
int d = 0; d < depth; ++d)
70 for(
int r = 0; r < height; ++r)
72 const int offset = u * height * depth + d * height + r;
75 const UniformQuantizationInfo iq_info =
src.quantization_info().uniform();
76 const UniformQuantizationInfo oq_info =
dst.quantization_info().uniform();
80 std::transform(src_ptr, src_ptr + width, dst_ptr + width_offset +
offset * width_out, [&](T
t)
88 std::transform(src_ptr, src_ptr + width, dst_ptr + width_offset +
offset * width_out, [&](T
t)
98 std::copy(src_ptr, src_ptr + width, dst_ptr + width_offset +
offset * width_out);
104 width_offset += width;
109 template SimpleTensor<float> widthconcatenate_layer(
const std::vector<SimpleTensor<float>> &srcs, SimpleTensor<float> &
dst);
110 template SimpleTensor<half> widthconcatenate_layer(
const std::vector<SimpleTensor<half>> &srcs, SimpleTensor<half> &
dst);
111 template SimpleTensor<uint8_t> widthconcatenate_layer(
const std::vector<SimpleTensor<uint8_t>> &srcs, SimpleTensor<uint8_t> &
dst);
112 template SimpleTensor<int8_t> widthconcatenate_layer(
const std::vector<SimpleTensor<int8_t>> &srcs, SimpleTensor<int8_t> &
dst);
115 template <
typename T>
122 return widthconcatenate_layer(srcs,
dst);