Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Apr 8, 2024
1 parent 8711dd4 commit ef8a99a
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 48 deletions.
5 changes: 4 additions & 1 deletion src/layer/loongarch/convolution1d_loongarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ int Convolution1D_loongarch::create_pipeline(const Option& opt)
}
}

if (opt.lightmode)
weight_data.release();

return 0;
}

Expand Down Expand Up @@ -281,7 +284,7 @@ int Convolution1D_loongarch::forward(const Mat& bottom_blob, Mat& top_blob, cons
sum = bias_data[p];
}

const float* kptr = (const float*)weight_data + kernel_w * h * p;
const float* kptr = weight_data_packed.channel(p);

for (int q = 0; q < h; q++)
{
Expand Down
6 changes: 4 additions & 2 deletions src/layer/loongarch/convolution_loongarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ int Convolution_loongarch::create_pipeline(const Option& opt)
}
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down Expand Up @@ -789,7 +790,8 @@ int Convolution_loongarch::create_pipeline_int8_loongarch(const Option& opt)
scale_in_data[p] = scale_in;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
12 changes: 8 additions & 4 deletions src/layer/loongarch/convolutiondepthwise_loongarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ int ConvolutionDepthWise_loongarch::create_pipeline(const Option& opt)
weight_data_tm = weight_data;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}

// group convolution
create_group_ops(opt);

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down Expand Up @@ -600,15 +602,17 @@ int ConvolutionDepthWise_loongarch::create_pipeline_int8_loongarch(const Option&
weight_data_tm = weight_data;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}

// group convolution
create_group_ops(opt);

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion src/layer/loongarch/deconvolution_loongarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ int Deconvolution_loongarch::create_pipeline(const Option& opt)
{
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
6 changes: 4 additions & 2 deletions src/layer/loongarch/deconvolutiondepthwise_loongarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,17 @@ int DeconvolutionDepthWise_loongarch::create_pipeline(const Option& opt)
weight_data_tm = weight_data_transposed;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}

// group convolution
create_group_ops(opt);

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
9 changes: 6 additions & 3 deletions src/layer/loongarch/innerproduct_loongarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ int InnerProduct_loongarch::create_pipeline(const Option& opt)
weight_data_tm = weight_data;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down Expand Up @@ -652,7 +653,8 @@ int InnerProduct_loongarch::create_pipeline_fp16s(const Option& opt)
ncnn::cast_float32_to_float16(weight_data_r2, weight_data_tm, opt);
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down Expand Up @@ -1140,7 +1142,8 @@ int InnerProduct_loongarch::create_pipeline_int8_loongarch(const Option& opt)
scale_in_data[p] = scale_in;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
5 changes: 4 additions & 1 deletion src/layer/mips/convolution1d_mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ int Convolution1D_mips::create_pipeline(const Option& opt)
}
}

if (opt.lightmode)
weight_data.release();

return 0;
}

Expand Down Expand Up @@ -281,7 +284,7 @@ int Convolution1D_mips::forward(const Mat& bottom_blob, Mat& top_blob, const Opt
sum = bias_data[p];
}

const float* kptr = (const float*)weight_data + kernel_w * h * p;
const float* kptr = weight_data_packed.channel(p);

for (int q = 0; q < h; q++)
{
Expand Down
6 changes: 4 additions & 2 deletions src/layer/mips/convolution_mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ int Convolution_mips::create_pipeline(const Option& opt)
}
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down Expand Up @@ -789,7 +790,8 @@ int Convolution_mips::create_pipeline_int8_mips(const Option& opt)
scale_in_data[p] = scale_in;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
12 changes: 8 additions & 4 deletions src/layer/mips/convolutiondepthwise_mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ int ConvolutionDepthWise_mips::create_pipeline(const Option& opt)
weight_data_tm = weight_data;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}

// group convolution
create_group_ops(opt);

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down Expand Up @@ -600,15 +602,17 @@ int ConvolutionDepthWise_mips::create_pipeline_int8_mips(const Option& opt)
weight_data_tm = weight_data;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}

// group convolution
create_group_ops(opt);

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion src/layer/mips/deconvolution_mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ int Deconvolution_mips::create_pipeline(const Option& opt)
{
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
6 changes: 4 additions & 2 deletions src/layer/mips/deconvolutiondepthwise_mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,17 @@ int DeconvolutionDepthWise_mips::create_pipeline(const Option& opt)
weight_data_tm = weight_data_transposed;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}

// group convolution
create_group_ops(opt);

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
9 changes: 6 additions & 3 deletions src/layer/mips/innerproduct_mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ int InnerProduct_mips::create_pipeline(const Option& opt)
weight_data_tm = weight_data;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down Expand Up @@ -652,7 +653,8 @@ int InnerProduct_mips::create_pipeline_fp16s(const Option& opt)
ncnn::cast_float32_to_float16(weight_data_r2, weight_data_tm, opt);
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down Expand Up @@ -1140,7 +1142,8 @@ int InnerProduct_mips::create_pipeline_int8_mips(const Option& opt)
scale_in_data[p] = scale_in;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
8 changes: 6 additions & 2 deletions src/layer/riscv/convolution1d_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ int Convolution1D_riscv::create_pipeline(const Option& opt)
}
}

if (opt.lightmode)
weight_data.release();

return 0;
}

Expand Down Expand Up @@ -308,7 +311,7 @@ int Convolution1D_riscv::forward(const Mat& bottom_blob, Mat& top_blob, const Op
sum = bias_data[p];
}

const float* kptr = (const float*)weight_data + kernel_w * h * p;
const float* kptr = weight_data_packed.channel(p);

for (int q = 0; q < h; q++)
{
Expand Down Expand Up @@ -470,7 +473,8 @@ int Convolution1D_riscv::create_pipeline_fp16s(const Option& opt)

ncnn::cast_float32_to_float16(bias_data, bias_data_fp16, opt);

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
6 changes: 4 additions & 2 deletions src/layer/riscv/convolution_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ int Convolution_riscv::create_pipeline(const Option& opt)
}
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down Expand Up @@ -834,7 +835,8 @@ int Convolution_riscv::create_pipeline_fp16s(const Option& opt)
ncnn::cast_float32_to_float16(bias_data, bias_data_fp16, opt);
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
12 changes: 8 additions & 4 deletions src/layer/riscv/convolutiondepthwise_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,17 @@ int ConvolutionDepthWise_riscv::create_pipeline(const Option& opt)
weight_data_tm = weight_data;
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}

// group convolution
create_group_ops(opt);

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down Expand Up @@ -682,15 +684,17 @@ int ConvolutionDepthWise_riscv::create_pipeline_fp16s(const Option& opt)

ncnn::cast_float32_to_float16(bias_data, bias_data_fp16, opt);

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}

// group convolution
create_group_ops(opt);

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
6 changes: 4 additions & 2 deletions src/layer/riscv/deconvolution_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ int Deconvolution_riscv::create_pipeline(const Option& opt)
{
}

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down Expand Up @@ -530,7 +531,8 @@ int Deconvolution_riscv::create_pipeline_fp16s(const Option& opt)

ncnn::cast_float32_to_float16(bias_data, bias_data_fp16, opt);

weight_data.release();
if (opt.lightmode)
weight_data.release();

return 0;
}
Expand Down
Loading

0 comments on commit ef8a99a

Please sign in to comment.