1 // Copyright 2021 Google LLC
2 //
3 // This source code is licensed under the BSD-style license found in the
4 // LICENSE file in the root directory of this source tree.
5
6 #include <assert.h>
7 #include <string.h>
8
9 #include <xnnpack/common.h>
10 #include <xnnpack/math.h>
11 #include <xnnpack/transpose.h>
12
xnn_xx_transposev_ukernel__1x1_memcpy(const void * input,void * output,size_t input_row_stride,size_t output_row_stride,size_t input_element_stride,size_t output_element_stride,size_t element_size,size_t block_width,size_t block_height)13 void xnn_xx_transposev_ukernel__1x1_memcpy(
14 const void* input,
15 void* output,
16 size_t input_row_stride,
17 size_t output_row_stride,
18 size_t input_element_stride,
19 size_t output_element_stride,
20 size_t element_size,
21 size_t block_width,
22 size_t block_height)
23 {
24 const size_t input_reset = input_element_stride - block_height * input_row_stride;
25 const size_t output_reset = output_row_stride - block_height * output_element_stride;
26
27 const void* i = (const void*) input;
28 void* o = (void*) output;
29
30 do {
31 size_t bh = block_height;
32 for (; bh >= 1; bh -= 1) {
33 memcpy(o, i, element_size);
34 i = (const void*) ((uintptr_t) i + input_row_stride);
35 o = (void*) ((uintptr_t) o + output_element_stride);
36 }
37
38 i = (const void*) ((uintptr_t) i + input_reset);
39 o = (void*) ((uintptr_t) o + output_reset);
40 block_width -= 1;
41 } while (block_width != 0);
42 }
43