MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / col2im

Function col2im

tests/validation/reference/Col2Im.cpp:38–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36{
37template <typename T>
38SimpleTensor<T> col2im(const SimpleTensor<T> &src, const TensorShape &dst_shape, unsigned int num_groups)
39{
40 SimpleTensor<T> dst{dst_shape, src.data_type(), 1};
41
42 // Compute reference
43 const size_t batches = dst_shape.total_size() / (dst_shape.x() * dst_shape.y() * dst_shape.z());
44 const size_t src_width = src.shape().x();
45 const size_t src_height = src.shape().y();
46
47 if (num_groups == 1)
48 {
49 // Batches are on the 3rd dimension of the input tensor
50#if defined(_OPENMP)
51#pragma omp parallel for collapse(3)
52#endif /* _OPENMP */
53 for (size_t b = 0; b < batches; ++b)
54 {
55 for (size_t x = 0; x < src_width; ++x)
56 {
57 for (size_t y = 0; y < src_height; ++y)
58 {
59 const int dst_idx = y + x * src_height + b * src_height * src_width;
60 dst[dst_idx] = src[coord2index(src.shape(), Coordinates(x, y, b))];
61 }
62 }
63 }
64 }
65 else
66 {
67#if defined(_OPENMP)
68#pragma omp parallel for collapse(4)
69#endif /* _OPENMP */
70 for (size_t b = 0; b < batches; ++b)
71 {
72 for (size_t g = 0; g < num_groups; ++g)
73 {
74 for (size_t x = 0; x < src_width; ++x)
75 {
76 for (size_t y = 0; y < src_height; ++y)
77 {
78 const int dst_idx =
79 y + x * src_height + g * src_height * src_width + b * src_height * src_width * num_groups;
80 dst[dst_idx] = src[coord2index(src.shape(), Coordinates(x, y, g, b))];
81 }
82 }
83 }
84 }
85 }
86 return dst;
87}
88
89template SimpleTensor<float>
90col2im(const SimpleTensor<float> &src, const TensorShape &dst_shape, unsigned int num_groups);

Callers

nothing calls this directly

Calls 8

coord2indexFunction · 0.85
CoordinatesClass · 0.50
data_typeMethod · 0.45
total_sizeMethod · 0.45
xMethod · 0.45
yMethod · 0.45
zMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected