Skip to content

Commit

Permalink
fixup: api: ukernel: make get_B_pack_type static for better usability
Browse files Browse the repository at this point in the history
Handle unsupported platforms gracefully.
  • Loading branch information
dzarukin committed Feb 15, 2025
1 parent ef18919 commit e320df4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions examples/ukernels/cpu_brgemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,17 @@ void brgemm_example() {
// packing requirements once for multiple objects.
// Based on this information, specific `ldb` value can be used, since
// transform has a limited set of values supported.
const bool need_pack
= brgemm::get_B_pack_type(a_dt, b_dt) == pack_type::pack32;
bool need_pack = false;
try {
need_pack = brgemm::get_B_pack_type(a_dt, b_dt) == pack_type::pack32;
} catch (error &e) {
if (e.status == dnnl_unimplemented)
throw example_allows_unimplemented {
"Kernel is not supported on this platform.\n"};

// on any other error just re-throw
throw;
}

const memory::dim lda = K;
// `ldb` for `need_pack = true` must be one of 16, 32, 48, or 64. This
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/x64/brgemm/capi/brgemm_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ status_t brgemm_t::get_B_pack_type(
brgemm_utils::set_isa_impl(&brg);
if (brg.isa_impl == cpu_isa_t::isa_undef) {
VCHECK_BRGEMM_STATUS(
status::invalid_arguments, false, "get_B_pack_type failed");
status::unimplemented, false, "get_B_pack_type failed");
}
const bool has_vnni_layout = brgemm_desc_t::is_b_data_layout_vnni(
dt_a, dt_b, /* brgattr.b_is_vnni = */ false, brg.isa_impl);
Expand Down

0 comments on commit e320df4

Please sign in to comment.