Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Jan 4, 2024
1 parent 8a29df6 commit 4637fb0
Show file tree
Hide file tree
Showing 13 changed files with 224 additions and 77 deletions.
44 changes: 24 additions & 20 deletions src/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,77 +317,81 @@ class Layer_final : public Layer
virtual int load_param(const ParamDict& pd)
{
set_layer_properties();
{
int ret = layer_cpu->load_param(pd);
if (ret)
return ret;
}
#if NCNN_VULKAN
if (layer_vulkan && vkdev)
{
int ret = layer_vulkan->load_param(pd);
if (ret)
return ret;
}
else
#endif // NCNN_VULKAN
{
int ret = layer_cpu->load_param(pd);
if (ret)
return ret;
}
get_layer_properties();
return 0;
}

virtual int load_model(const ModelBin& mb)
{
{
int ret = layer_cpu->load_model(mb);
if (ret)
return ret;
}
#if NCNN_VULKAN
if (layer_vulkan && vkdev)
{
int ret = layer_vulkan->load_model(mb);
if (ret)
return ret;
}
else
#endif // NCNN_VULKAN
{
int ret = layer_cpu->load_model(mb);
if (ret)
return ret;
}
get_layer_properties();
return 0;
}

virtual int create_pipeline(const Option& opt)
{
set_layer_properties();
{
int ret = layer_cpu->create_pipeline(opt);
if (ret)
return ret;
}
#if NCNN_VULKAN
if (layer_vulkan && vkdev)
{
int ret = layer_vulkan->create_pipeline(opt);
if (ret)
return ret;
}
else
#endif // NCNN_VULKAN
{
int ret = layer_cpu->create_pipeline(opt);
if (ret)
return ret;
}
get_layer_properties();
return 0;
}

virtual int destroy_pipeline(const Option& opt)
{
{
int ret = layer_cpu->destroy_pipeline(opt);
if (ret)
return ret;
}
#if NCNN_VULKAN
if (layer_vulkan && vkdev)
{
int ret = layer_vulkan->destroy_pipeline(opt);
if (ret)
return ret;
}
else
#endif // NCNN_VULKAN
{
int ret = layer_cpu->destroy_pipeline(opt);
if (ret)
return ret;
}
return 0;
}

Expand Down
12 changes: 10 additions & 2 deletions src/layer/vulkan/convolution1d_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,23 @@ Convolution1D_vulkan::Convolution1D_vulkan()
pipeline_convolution1d = 0;
}

int Convolution1D_vulkan::create_pipeline(const Option& _opt)
int Convolution1D_vulkan::load_param(const ParamDict& pd)
{
int ret = Convolution1D::load_param(pd);
if (ret)
return ret;

if (dynamic_weight)
{
support_vulkan = false;
support_image_storage = false;
return 0;
}

return 0;
}

int Convolution1D_vulkan::create_pipeline(const Option& _opt)
{
Option opt = _opt;

const int maxk = kernel_w;
Expand Down
2 changes: 2 additions & 0 deletions src/layer/vulkan/convolution1d_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Convolution1D_vulkan : public Convolution1D
public:
Convolution1D_vulkan();

virtual int load_param(const ParamDict& pd);

virtual int create_pipeline(const Option& opt);
virtual int destroy_pipeline(const Option& opt);

Expand Down
12 changes: 10 additions & 2 deletions src/layer/vulkan/convolution_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,23 @@ Convolution_vulkan::Convolution_vulkan()
reshape_w = 0;
}

int Convolution_vulkan::create_pipeline(const Option& _opt)
int Convolution_vulkan::load_param(const ParamDict& pd)
{
int ret = Convolution::load_param(pd);
if (ret)
return ret;

if (dynamic_weight)
{
support_vulkan = false;
support_image_storage = false;
return 0;
}

return 0;
}

