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

generic: SYCL: convolution/deconvolution/softmax: add missing checks #2146

Merged
merged 1 commit into from
Oct 14, 2024
Merged
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
14 changes: 6 additions & 8 deletions src/gpu/generic/sycl/ref_convolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ struct ref_convolution_fwd_t : public gpu::generic::sycl::primitive_t {
&& IMPLICATION(!attr()->scales_.has_default_values(),
attr_scales_ok()
&& check_convolution_scales_types(attr()))
&& sycl_post_ops_t::post_ops_ok(attr(), false);
&& sycl_post_ops_t::post_ops_ok(attr(), false)
&& set_default_alg_kind(alg_kind::convolution_direct);
if (!ok) return status::unimplemented;

return init_conf();
Expand Down Expand Up @@ -156,7 +157,8 @@ struct ref_convolution_bwd_data_t : public gpu::generic::sycl::primitive_t {
| sm::zero_points_runtime | sm::sum_dt)
&& IMPLICATION(!attr()->scales_.has_default_values(),
attr_scales_ok()
&& check_convolution_scales_types(attr()));
&& check_convolution_scales_types(attr()))
&& set_default_alg_kind(alg_kind::convolution_direct);
if (!ok) return status::unimplemented;

return init_conf();
Expand Down Expand Up @@ -195,7 +197,6 @@ struct ref_convolution_bwd_weights_t : public gpu::generic::sycl::primitive_t {

status_t init(impl::engine_t *engine) {
using namespace data_type;
using sm = primitive_attr_t::skip_mask_t;

const memory_desc_wrapper data_d(src_md());
const memory_desc_wrapper diff_weights_d(diff_weights_md());
Expand All @@ -208,11 +209,8 @@ struct ref_convolution_bwd_weights_t : public gpu::generic::sycl::primitive_t {
data_d, diff_weights_d, diff_dst_d)
&& check_convolution_formats(
data_d, diff_weights_d, diff_dst_d)
&& attr()->has_default_values(sm::scales_runtime
| sm::zero_points_runtime | sm::sum_dt)
&& IMPLICATION(!attr()->scales_.has_default_values(),
attr_scales_ok()
&& check_convolution_scales_types(attr()));
&& attr()->has_default_values()
&& set_default_alg_kind(alg_kind::convolution_direct);
if (!ok) return status::unimplemented;

return init_conf();
Expand Down
6 changes: 2 additions & 4 deletions src/gpu/generic/sycl/ref_deconvolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ struct ref_deconvolution_bwd_weights_t

status_t init(impl::engine_t *engine) {
using namespace data_type;
using sm = primitive_attr_t::skip_mask_t;

const memory_desc_wrapper data_d(src_md());
const memory_desc_wrapper diff_weights_d(diff_weights_md());
Expand All @@ -57,9 +56,8 @@ struct ref_deconvolution_bwd_weights_t
data_d, diff_weights_d, diff_dst_d)
&& check_convolution_formats(
data_d, diff_weights_d, diff_dst_d)
&& attr()->has_default_values(sm::scales_runtime
| sm::zero_points_runtime | sm::post_ops
| sm::sum_dt);
&& attr()->has_default_values()
&& desc()->alg_kind == alg_kind::deconvolution_direct;
if (!ok) return status::unimplemented;

return init_conf();
Expand Down
20 changes: 20 additions & 0 deletions src/gpu/generic/sycl/ref_softmax.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct ref_sycl_softmax_fwd_t : public gpu::generic::sycl::primitive_t {
&& sycl_post_ops_t::post_ops_ok(attr(), true, false)
&& set_default_formats() == status::success
&& attr_.set_default_formats(dst_md()) == status::success
&& check_formats(diff_src_md(), diff_dst_md())
&& md_dims_in_range(src_md());

if (!ok) return status::unimplemented;
Expand All @@ -70,6 +71,15 @@ struct ref_sycl_softmax_fwd_t : public gpu::generic::sycl::primitive_t {
return utils::one_of(src, data_type::f32, data_type::bf16,
data_type::f16, data_type::s8, data_type::u8);
}

static bool check_formats(const memory_desc_wrapper &src,
const memory_desc_wrapper &dst) {
for (const auto &mdw : {src, dst}) {
if (!mdw.is_plain()) return false;
}

return true;
}
};

status_t init(impl::engine_t *engine) override;
Expand Down Expand Up @@ -101,12 +111,22 @@ struct ref_sycl_softmax_bwd_t : public gpu::generic::sycl::primitive_t {
&& dst_md()->data_type == diff_dst_md()->data_type
&& attr()->has_default_values()
&& set_default_formats() == status::success
&& check_formats(src_md(), dst_md())
&& md_dims_in_range(diff_dst_md());

if (!ok) return status::unimplemented;
return init_conf();
}

static bool check_formats(const memory_desc_wrapper &src,
const memory_desc_wrapper &dst) {
for (const auto &mdw : {src, dst}) {
if (!mdw.is_plain()) return false;
}

return true;
}

sycl_softmax_conf_t conf_;
status_t init_conf();
};
Expand Down
Loading