17
static int test_convolution(int w, int h, int c, int outch, int kernel, int dilation, int stride, int pad, int bias)
19
ncnn::Mat a = RandomMat(w, h, c);
28
pd.set(6, outch * c * kernel * kernel);
30
int activation_type = RAND() % 7;
31
ncnn::Mat activation_params(2);
32
activation_params[0] = (activation_type == 6) ? RandomFloat(0, 1) : RandomFloat(-1, 0);
33
activation_params[1] = RandomFloat(0, 1);
34
pd.set(9, activation_type);
35
pd.set(10, activation_params);
37
std::vector<ncnn::Mat> weights(bias ? 2 : 1);
38
weights[0] = RandomMat(outch * c * kernel * kernel);
40
weights[1] = RandomMat(outch);
42
float epsilon = 0.001;
44
int ret = test_layer("Convolution", pd, weights, a, epsilon);
47
fprintf(stderr, "test_convolution failed w=%d h=%d c=%d outch=%d kernel=%d dilation=%d stride=%d pad=%d bias=%d act=%d actparams=[%f,%f]\n", w, h, c, outch, kernel, dilation, stride, pad, bias, activation_type, activation_params[0], activation_params[1]);
54
opt.use_packing_layout = true;
55
opt.use_fp16_packed = false;
56
opt.use_fp16_storage = false;
57
opt.use_fp16_arithmetic = false;
58
opt.use_bf16_storage = false;
59
opt.use_shader_pack8 = false;
60
opt.use_image_storage = false;
61
opt.use_sgemm_convolution = false;
62
opt.use_winograd_convolution = false;
64
ret = test_layer_opt("Convolution", pd, weights, opt, a, epsilon);
67
fprintf(stderr, "test_convolution failed w=%d h=%d c=%d outch=%d kernel=%d dilation=%d stride=%d pad=%d bias=%d act=%d actparams=[%f,%f]\n", w, h, c, outch, kernel, dilation, stride, pad, bias, activation_type, activation_params[0], activation_params[1]);
75
opt.use_packing_layout = true;
76
opt.use_fp16_packed = true;
77
opt.use_fp16_storage = true;
78
opt.use_fp16_arithmetic = true;
79
opt.use_bf16_storage = true;
80
opt.use_shader_pack8 = true;
81
opt.use_image_storage = true;
82
opt.use_sgemm_convolution = false;
83
opt.use_winograd_convolution = false;
85
ret = test_layer_opt("Convolution", pd, weights, opt, a, epsilon);
88
fprintf(stderr, "test_convolution failed w=%d h=%d c=%d outch=%d kernel=%d dilation=%d stride=%d pad=%d bias=%d act=%d actparams=[%f,%f]\n", w, h, c, outch, kernel, dilation, stride, pad, bias, activation_type, activation_params[0], activation_params[1]);
97
opt.use_a53_a55_optimized_kernel = true;
99
ret = test_layer_opt("Convolution", pd, weights, opt, a, epsilon);
102
fprintf(stderr, "test_convolution failed w=%d h=%d c=%d outch=%d kernel=%d dilation=%d stride=%d pad=%d bias=%d act=%d actparams=[%f,%f]\n", w, h, c, outch, kernel, dilation, stride, pad, bias, activation_type, activation_params[0], activation_params[1]);
111
static int test_convolution_0()
113
static const int kdsp[16][4] = {
132
for (int i = 12; i < 16; i++)
134
const int k = kdsp[i][0];
135
const int d = kdsp[i][1];
136
const int s = kdsp[i][2];
137
const int p = kdsp[i][3];
140
|| test_convolution(9, 7, 1, 1, k, d, s, p, 1)
141
|| test_convolution(9, 7, 4, 13, k, d, s, p, 0)
142
|| test_convolution(9, 7, 13, 4, k, d, s, p, 1)
143
|| test_convolution(9, 7, 12, 12, k, d, s, p, 0)
144
|| test_convolution(9, 7, 8, 12, k, d, s, p, 1)
145
|| test_convolution(9, 7, 8, 13, k, d, s, p, 0)
146
|| test_convolution(9, 7, 13, 8, k, d, s, p, 1)
147
|| test_convolution(9, 7, 12, 16, k, d, s, p, 0)
148
|| test_convolution(9, 7, 15, 15, k, d, s, p, 0)
149
|| test_convolution(9, 7, 16, 16, k, d, s, p, 0)
150
|| test_convolution(18, 17, 1, 1, k, d, s, p, 1)
151
|| test_convolution(18, 17, 4, 13, k, d, s, p, 0)
152
|| test_convolution(18, 17, 13, 4, k, d, s, p, 1)
153
|| test_convolution(18, 17, 12, 12, k, d, s, p, 0)
154
|| test_convolution(18, 17, 8, 12, k, d, s, p, 1)
155
|| test_convolution(18, 17, 8, 13, k, d, s, p, 0)
156
|| test_convolution(18, 17, 13, 8, k, d, s, p, 1)
157
|| test_convolution(18, 17, 12, 16, k, d, s, p, 0)
158
|| test_convolution(18, 17, 15, 15, k, d, s, p, 0)
159
|| test_convolution(18, 17, 16, 16, k, d, s, p, 0)
160
|| test_convolution(25, 33, 1, 1, k, d, s, p, 1)
161
|| test_convolution(25, 33, 4, 13, k, d, s, p, 0)
162
|| test_convolution(25, 33, 13, 4, k, d, s, p, 1)
163
|| test_convolution(25, 33, 12, 12, k, d, s, p, 0)
164
|| test_convolution(25, 33, 8, 12, k, d, s, p, 1)
165
|| test_convolution(25, 33, 8, 13, k, d, s, p, 0)
166
|| test_convolution(25, 33, 13, 8, k, d, s, p, 1)
167
|| test_convolution(25, 33, 12, 16, k, d, s, p, 0)
168
|| test_convolution(25, 33, 15, 15, k, d, s, p, 0)
169
|| test_convolution(25, 33, 16, 16, k, d, s, p, 0);
182
return test_convolution_0();