Skip to content

Commit

Permalink
[Snippets][CPU] Applied Ivan comment
Browse files Browse the repository at this point in the history
  • Loading branch information
a-sidorova committed Jan 31, 2025
1 parent eb2fb67 commit 15dadd5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void BrgemmBaseKernelExecutor::update_config(const ov::snippets::lowered::Expres
OV_CPU_JIT_EMITTER_ASSERT(brgemm_node, "Got invalid node type in update_config");
// In case of data repacking LDB is chosen in accordance with repacking buffer size
if (with_repacking(brgemm_node->get_type())) {
LDB = DIM_CAST(brgemm_utils::repacking::compute_LDB(LDB, brgemm_node->get_input_element_type(1)));
LDB = DIM_CAST(brgemm_utils::repacking::compute_repacked_n_dim(LDB, brgemm_node->get_input_element_type(1)));
}

config.update(DIM_CAST(M), DIM_CAST(N), DIM_CAST(K), LDA, LDB, LDC, beta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ void BrgemmCopyBKernelExecutor::update_config(const ov::snippets::lowered::Expre
init(N_dim, N_blk, 0);

const auto& brg_weight_etype = expr->get_node()->get_input_element_type(0);
const auto LDB = brgemm_utils::repacking::compute_LDB(N_dim, brg_weight_etype);
const auto LDB = brgemm_utils::repacking::compute_repacked_n_dim(N_dim, brg_weight_etype);
const auto copy_B_wei_stride =
ov::snippets::utils::get_dim_stride(expr->get_input_port(0), config.is_transposed_B() ? 0 : 1) *
brg_weight_etype.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,6 @@ template <
inline T compute_repacked_n_dim(T n, const ov::element::Type& precision) {
return ov::snippets::utils::rnd_up(n, static_cast<T>(compute_inner_n_block(precision)));
}
/**
* @brief Computes leading dimension (LDB) which must be used in brgemm and brgemm_copy_b emitters
* @param n_block N block size shared between BrgemmCPU and BrgemmCopyB node
* @param precision tensor precision
*/
template <
typename T,
typename = typename std::enable_if<(std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value), bool>::type>
inline T compute_LDB(T n_block, const ov::element::Type& precision) {
return compute_repacked_n_dim(n_block, precision);
}
/**
* @brief Retrieves the expression pointer for the brgemm_copy_b expression corresponding to the given BrgemmCPU
* expression.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ bool pass::AdjustBrgemmCopyBLoopPorts::update_loop_info(
// K blocking loop: account for zero padding
if (loop_port.get_dim_idx() == 1) {
const auto ptr_incr = loop_desc.ptr_increment;
const auto blocked_shape_ptr_inc = brgemm_utils::repacking::compute_LDB(ptr_incr, precision);
const auto blocked_shape_ptr_inc =
brgemm_utils::repacking::compute_repacked_n_dim(ptr_incr, precision);
if (ptr_incr != 0 && ptr_incr != blocked_shape_ptr_inc) {
loop_desc.ptr_increment = blocked_shape_ptr_inc;
OPENVINO_ASSERT(loop_desc.finalization_offset % ptr_incr == 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void BrgemmExternalRepackingAdjuster::update_kernel(const RepackExecutorPtr& exe
auto config = static_cast<BrgemmCopyBKernelConfig*>(generic_config.get());
const auto idx = config->is_transposed_B() ? 0 : 1;
const auto copy_wei_stride = ov::snippets::utils::get_dim_in_stride(shape, layout, idx) * prc.size();
config->update(N, N, K, K, copy_wei_stride, brgemm_utils::repacking::compute_LDB(N, prc));
const auto LDB = brgemm_utils::repacking::compute_repacked_n_dim(N, prc);
config->update(N, N, K, K, copy_wei_stride, LDB);
executor->update_by_config(*config);
}

Expand Down

0 comments on commit 15dadd5

Please sign in to comment.