Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segmentation fault in mvn update_shapes #27263

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/plugins/intel_gpu/src/graph/impls/ocl/eltwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ struct eltwise_impl : typed_primitive_impl_ocl<eltwise> {
DECLARE_OBJECT_TYPE_SERIALIZATION(cldnn::ocl::eltwise_impl)

std::unique_ptr<primitive_impl> clone() const override {
return make_unique<eltwise_impl>(*this);
auto prim_impl = make_unique<eltwise_impl>(*this);
clone_kernel_data_params<kernel_params_t>(*prim_impl);
return prim_impl;
}

void load(BinaryInputBuffer& ib) override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ struct fully_connected_impl : typed_primitive_impl_ocl<fully_connected> {
}

std::unique_ptr<primitive_impl> clone() const override {
return make_unique<fully_connected_impl>(*this);
auto prim_impl = make_unique<fully_connected_impl>(*this);
clone_kernel_data_params<kernel_params_t>(*prim_impl);
return prim_impl;
}

void load(BinaryInputBuffer& ib) override {
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/intel_gpu/src/graph/impls/ocl/gather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ struct gather_impl : typed_primitive_impl_ocl<gather> {
DECLARE_OBJECT_TYPE_SERIALIZATION(cldnn::ocl::gather_impl)

std::unique_ptr<primitive_impl> clone() const override {
return make_unique<gather_impl>(*this);
auto prim_impl = make_unique<gather_impl>(*this);
clone_kernel_data_params<kernel_params_t>(*prim_impl);
return prim_impl;
}

void load(BinaryInputBuffer& ib) override {
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/intel_gpu/src/graph/impls/ocl/gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ struct gemm_impl : multi_stage_primitive<gemm> {
const uint32_t indirect_gemm = 1;

std::unique_ptr<primitive_impl> clone() const override {
return make_unique<gemm_impl>(*this);
auto prim_impl = make_unique<gemm_impl>(*this);
clone_kernel_data_params<kernel_params_t>(*prim_impl);
return prim_impl;
}

gemm_impl() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ struct multi_stage_primitive : public typed_primitive_impl<PType> {
return {kernels_cache.get_cached_kernel_ids(_kernels)};
}

template<typename kernel_params_t>
static void clone_kernel_data_params(multi_stage_primitive& prim_impl) {
for (auto& _kernel_data : prim_impl._kernels_data) {
kernel_params_t* params_ptr = dynamic_cast<kernel_params_t*>(_kernel_data.params.get());
_kernel_data.params = make_unique<kernel_params_t>(*params_ptr);
}
}

std::vector<kernel::ptr> get_kernels() const override {
return _kernels;
}
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/intel_gpu/src/graph/impls/ocl/mvn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ struct mvn_impl : typed_primitive_impl_ocl<mvn> {
DECLARE_OBJECT_TYPE_SERIALIZATION(cldnn::ocl::mvn_impl)

std::unique_ptr<primitive_impl> clone() const override {
return make_unique<mvn_impl>(*this);
auto prim_impl = make_unique<mvn_impl>(*this);
clone_kernel_data_params<kernel_params_t>(*prim_impl);
return prim_impl;
}

void load(BinaryInputBuffer& ib) override {
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/intel_gpu/src/graph/impls/ocl/permute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ struct permute_impl : typed_primitive_impl_ocl<permute> {
DECLARE_OBJECT_TYPE_SERIALIZATION(cldnn::ocl::permute_impl)

std::unique_ptr<primitive_impl> clone() const override {
return make_unique<permute_impl>(*this);
auto prim_impl = make_unique<permute_impl>(*this);
clone_kernel_data_params<kernel_params_t>(*prim_impl);
return prim_impl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can have a template helper to minimize code copy-paste.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vladimir-paramuzov Addressed with commit 0ccef8f.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can embed make_unique part as well.

std::unique_ptr<primitive_impl> clone() const override {
    return make_deep_copy<permute_impl, kernel_params_t>(*this);
}

}

void load(BinaryInputBuffer& ib) override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ struct typed_primitive_impl_ocl : public typed_primitive_impl<PType> {
return {kernels_cache.get_cached_kernel_ids(_kernels)};
}

template<typename kernel_params_t>
static void clone_kernel_data_params(typed_primitive_impl_ocl& prim_impl) {
kernel_params_t* params_ptr = dynamic_cast<kernel_params_t*>(prim_impl._kernel_data.params.get());
prim_impl._kernel_data.params = make_unique<kernel_params_t>(*params_ptr);
}

std::vector<kernel::ptr> get_kernels() const override {
return _kernels;
}
Expand Down
Loading