Skip to content

Commit

Permalink
cpu: x64: reorder: add plain transpose reorder based on brgemm matmul…
Browse files Browse the repository at this point in the history
… reorder
  • Loading branch information
karasjoh000 authored and dzarukin committed Oct 16, 2024
1 parent 6bfb6a8 commit 3877097
Show file tree
Hide file tree
Showing 14 changed files with 402 additions and 157 deletions.
4 changes: 2 additions & 2 deletions src/cpu/reorder/cpu_reorder_comp_s8_s8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const impl_list_map_t &comp_s8_s8_impl_list_map() {
static const impl_list_map_t the_map = REG_REORDER_P({
// s8 -> s8
{{s8, s8, 2}, {
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_matrix_B_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_copy_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_t))
DNNL_AARCH64_ONLY(CPU_REORDER_INSTANCE(aarch64::jit_uni_reorder_t))
DNNL_NON_X64_ONLY(REG_SR(s8, oi, s8, OI4i16o4i, fmt_order::keep, spec::conv_req_comp))
Expand All @@ -49,7 +49,7 @@ const impl_list_map_t &comp_s8_s8_impl_list_map() {
}},
// s8 -> s8
{{s8, s8, 3}, {
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_matrix_B_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_copy_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_t))
DNNL_AARCH64_ONLY(CPU_REORDER_INSTANCE(aarch64::jit_uni_reorder_t))
DNNL_NON_X64_ONLY(REG_SR(s8, any, s8, wio, fmt_order::keep, spec::conv_req_comp))
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/reorder/cpu_reorder_regular_bf16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const impl_list_map_t &regular_bf16_impl_list_map() {
// bf16 ->
{{bf16, data_type::undef, 0}, {
CPU_REORDER_INSTANCE(rnn_weights_reorder_t<bf16, bf16>)
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_matrix_B_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_copy_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_direct_copy_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_blk_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_t))
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/reorder/cpu_reorder_regular_f16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const impl_list_map_t &regular_f16_impl_list_map() {
{{f16, data_type::undef, 0}, {
DNNL_AARCH64_ONLY(REG_SR_DIRECT_COPY(f16, f16))

DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_matrix_B_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_copy_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_direct_copy_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_blk_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_t))
Expand Down
6 changes: 4 additions & 2 deletions src/cpu/reorder/cpu_reorder_regular_f32_f32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const impl_list_map_t &regular_f32_f32_impl_list_map() {
static const impl_list_map_t the_map = REG_REORDER_P({
// f32 -> f32
{{f32, f32, 0}, {
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_matrix_B_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_copy_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_direct_copy_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_blk_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_t))
Expand All @@ -45,7 +45,7 @@ const impl_list_map_t &regular_f32_f32_impl_list_map() {
nullptr,
}},
{{f32, f32, 3}, {
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_matrix_B_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_copy_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_direct_copy_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_blk_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_t))
Expand Down Expand Up @@ -80,6 +80,7 @@ const impl_list_map_t &regular_f32_f32_impl_list_map() {
{{f32, f32, 4}, {
CPU_REORDER_INSTANCE(rnn_weights_reorder_t<f32, f32>)

DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_copy_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_direct_copy_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_blk_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_t))
Expand Down Expand Up @@ -132,6 +133,7 @@ const impl_list_map_t &regular_f32_f32_impl_list_map() {
{{f32, f32, 5}, {
CPU_REORDER_INSTANCE(rnn_weights_reorder_t<f32, f32>)

DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_copy_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_direct_copy_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_blk_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_t))
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/reorder/cpu_reorder_regular_s4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const impl_list_map_t &regular_s4_impl_list_map() {
nullptr,
}},
{{s4, f32, 0}, {
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_matrix_B_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_copy_reorder_t))
REG_SR(s4, any, f32, any, fmt_order::any, spec::reference)
nullptr,
}},
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/reorder/cpu_reorder_regular_s8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const impl_list_map_t &regular_s8_impl_list_map() {
{{s8, data_type::undef, 0}, {
CPU_REORDER_INSTANCE(rnn_weights_reorder_s8_t<s8>)
CPU_REORDER_INSTANCE(rnn_brgemm_weights_reorder_s8_t<s8, s8>)
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_matrix_B_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_copy_reorder_t))

DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_direct_copy_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_blk_reorder_t))
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/reorder/cpu_reorder_regular_u4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const impl_list_map_t &regular_u4_impl_list_map() {
nullptr,
}},
{{u4, f32, 0}, {
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_matrix_B_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_copy_reorder_t))
REG_SR(u4, any, f32, any, fmt_order::any, spec::reference)
nullptr,
}},
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/reorder/cpu_reorder_regular_u8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const impl_list_map_t &regular_u8_impl_list_map() {
static const impl_list_map_t the_map = REG_REORDER_P({
// u8 ->
{{u8, data_type::undef, 0}, {
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_matrix_B_reorder_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::brgemm_matmul_copy_reorder_t))

DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_uni_reorder_direct_copy_t))
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64::jit_blk_reorder_t))
Expand Down
4 changes: 2 additions & 2 deletions src/cpu/x64/brgemm/capi/brgemm_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ dnnl_transform::dnnl_transform(dim_t K, dim_t N, pack_type_t in_pack_type,

const auto in_tag = in_pack_type == pack_type::trans ? format_tag::ba
: format_tag::ab;
auto status = matmul::init_conf(bmc_, /* batch = */ 1, K_, N_, in_ld_,
out_ld_, in_dt_, out_dt_, in_tag);
auto status = matmul::init_conf(bmc_, /* batch = */ 1, /* M = */ 0, K_, N_,
in_ld_, out_ld_, in_dt_, out_dt_, in_tag);
assert(status == status::success);
if (status != status::success) return;

Expand Down
Loading

0 comments on commit 3877097

Please sign in to comment.