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

Method run

src/core/NEON/kernels/NEReorgLayerKernel.cpp:115–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115void NEReorgLayerKernel::run(const Window &window, const ThreadInfo &info)
116{
117 ARM_COMPUTE_UNUSED(info);
118 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
119 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICPPKernel::window(), window);
120
121 const DataLayout data_layout = _input->info()->data_layout();
122 const size_t idx_w = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
123 const size_t idx_h = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
124 const size_t idx_c = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
125
126 const unsigned int stride = _stride;
127 const unsigned int out_c = _output->info()->tensor_shape()[idx_c] / (stride * stride);
128 const uint8_t *in_ptr = _input->buffer();
129
130 // Collapse
131 Window collapsed_window = window.collapse_if_possible(window, 4);
132
133 // Create Iterator
134 Iterator out(_output, collapsed_window);
135
136 // Perform reorg
137 execute_window_loop(
138 collapsed_window,
139 [&](const Coordinates &id)
140 {
141 // Get spatial coords and channels
142 const unsigned int w = id[idx_w];
143 const unsigned int h = id[idx_h];
144 const unsigned int c = id[idx_c];
145
146 // Calculate mapping
147 const unsigned int offset = c / out_c;
148 Coordinates map_coords = id;
149 map_coords.set(idx_w, w * stride + offset % stride);
150 map_coords.set(idx_h, h * stride + offset / stride);
151 map_coords.set(idx_c, c % out_c);
152
153 // Perform mapping
154 std::memcpy(out.ptr(), in_ptr + _input->info()->offset_element_in_bytes(map_coords),
155 _input->info()->element_size());
156 },
157 out);
158}
159} // namespace arm_compute

Callers

nothing calls this directly

Calls 8

collapse_if_possibleMethod · 0.80
data_layoutMethod · 0.45
infoMethod · 0.45
bufferMethod · 0.45
setMethod · 0.45
ptrMethod · 0.45
element_sizeMethod · 0.45

Tested by

no test coverage detected