int Convolution_vulkan::create_pipeline(const Option& _opt)
{
Option opt = _opt;
const Mat& shape = bottom_shapes.empty() ? Mat() : bottom_shapes[0];
const Mat& out_shape = top_shapes.empty() ? Mat() : top_shapes[0];
Expand Down
2 changes: 2 additions & 0 deletions src/layer/vulkan/convolution_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Convolution_vulkan : public Convolution
public:
Convolution_vulkan();

virtual int load_param(const ParamDict& pd);

virtual int create_pipeline(const Option& opt);
virtual int destroy_pipeline(const Option& opt);

Expand Down
12 changes: 10 additions & 2 deletions src/layer/vulkan/convolutiondepthwise_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,23 @@ ConvolutionDepthWise_vulkan::ConvolutionDepthWise_vulkan()
pipeline_convolutiondepthwise_group_pack8to1 = 0;
}

int ConvolutionDepthWise_vulkan::create_pipeline(const Option& _opt)
int ConvolutionDepthWise_vulkan::load_param(const ParamDict& pd)
{
int ret = ConvolutionDepthWise::load_param(pd);
if (ret)
return ret;

if (dynamic_weight)
{
support_vulkan = false;
support_image_storage = false;
return 0;
}

return 0;
}

int ConvolutionDepthWise_vulkan::create_pipeline(const Option& _opt)
{
Option opt = _opt;
const Mat& shape = bottom_shapes.empty() ? Mat() : bottom_shapes[0];
const Mat& out_shape = top_shapes.empty() ? Mat() : top_shapes[0];
Expand Down
2 changes: 2 additions & 0 deletions src/layer/vulkan/convolutiondepthwise_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class ConvolutionDepthWise_vulkan : public ConvolutionDepthWise
public:
ConvolutionDepthWise_vulkan();

virtual int load_param(const ParamDict& pd);

virtual int create_pipeline(const Option& opt);
virtual int destroy_pipeline(const Option& opt);

Expand Down
12 changes: 10 additions & 2 deletions src/layer/vulkan/deconvolution_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,23 @@ Deconvolution_vulkan::Deconvolution_vulkan()
pipeline_deconvolution_col2im = 0;
}

int Deconvolution_vulkan::create_pipeline(const Option& _opt)
int Deconvolution_vulkan::load_param(const ParamDict& pd)
{
int ret = Deconvolution::load_param(pd);
if (ret)
return ret;

if (dynamic_weight)
{
support_vulkan = false;
support_image_storage = false;
return 0;
}

return 0;
}

int Deconvolution_vulkan::create_pipeline(const Option& _opt)
{
Option opt = _opt;
const Mat& shape = bottom_shapes.empty() ? Mat() : bottom_shapes[0];
const Mat& out_shape = top_shapes.empty() ? Mat() : top_shapes[0];
Expand Down
2 changes: 2 additions & 0 deletions src/layer/vulkan/deconvolution_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Deconvolution_vulkan : public Deconvolution
public:
Deconvolution_vulkan();

virtual int load_param(const ParamDict& pd);

virtual int create_pipeline(const Option& opt);
virtual int destroy_pipeline(const Option& opt);

Expand Down
12 changes: 10 additions & 2 deletions src/layer/vulkan/deconvolutiondepthwise_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,23 @@ DeconvolutionDepthWise_vulkan::DeconvolutionDepthWise_vulkan()
pipeline_deconvolutiondepthwise_group_pack8to1 = 0;
}

int DeconvolutionDepthWise_vulkan::create_pipeline(const Option& _opt)
int DeconvolutionDepthWise_vulkan::load_param(const ParamDict& pd)
{
int ret = DeconvolutionDepthWise::load_param(pd);
if (ret)
return ret;

if (dynamic_weight)
{
support_vulkan = false;
support_image_storage = false;
return 0;
}

return 0;
}

int DeconvolutionDepthWise_vulkan::create_pipeline(const Option& _opt)
{
Option opt = _opt;
const Mat& shape = bottom_shapes.empty() ? Mat() : bottom_shapes[0];
const Mat& out_shape = top_shapes.empty() ? Mat() : top_shapes[0];
Expand Down
2 changes: 2 additions & 0 deletions src/layer/vulkan/deconvolutiondepthwise_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class DeconvolutionDepthWise_vulkan : public DeconvolutionDepthWise
public:
DeconvolutionDepthWise_vulkan();

virtual int load_param(const ParamDict& pd);

virtual int create_pipeline(const Option& opt);
virtual int destroy_pipeline(const Option& opt);

Expand Down
Loading

0 comments on commit 4637fb0

Please sign in to comment.