17
static int test_deconvolution(int w, int h, int c, int outch, int kernel, int dilation, int stride, int pad, int bias, int output_pad_right, int output_pad_bottom, int output_w, int output_h)
19
ncnn::Mat a = RandomMat(w, h, c);
21
if (output_w > 0 && output_h > 0 && pad != -233 && pad != -234)
33
pd.set(6, outch * c * kernel * kernel);
35
int activation_type = RAND() % 5;
36
ncnn::Mat activation_params(2);
37
activation_params[0] = RandomFloat(-1, 0);
38
activation_params[1] = RandomFloat(0, 1);
39
pd.set(9, activation_type);
40
pd.set(10, activation_params);
42
pd.set(18, output_pad_right);
43
pd.set(19, output_pad_bottom);
47
std::vector<ncnn::Mat> weights(2);
48
weights[0] = RandomMat(outch * c * kernel * kernel);
49
weights[1] = RandomMat(outch);
51
int ret = test_layer("Deconvolution", pd, weights, a);
54
fprintf(stderr, "test_deconvolution failed w=%d h=%d c=%d outch=%d kernel=%d dilation=%d stride=%d pad=%d bias=%d act=%d actparams=[%f,%f] output_pad_right=%d output_pad_bottom=%d output_w=%d output_h=%d\n", w, h, c, outch, kernel, dilation, stride, pad, bias, activation_type, activation_params[0], activation_params[1], output_pad_right, output_pad_bottom, output_w, output_h);
60
opt.use_packing_layout = true;
61
opt.use_fp16_packed = false;
62
opt.use_fp16_storage = false;
63
opt.use_fp16_arithmetic = false;
64
opt.use_bf16_storage = false;
65
opt.use_shader_pack8 = false;
66
opt.use_image_storage = false;
67
opt.use_sgemm_convolution = false;
68
opt.use_winograd_convolution = false;
70
ret = test_layer_opt("Deconvolution", pd, weights, opt, a);
73
fprintf(stderr, "test_deconvolution failed w=%d h=%d c=%d outch=%d kernel=%d dilation=%d stride=%d pad=%d bias=%d act=%d actparams=[%f,%f] output_pad_right=%d output_pad_bottom=%d output_w=%d output_h=%d\n", w, h, c, outch, kernel, dilation, stride, pad, bias, activation_type, activation_params[0], activation_params[1], output_pad_right, output_pad_bottom, output_w, output_h);
80
opt.use_packing_layout = true;
81
opt.use_fp16_packed = true;
82
opt.use_fp16_storage = true;
83
opt.use_fp16_arithmetic = true;
84
opt.use_bf16_storage = true;
85
opt.use_shader_pack8 = true;
86
opt.use_image_storage = true;
87
opt.use_sgemm_convolution = false;
88
opt.use_winograd_convolution = false;
90
ret = test_layer_opt("Deconvolution", pd, weights, opt, a);
93
fprintf(stderr, "test_deconvolution failed w=%d h=%d c=%d outch=%d kernel=%d dilation=%d stride=%d pad=%d bias=%d act=%d actparams=[%f,%f] output_pad_right=%d output_pad_bottom=%d output_w=%d output_h=%d\n", w, h, c, outch, kernel, dilation, stride, pad, bias, activation_type, activation_params[0], activation_params[1], output_pad_right, output_pad_bottom, output_w, output_h);
100
static int test_deconvolution_0()
102
static const int kdsp[16][4] = {
121
for (int i = 0; i < 16; i++)
123
const int k = kdsp[i][0];
124
const int d = kdsp[i][1];
125
const int s = kdsp[i][2];
126
const int p = kdsp[i][3];
129
|| test_deconvolution(9, 7, 1, 1, k, d, s, p, 1, 0, 0, 0, 0)
130
|| test_deconvolution(9, 7, 4, 13, k, d, s, p, 0, 1, 1, 7, 5)
131
|| test_deconvolution(9, 7, 13, 4, k, d, s, p, 1, 1, 0, 0, 0)
132
|| test_deconvolution(9, 7, 4, 8, k, d, s, p, 0, 0, 1, 0, 0)
133
|| test_deconvolution(9, 7, 8, 4, k, d, s, p, 1, 0, 0, 7, 5)
134
|| test_deconvolution(7, 7, 12, 12, k, d, s, p, 1, 0, 1, 0, 0)
135
|| test_deconvolution(4, 5, 12, 11, k, d, s, p, 0, 0, 1, 1, 0)
136
|| test_deconvolution(9, 7, 8, 13, k, d, s, p, 0, 2, 2, 0, 0)
137
|| test_deconvolution(9, 7, 13, 8, k, d, s, p, 1, 2, 0, 0, 0)
138
|| test_deconvolution(9, 7, 16, 16, k, d, s, p, 0, 0, 2, 7, 5);
145
|| test_deconvolution(7, 5, 24, 32, 4, 2, 2, 2, 1, 0, 0, 0, 0)
146
|| test_deconvolution(7, 5, 32, 24, 4, 2, 2, 2, 1, 0, 0, 0, 0)
147
|| test_deconvolution(7, 5, 28, 32, 4, 2, 2, 2, 1, 0, 0, 0, 0)
148
|| test_deconvolution(7, 5, 32, 28, 4, 2, 2, 2, 1, 0, 0, 0, 0)
149
|| test_deconvolution(7, 5, 26, 32, 4, 2, 2, 2, 1, 0, 0, 0, 0)
150
|| test_deconvolution(7, 5, 32, 26, 4, 2, 2, 2, 1, 0, 0, 0, 0);
153
static int test_deconvolution_dynamic(int w, int h, int c, int outch, int kernel, int dilation, int stride, int pad, int bias, int output_pad_right, int output_pad_bottom, int output_w, int output_h)
155
ncnn::Mat a = RandomMat(w, h, c);
157
if (output_w > 0 && output_h > 0 && pad != -233 && pad != -234)
172
int activation_type = RAND() % 7;
173
ncnn::Mat activation_params(2);
174
activation_params[0] = (activation_type == 6) ? RandomFloat(0, 1) : RandomFloat(-1, 0);
175
activation_params[1] = RandomFloat(0, 1);
176
pd.set(9, activation_type);
177
pd.set(10, activation_params);
179
pd.set(18, output_pad_right);
180
pd.set(19, output_pad_bottom);
181
pd.set(20, output_w);
182
pd.set(21, output_h);
184
std::vector<ncnn::Mat> as(bias ? 3 : 2);
186
as[1] = RandomMat(kernel, kernel, outch, c);
188
as[2] = RandomMat(outch);
190
std::vector<ncnn::Mat> weights(0);
192
int ret = test_layer("Deconvolution", pd, weights, as);
195
fprintf(stderr, "test_deconvolution_dynamic failed w=%d h=%d c=%d outch=%d kernel=%d dilation=%d stride=%d pad=%d bias=%d act=%d actparams=[%f,%f] output_pad_right=%d output_pad_bottom=%d output_w=%d output_h=%d\n", w, h, c, outch, kernel, dilation, stride, pad, bias, activation_type, activation_params[0], activation_params[1], output_pad_right, output_pad_bottom, output_w, output_h);
201
static int test_deconvolution_1()
203
static const int kdsp[7][4] = {
213
for (int i = 0; i < 7; i++)
215
const int k = kdsp[i][0];
216
const int d = kdsp[i][1];
217
const int s = kdsp[i][2];
218
const int p = kdsp[i][3];
221
|| test_deconvolution_dynamic(9, 7, 1, 1, k, d, s, p, 1, 0, 0, 0, 0)
222
|| test_deconvolution_dynamic(9, 7, 4, 13, k, d, s, p, 0, 1, 1, 7, 5)
223
|| test_deconvolution_dynamic(9, 7, 13, 4, k, d, s, p, 1, 1, 0, 0, 0)
224
|| test_deconvolution_dynamic(9, 7, 4, 8, k, d, s, p, 0, 0, 1, 0, 0)
225
|| test_deconvolution_dynamic(9, 7, 8, 4, k, d, s, p, 1, 0, 0, 7, 5)
226
|| test_deconvolution_dynamic(7, 7, 12, 12, k, d, s, p, 1, 0, 1, 0, 0)
227
|| test_deconvolution_dynamic(4, 5, 12, 11, k, d, s, p, 0, 0, 1, 1, 0)
228
|| test_deconvolution_dynamic(9, 7, 8, 13, k, d, s, p, 0, 2, 2, 0, 0)
229
|| test_deconvolution_dynamic(9, 7, 13, 8, k, d, s, p, 1, 2, 0, 0, 0)
230
|| test_deconvolution_dynamic(9, 7, 16, 16, k, d, s, p, 0, 0, 2, 7, 5);
243
return test_deconvolution_0() || test_deconvolution_1();