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

Function transpose

tests/validation/reference/Transpose.cpp:39–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37{
38template <typename T>
39SimpleTensor<T> transpose(const SimpleTensor<T> &src)
40{
41 // Make rows the columns of the original shape
42 TensorShape dst_shape{src.shape().y(), src.shape().x()};
43
44 // Create reference
45 SimpleTensor<T> dst{dst_shape, src.data_type()};
46
47 // Compute reference
48 const uint32_t num_elements = src.num_elements();
49 for (uint32_t i = 0; i < num_elements; ++i)
50 {
51 const Coordinates coord = index2coord(src.shape(), i);
52 const Coordinates dst_coord{coord.y(), coord.x()};
53 const size_t dst_index = coord2index(dst.shape(), dst_coord);
54
55 dst[dst_index] = src[i];
56 }
57
58 return dst;
59}
60
61template SimpleTensor<uint8_t> transpose(const SimpleTensor<uint8_t> &src);
62template SimpleTensor<uint16_t> transpose(const SimpleTensor<uint16_t> &src);

Callers

nothing calls this directly

Calls 7

index2coordFunction · 0.85
coord2indexFunction · 0.85
yMethod · 0.45
shapeMethod · 0.45
xMethod · 0.45
data_typeMethod · 0.45
num_elementsMethod · 0.45

Tested by

no test coverage detected