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);
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) {
119 if (!output_operand->
data) {
126 for (
int n = 0; n < number; n++) {
129 const float *
src =
input + n * hwc_stride +
h * wc_stride +
w * c_stride;
130 float *dst =
output + (n + params->
paddings[0][0]) * new_hwc_stride
131 + (
h + params->
paddings[1][0]) * new_wc_stride
132 + (
w + params->
paddings[2][0]) * new_c_stride
140 before_paddings = params->
paddings[0][0];
141 after_paddings = params->
paddings[0][1];
142 for (
int n = 0; n < before_paddings; n++) {
143 float *dst =
output + n * new_hwc_stride;
145 for (
int i = 0;
i < new_hwc_stride;
i++) {
151 float *
src =
output + buddy * new_hwc_stride;
152 memcpy(dst,
src, new_hwc_stride *
sizeof(
float));
155 for (
int n = 0; n < after_paddings; n++) {
156 int given = number + before_paddings + n;
157 float *dst =
output + given * new_hwc_stride;
159 for (
int i = 0;
i < new_hwc_stride;
i++) {
164 float *
src =
output + buddy * new_hwc_stride;
165 memcpy(dst,
src, new_hwc_stride *
sizeof(
float));
170 before_paddings = params->
paddings[1][0];
171 after_paddings = params->
paddings[1][1];
172 for (
int n = 0; n < new_number; n++) {
173 float *start =
output + n * new_hwc_stride;
174 for (
int h = 0;
h < before_paddings;
h++) {
175 float *dst = start +
h * new_wc_stride;
177 for (
int i = 0;
i < new_wc_stride;
i++) {
182 float *
src = start + buddy * new_wc_stride;
183 memcpy(dst,
src, new_wc_stride *
sizeof(
float));
186 for (
int h = 0;
h < after_paddings;
h++) {
187 int given =
height + before_paddings +
h;
188 float *dst = start + given * new_wc_stride;
190 for (
int i = 0;
i < new_wc_stride;
i++) {
195 float *
src = start + buddy * new_wc_stride;
196 memcpy(dst,
src, new_wc_stride *
sizeof(
float));
202 before_paddings = params->
paddings[2][0];
203 after_paddings = params->
paddings[2][1];
204 for (
int n = 0; n < new_number; n++) {
205 for (
int h = 0;
h < new_height;
h++) {
206 float *start =
output + n * new_hwc_stride +
h * new_wc_stride;
207 for (
int w = 0;
w < before_paddings;
w++) {
208 float *dst = start +
w * new_c_stride;
210 for (
int i = 0;
i < new_c_stride;
i++) {
215 float *
src = start + buddy * new_c_stride;
216 memcpy(dst,
src, new_c_stride *
sizeof(
float));
219 for (
int w = 0;
w < after_paddings;
w++) {
220 int given =
width + before_paddings +
w;
221 float *dst = start + given * new_c_stride;
223 for (
int i = 0;
i < new_c_stride;
i++) {
228 float *
src = start + buddy * new_c_stride;
229 memcpy(dst,
src, new_c_stride *
sizeof(
float));
236 before_paddings = params->
paddings[3][0];
237 after_paddings = params->
paddings[3][1];
238 for (
int n = 0; n < new_number; n++) {
239 for (
int h = 0;
h < new_height;
h++) {
240 for (
int w = 0;
w < new_width;
w++) {
241 float *start =
output + n * new_hwc_stride +
h * new_wc_stride +
w * new_c_stride;
242 for (
int c = 0;
c < before_paddings;
c++) {
243 float *dst = start +
c;
248 float *
src = start + buddy;
252 for (
int c = 0;
c < after_paddings;
c++) {
253 int given =
channel + before_paddings +
c;
254 float *dst = start + given;
259 float *
src = start + buddy;