/*Step 2: transfer image to winograd domain*/
float *col_buff =
new float[std::max(outch, inch) * ntiles_h_ * ntiles_w_ * tile_h_in_ * tile_w_in_];
- if (NULL == col_buff)
- return;
-
- winograd_input_im2col(col_buff);
int temp1_n = inch * ntiles_h_ * ntiles_w_;
float *temp1_ =
new float[tile_h_in_ * tile_w_in_ * std::max(outch, inch) * ntiles_h_ * ntiles_w_];
- if (NULL == temp1_)
- return;
float *winograd_b = new float[M * M * M * M];
- if (NULL == winograd_b)
+
+ if ((NULL == col_buff) || (NULL == temp1_) || (NULL == winograd_b))
+ {
+ delete[] col_buff;
+ delete[] temp1_;
+ delete[] winograd_b;
return;
+ }
+
+ winograd_input_im2col(col_buff);
+
kronecker_product(winograd_b, B, B, M, M, M, M);
compute_sgemm(rowMajor, trans, trans, tile_h_in_ * tile_w_in_, temp1_n, tile_h_in_ * tile_w_in_,
winograd_b, col_buff, temp1_);
+ delete[] winograd_b;
+
/*Step 3: convolution in winograd domain*/
for (int j = 0; j < tile_h_in_ * tile_w_in_; ++j)
{
/*Step 4: transfer back to time domain*/
float *winograd_a = new float[M * (M - N + 1) * M * (M - N + 1)];
if (NULL == winograd_a)
+ {
+ delete[] col_buff;
+ delete[] temp1_;
return;
+ }
kronecker_product(winograd_a, A, A, M, M - N + 1, M, M - N + 1);
compute_sgemm(rowMajor, trans, notrans, outch * ntiles_h_ * ntiles_w_, tile_h_out_ * tile_w_out_,
tile_h_in_ * tile_w_in_, col_buff, winograd_a, temp1_);
winograd_output_col2im(temp1_);
delete[] temp1_;
-
- delete[] winograd_b;
}
void conv_winograd::run()
/*Step 2: transfer image to winograd domain*/
float *col_buff =
new float[std::max(outch, inch) * batch * ntiles_h_ * ntiles_w_ * tile_h_in_ * tile_w_in_];
- if (NULL == col_buff)
- return;
-
- winograd_input_im2col(col_buff);
int temp1_n = batch * inch * ntiles_h_ * ntiles_w_;
float *temp1_ =
new float[batch * tile_h_in_ * tile_w_in_ * std::max(outch, inch) * ntiles_h_ * ntiles_w_];
- if (NULL == temp1_)
- return;
float *winograd_b = new float[M * M * M * M];
- if (NULL == winograd_b)
+
+ if ((NULL == col_buff) || (NULL == temp1_) || (NULL == winograd_b))
+ {
+ delete[] col_buff;
+ delete[] temp1_;
+ delete[] winograd_b;
return;
+ }
+
+ winograd_input_im2col(col_buff);
+
kronecker_product(winograd_b, B, B, M, M, M, M);
compute_sgemm(rowMajor, trans, trans, tile_h_in_ * tile_w_in_, temp1_n, tile_h_in_ * tile_w_in_,
winograd_b, col_buff, temp1_);
+ delete[] winograd_b;
/*Step 3: convolution in winograd domain*/
for (int j = 0; j < tile_h_in_ * tile_w_in_; ++j)
/*Step 4: transfer back to time domain*/
float *winograd_a = new float[M * (M - N + 1) * M * (M - N + 1)];
if (NULL == winograd_a)
+ {
+ delete[] col_buff;
+ delete[] temp1_;
return;
+ }
+
kronecker_product(winograd_a, A, A, M, M - N + 1, M, M - N + 1);
compute_sgemm(rowMajor, trans, notrans, batch * outch * ntiles_h_ * ntiles_w_,
tile_h_out_ * tile_w_out_, tile_h_in_ * tile_w_in_, col_buff, winograd_a, temp1_);
winograd_output_col2im(temp1_);
delete[] temp1_;
-
- delete[] winograd_b;
}
void conv_winograd_batch::run()
float *winograd_g = new float[M * M * N * N];
if (!winograd_g)
+ {
+ delete[] winograd_weight;
return NULL;
+ }
kronecker_product(winograd_g, G, G, M, N, M, N);
{
weight_data = new float[kernel_size * kernel_size * inch * outch];
if (!weight_data)
+ {
+ delete[] winograd_weight;
+ delete[] winograd_g;
return NULL;
+ }
weight_transfer(weight_data, params.weight_data, kernel_size, kernel_size, inch, outch);
}