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

Method run_permute

src/core/CPP/kernels/CPPPermuteKernel.cpp:69–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68template <typename T>
69void CPPPermuteKernel::run_permute(const Window &window)
70{
71 // Permute strides
72 Strides strides = _output->info()->strides_in_bytes();
73 Strides perm_strides = strides;
74 permute_strides(perm_strides, _perm);
75
76 // Create output window
77 Window window_out(window);
78 const Window::Dimension zero_window = Window::Dimension(0, 0, 0);
79 for (size_t d = 0; d <= _perm.num_dimensions(); ++d)
80 {
81 window_out.set(d, zero_window);
82 }
83
84 // Create iterators
85 Iterator in(_input, window);
86 Iterator out(_output, window_out);
87
88 if (_input->info()->num_dimensions() <= 3)
89 {
90 execute_window_loop(
91 window,
92 [&](const Coordinates &id)
93 {
94 const int idx = id[0] * perm_strides[0] + id[1] * perm_strides[1] + id[2] * perm_strides[2];
95 *(reinterpret_cast<T *>(out.ptr() + idx)) = *(reinterpret_cast<const T *>(in.ptr()));
96 },
97 in, out);
98 }
99 else if (_input->info()->num_dimensions() >= 4)
100 {
101 execute_window_loop(
102 window,
103 [&](const Coordinates &id)
104 {
105 const int idx = id[0] * perm_strides[0] + id[1] * perm_strides[1] + id[2] * perm_strides[2] +
106 id[3] * perm_strides[3];
107 *(reinterpret_cast<T *>(out.ptr() + idx)) = *(reinterpret_cast<const T *>(in.ptr()));
108 },
109 in, out);
110 }
111}
112
113CPPPermuteKernel::CPPPermuteKernel() : _func(), _input(nullptr), _output(nullptr), _perm()
114{

Callers

nothing calls this directly

Calls 6

permute_stridesFunction · 0.85
DimensionClass · 0.50
infoMethod · 0.45
num_dimensionsMethod · 0.45
setMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected