Skip to content

Commit

Permalink
changed a way to use kernel_impl_params in save and load
Browse files Browse the repository at this point in the history
  • Loading branch information
e-ddykim committed Nov 7, 2022
1 parent b2033a4 commit e72ffa4
Show file tree
Hide file tree
Showing 23 changed files with 89 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ struct detection_output_impl : typed_primitive_impl<detection_output> {
nms_type = (node.get_primitive()->decrease_label_id ? NMSType::MXNET : NMSType::CAFFE);
}

void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
void save(BinaryOutputBuffer& ob) const override {
ob << make_data(&nms_type, sizeof(NMSType));
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
void load(BinaryInputBuffer& ib) override {
ib >> make_data(&nms_type, sizeof(NMSType));
}

Expand Down
8 changes: 4 additions & 4 deletions src/plugins/intel_gpu/src/graph/impls/ocl/activation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ struct activation_impl : typed_primitive_impl_ocl<activation> {
return args;
}

void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);
ob << _is_parameterized;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);
ib >> _is_parameterized;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ struct binary_convolution_impl : typed_primitive_impl_ocl<binary_convolution> {
int32_t get_split() const override { return _split; }

public:
void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);
ob << _split;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);
ib >> _split;
}

Expand Down
8 changes: 4 additions & 4 deletions src/plugins/intel_gpu/src/graph/impls/ocl/concatenation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ struct concatenation_impl : typed_primitive_impl_ocl<concatenation> {
}

public:
void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);
ob << _can_be_optimized;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);
ib >> _can_be_optimized;
}

Expand Down
8 changes: 4 additions & 4 deletions src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ struct convolution_impl : typed_primitive_impl_ocl<convolution> {
bool get_depthwise_sep_opt() const override { return _depthwise_sep_opt; }

public:
void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);
ob << _split;
ob << _groups;
ob << _depthwise_sep_opt;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);
ib >> _split;
ib >> _groups;
ib >> _depthwise_sep_opt;
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/intel_gpu/src/graph/impls/ocl/crop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ struct crop_impl : typed_primitive_impl_ocl<crop> {
}

public:
void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);
ob << _can_be_optimized;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);
ib >> _can_be_optimized;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ struct custom_gpu_primitive_impl : typed_primitive_impl<custom_gpu_primitive> {
return {_kernel_id};
}

void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
void save(BinaryOutputBuffer& ob) const override {
ob << *cl_kernel;
ob << _kernel_id;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
void load(BinaryInputBuffer& ib) override {
cl_kernel = std::make_shared<kernel_selector::cl_kernel_data>();
ib >> *cl_kernel;
ib >> _kernel_id;
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/intel_gpu/src/graph/impls/ocl/deconvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ struct deconvolution_impl : typed_primitive_impl_ocl<deconvolution> {
_groups = node.get_groups();
}

void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);
ob << _split;
ob << _groups;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);
ib >> _split;
ib >> _groups;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ struct deformable_conv_impl : typed_primitive_impl_ocl<deformable_conv> {
_groups = node.get_groups();
}

void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);
ob << _split;
ob << _groups;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);
ib >> _split;
ib >> _groups;
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_gpu/src/graph/impls/ocl/generic_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ struct generic_layer_impl : typed_primitive_impl<generic_layer> {
_kernel_id = arg.get_program().add_kernel(arg.get_primitive()->generic_params.clKernel->code.kernelString);
}

void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
void save(BinaryOutputBuffer& ob) const override {
ob <<_cl_kernel_data;
ob << _kernel_id;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
void load(BinaryInputBuffer& ib) override {
ib >> _cl_kernel_data;
ib >> _kernel_id;
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_gpu/src/graph/impls/ocl/primitive_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ struct typed_primitive_impl_ocl : public typed_primitive_impl<PType> {

bool is_cpu() const override { return false; }

void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
void save(BinaryOutputBuffer& ob) const override {
ob << make_data(&_kernel_data.internalBufferDataType, sizeof(kernel_selector::Datatype));
ob << _kernel_data.internalBufferSizes;
ob << _kernel_data.kernels;
ob << _kernel_ids;
ob << _kernel_args;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
void load(BinaryInputBuffer& ib) override {
ib >> make_data(&_kernel_data.internalBufferDataType, sizeof(kernel_selector::Datatype));
ib >> _kernel_data.internalBufferSizes;
ib >> _kernel_data.kernels;
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/intel_gpu/src/graph/impls/ocl/reorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ struct reorder_impl : typed_primitive_impl_ocl<reorder> {
_has_mean = node.has_mean();
}

void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);
ob << _can_be_optimized;
ob << _has_mean;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);
ib >> _can_be_optimized;
ib >> _has_mean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ struct concatenation_onednn : typed_primitive_onednn_impl<concatenation, void, d
}

public:
void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
void save(BinaryOutputBuffer& ob) const override {
if (_prim.get(true) == nullptr) {
ob << false;
return;
} else {
ob << true;
}

parent::save(ob, impl_params);
parent::save(ob);

const kernel_impl_params* impl_params = reinterpret_cast<kernel_impl_params*>(ob.getKernlImplParams());
auto prim = impl_params->typed_desc<concatenation>();
ob << prim->axis;

Expand All @@ -81,18 +82,19 @@ struct concatenation_onednn : typed_primitive_onednn_impl<concatenation, void, d
ob << prim_cache;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
void load(BinaryInputBuffer& ib) override {
bool has_prim;
ib >> has_prim;

if (!has_prim)
return;

parent::load(ib, impl_params);
parent::load(ib);

int64_t prim_axis;
ib >> prim_axis;

const kernel_impl_params* impl_params = reinterpret_cast<kernel_impl_params*>(ib.getKernlImplParams());
auto desc = get_concatenation_descriptor(*impl_params, prim_axis, ib.get_engine());
_pd = *desc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ struct convolution_onednn : typed_primitive_onednn_impl<convolution, dnnl::convo


public:
void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);

ob << make_data(&_desc->data, sizeof(dnnl_convolution_desc_t));

Expand All @@ -195,8 +195,8 @@ struct convolution_onednn : typed_primitive_onednn_impl<convolution, dnnl::convo
ob << prim_cache;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);

_desc = std::make_shared<dnnl::convolution_forward::desc>();
ib >> make_data(&_desc->data, sizeof(dnnl_convolution_desc_t));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ struct deconvolution_onednn : typed_primitive_onednn_impl<deconvolution, dnnl::d
}

public:
void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);

ob << make_data(&_desc->data, sizeof(dnnl_deconvolution_desc_t));

Expand All @@ -114,8 +114,8 @@ struct deconvolution_onednn : typed_primitive_onednn_impl<deconvolution, dnnl::d
ob << prim_cache;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);

_desc = std::make_shared<dnnl::deconvolution_forward::desc>();
ib >> make_data(&_desc->data, sizeof(dnnl_deconvolution_desc_t));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ struct fully_connected_onednn : typed_primitive_onednn_impl<fully_connected, dnn
}

public:
void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);

ob << make_data(&_desc->data, sizeof(dnnl_inner_product_desc_t));

Expand All @@ -176,8 +176,8 @@ struct fully_connected_onednn : typed_primitive_onednn_impl<fully_connected, dnn
ob << prim_cache;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);

_desc = std::make_shared<dnnl::inner_product_forward::desc>();
ib >> make_data(&_desc->data, sizeof(dnnl_inner_product_desc_t));
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ struct gemm_onednn : typed_primitive_onednn_impl<gemm, dnnl::matmul::desc> {
}

public:
void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);

ob << make_data(&_desc->data, sizeof(dnnl_matmul_desc_t));

Expand All @@ -219,8 +219,8 @@ struct gemm_onednn : typed_primitive_onednn_impl<gemm, dnnl::matmul::desc> {
ob << prim_cache;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);

_desc = std::make_shared<dnnl::matmul::desc>();
ib >> make_data(&_desc->data, sizeof(dnnl_matmul_desc_t));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ struct pooling_onednn : typed_primitive_onednn_impl<pooling, dnnl::pooling_forwa
}

public:
void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);

ob << make_data(&_desc->data, sizeof(dnnl_pooling_desc_t));

Expand All @@ -74,8 +74,8 @@ struct pooling_onednn : typed_primitive_onednn_impl<pooling, dnnl::pooling_forwa
ob << prim_cache;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);

_desc = std::make_shared<dnnl::pooling_forward::desc>();
ib >> make_data(&_desc->data, sizeof(dnnl_pooling_desc_t));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ struct reduction_onednn : typed_primitive_onednn_impl<reduce, dnnl::reduction::d
}

public:
void save(BinaryOutputBuffer& ob, const kernel_impl_params* impl_params = nullptr) const override {
parent::save(ob, impl_params);
void save(BinaryOutputBuffer& ob) const override {
parent::save(ob);

ob << make_data(&_desc->data, sizeof(dnnl_reduction_desc_t));

Expand All @@ -103,8 +103,8 @@ struct reduction_onednn : typed_primitive_onednn_impl<reduce, dnnl::reduction::d
ob << prim_cache;
}

void load(BinaryInputBuffer& ib, const kernel_impl_params* impl_params = nullptr) override {
parent::load(ib, impl_params);
void load(BinaryInputBuffer& ib) override {
parent::load(ib);

_desc = std::make_shared<dnnl::reduction::desc>();
ib >> make_data(&_desc->data, sizeof(dnnl_reduction_desc_t));
Expand Down
Loading

0 comments on commit e72ffa4

Please sign in to comment.