35 for (
int i = 0;
i < 4; ++
i) {
55 return (2 * paddings - 1 - given);
57 return (2 * paddings - given);
67 int offset = given - border;
68 return (border - 1 -
offset);
70 int offset = given - border;
71 return (border - 2 -
offset);
79 int32_t output_operand_index,
const void *parameters)
87 int32_t input_operand_index = input_operand_indexes[0];
88 int number = operands[input_operand_index].
dims[0];
89 int height = operands[input_operand_index].
dims[1];
90 int width = operands[input_operand_index].
dims[2];
91 int channel = operands[input_operand_index].
dims[3];
92 const float *
input = operands[input_operand_index].
data;
100 int wc_stride = c_stride *
width;
101 int hwc_stride = wc_stride *
height;
103 int new_c_stride = new_channel;
104 int new_wc_stride = new_c_stride * new_width;
105 int new_hwc_stride = new_wc_stride * new_height;
107 DnnOperand *output_operand = &operands[output_operand_index];
108 output_operand->
dims[0] = new_number;
109 output_operand->
dims[1] = new_height;
110 output_operand->
dims[2] = new_width;
111 output_operand->
dims[3] = new_channel;
114 if (output_operand->
length <= 0)
117 if (!output_operand->
data)
122 for (
int n = 0; n < number; n++) {
125 const float *
src =
input + n * hwc_stride +
h * wc_stride +
w * c_stride;
126 float *dst =
output + (n + params->
paddings[0][0]) * new_hwc_stride
127 + (
h + params->
paddings[1][0]) * new_wc_stride
128 + (
w + params->
paddings[2][0]) * new_c_stride
136 before_paddings = params->
paddings[0][0];
137 after_paddings = params->
paddings[0][1];
138 for (
int n = 0; n < before_paddings; n++) {
139 float *dst =
output + n * new_hwc_stride;
141 for (
int i = 0;
i < new_hwc_stride;
i++) {
147 float *
src =
output + buddy * new_hwc_stride;
148 memcpy(dst,
src, new_hwc_stride *
sizeof(
float));
151 for (
int n = 0; n < after_paddings; n++) {
152 int given = number + before_paddings + n;
153 float *dst =
output + given * new_hwc_stride;
155 for (
int i = 0;
i < new_hwc_stride;
i++) {
160 float *
src =
output + buddy * new_hwc_stride;
161 memcpy(dst,
src, new_hwc_stride *
sizeof(
float));
166 before_paddings = params->
paddings[1][0];
167 after_paddings = params->
paddings[1][1];
168 for (
int n = 0; n < new_number; n++) {
169 float *start =
output + n * new_hwc_stride;
170 for (
int h = 0;
h < before_paddings;
h++) {
171 float *dst = start +
h * new_wc_stride;
173 for (
int i = 0;
i < new_wc_stride;
i++) {
178 float *
src = start + buddy * new_wc_stride;
179 memcpy(dst,
src, new_wc_stride *
sizeof(
float));
182 for (
int h = 0;
h < after_paddings;
h++) {
183 int given =
height + before_paddings +
h;
184 float *dst = start + given * new_wc_stride;
186 for (
int i = 0;
i < new_wc_stride;
i++) {
191 float *
src = start + buddy * new_wc_stride;
192 memcpy(dst,
src, new_wc_stride *
sizeof(
float));
198 before_paddings = params->
paddings[2][0];
199 after_paddings = params->
paddings[2][1];
200 for (
int n = 0; n < new_number; n++) {
201 for (
int h = 0;
h < new_height;
h++) {
202 float *start =
output + n * new_hwc_stride +
h * new_wc_stride;
203 for (
int w = 0;
w < before_paddings;
w++) {
204 float *dst = start +
w * new_c_stride;
206 for (
int i = 0;
i < new_c_stride;
i++) {
211 float *
src = start + buddy * new_c_stride;
212 memcpy(dst,
src, new_c_stride *
sizeof(
float));
215 for (
int w = 0;
w < after_paddings;
w++) {
216 int given =
width + before_paddings +
w;
217 float *dst = start + given * new_c_stride;
219 for (
int i = 0;
i < new_c_stride;
i++) {
224 float *
src = start + buddy * new_c_stride;
225 memcpy(dst,
src, new_c_stride *
sizeof(
float));
232 before_paddings = params->
paddings[3][0];
233 after_paddings = params->
paddings[3][1];
234 for (
int n = 0; n < new_number; n++) {
235 for (
int h = 0;
h < new_height;
h++) {
236 for (
int w = 0;
w < new_width;
w++) {
237 float *start =
output + n * new_hwc_stride +
h * new_wc_stride +
w * new_c_stride;
238 for (
int c = 0;
c < before_paddings;
c++) {
239 float *dst = start +
c;
244 float *
src = start + buddy;
248 for (
int c = 0;
c < after_paddings;
c++) {
249 int given =
channel + before_paddings +
c;
250 float *dst = start + given;
255 float *
src = start + buddy;