49 float input[1*4*4*3] = {
50 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
52 float expected_output[1*9*9*3] = {
53 18.0, 19.0, 20.0, 15.0, 16.0, 17.0, 12.0, 13.0, 14.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 21.0, 22.0, 23.0, 18.0, 19.0, 20.0, 6.0, 7.0, 8.0, 3.0,
54 4.0, 5.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 9.0, 10.0, 11.0, 6.0, 7.0, 8.0, 6.0, 7.0, 8.0, 3.0, 4.0, 5.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 3.0,
55 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 9.0, 10.0, 11.0, 6.0, 7.0, 8.0, 18.0, 19.0, 20.0, 15.0, 16.0, 17.0, 12.0, 13.0, 14.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0,
56 21.0, 22.0, 23.0, 21.0, 22.0, 23.0, 18.0, 19.0, 20.0, 30.0, 31.0, 32.0, 27.0, 28.0, 29.0, 24.0, 25.0, 26.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 33.0,
57 34.0, 35.0, 30.0, 31.0, 32.0, 42.0, 43.0, 44.0, 39.0, 40.0, 41.0, 36.0, 37.0, 38.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 45.0, 46.0, 47.0, 42.0, 43.0,
58 44.0, 42.0, 43.0, 44.0, 39.0, 40.0, 41.0, 36.0, 37.0, 38.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 45.0, 46.0, 47.0, 42.0, 43.0, 44.0, 30.0, 31.0, 32.0,
59 27.0, 28.0, 29.0, 24.0, 25.0, 26.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 33.0, 34.0, 35.0, 30.0, 31.0, 32.0, 18.0, 19.0, 20.0, 15.0, 16.0, 17.0, 12.0,
60 13.0, 14.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 21.0, 22.0, 23.0, 18.0, 19.0, 20.0
74 operands[0].
data = input;
75 operands[0].
dims[0] = 1;
76 operands[0].
dims[1] = 4;
77 operands[0].
dims[2] = 4;
78 operands[0].
dims[3] = 3;
84 output = operands[1].
data;
85 for (
int i = 0;
i <
sizeof(expected_output) /
sizeof(
float);
i++) {
86 if (fabs(output[
i] - expected_output[
i]) >
EPSON) {
87 printf(
"at index %d, output: %f, expected_output: %f\n", i, output[i], expected_output[i]);
119 float input[3*2*2*3] = {
120 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35
122 float expected_output[6*2*2*3] = {
123 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0,
124 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0,
125 35.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0
139 operands[0].
data = input;
140 operands[0].
dims[0] = 3;
141 operands[0].
dims[1] = 2;
142 operands[0].
dims[2] = 2;
143 operands[0].
dims[3] = 3;
146 input_indexes[0] = 0;
149 output = operands[1].
data;
150 for (
int i = 0;
i <
sizeof(expected_output) /
sizeof(
float);
i++) {
151 if (fabs(output[
i] - expected_output[
i]) >
EPSON) {
152 printf(
"at index %d, output: %f, expected_output: %f\n", i, output[i], expected_output[i]);
184 float input[1*2*2*3] = {
185 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
187 float expected_output[1*3*2*6] = {
188 728.0, 728.0, 728.0, 728.0, 728.0, 728.0, 728.0, 728.0, 728.0, 728.0, 728.0,
189 728.0, 728.0, 0.0, 1.0, 2.0, 728.0, 728.0, 728.0, 3.0, 4.0, 5.0, 728.0, 728.0,
190 728.0, 6.0, 7.0, 8.0, 728.0, 728.0, 728.0, 9.0, 10.0, 11.0, 728.0, 728.0
205 operands[0].
data = input;
206 operands[0].
dims[0] = 1;
207 operands[0].
dims[1] = 2;
208 operands[0].
dims[2] = 2;
209 operands[0].
dims[3] = 3;
212 input_indexes[0] = 0;
215 output = operands[1].
data;
216 for (
int i = 0;
i <
sizeof(expected_output) /
sizeof(
float);
i++) {
217 if (fabs(output[
i] - expected_output[
i]) >
EPSON) {
218 printf(
"at index %d, output: %f, expected_output: %f\n", i, output[i], expected_output[i]);
229 int main(
int argc,
char **argv)
static int test_with_mode_reflect(void)
static int test_with_mode_symmetric(void)
static int test_with_mode_constant(void)
int main(int argc, char **argv)
#define i(width, name, range_min, range_max)
void * data
data pointer with data length in bytes.
int32_t dims[4]
there are two memory layouts, NHWC or NCHW, so we use dims, dims[0] is Number.
int dnn_execute_layer_pad(DnnOperand *operands, const int32_t *input_operand_indexes, int32_t output_operand_index, const void *parameters)
layer pad (equivalent to tf.pad) for native backend.