Skip to content

Commit

Permalink
Last comments
Browse files Browse the repository at this point in the history
  • Loading branch information
v-Golubev authored and a-sidorova committed Aug 12, 2024
1 parent f662fa8 commit e51cd8a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ class RuntimeConfigurator {
void init(const ov::snippets::lowered::LinearIRCPtr& linear_ir,
const std::vector<snippets::lowered::PortDescriptorPtr>& io_descs,
size_t in_num);
/**
* @brief Checks if optimizer is enabled
* @todo Ticket 148891: when RuntimeConfigurator::update will be rewritten on PassPipeline, this method should be removed
* We will not just register ParallelWAOptimizer in case if it is not needed
*/
bool enabled();
/**
* @brief Checks if the current master shape can be optimized, and if yes, updates all the necessary runtime information
* @param master_shape Master shape
Expand All @@ -174,7 +180,7 @@ class RuntimeConfigurator {
* @param in_num Number of inputs. It is needed to distinguish input and output shapes/layouts
* @return status if the optimization is applied
*/
bool optimize(ov::snippets::VectorDims& master_shape,
void optimize(ov::snippets::VectorDims& master_shape,
ov::snippets::RuntimeConfigurator::LoopInfoRuntimeParamsMap& map,
std::vector<ov::snippets::VectorDims>& shapes,
std::vector<std::vector<size_t>>& layouts,
Expand Down
16 changes: 11 additions & 5 deletions src/common/snippets/src/runtime_configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ void RuntimeConfigurator::update(const lowered::LinearIRCPtr& linear_ir) {
LoopInfoRuntimeParamsMap initialized_info;
auto shapes = extract_shapes();
auto layouts = extract_layouts();
if (m_optimizer.optimize(m_config->master_shape, initialized_info, shapes, layouts, m_in_num))
if (m_optimizer.enabled()) {
m_optimizer.optimize(m_config->master_shape, initialized_info, shapes, layouts, m_in_num);
update_tensor_rank(m_config->master_shape);
}

if (linear_ir->is_dynamic()) {
update_loop_info(linear_ir, initialized_info);
Expand Down Expand Up @@ -318,6 +320,7 @@ void RuntimeConfigurator::ParallelWAOptimizer::init(const lowered::LinearIRCPtr&
return;

concurrency = linear_ir->get_config().m_min_parallel_work_amount;
// At the moment this optimization is Brgemm related so there must be `unsqueezed_params`
unsqueezed_params = find_unsqueezed_params(linear_ir, brgemms);
OPENVINO_ASSERT(!unsqueezed_params.empty(), "unsqueezed_params mustn't be empty after initialization");
loops_to_split = find_loops_to_split(linear_ir, unsqueezed_params);
Expand All @@ -333,20 +336,23 @@ void RuntimeConfigurator::ParallelWAOptimizer::init(const lowered::LinearIRCPtr&
}
}

bool RuntimeConfigurator::ParallelWAOptimizer::optimize(VectorDims& master_shape,
bool RuntimeConfigurator::ParallelWAOptimizer::enabled() {
return !loops_to_split.empty();
}

void RuntimeConfigurator::ParallelWAOptimizer::optimize(VectorDims& master_shape,
RuntimeConfigurator::LoopInfoRuntimeParamsMap& map,
std::vector<ov::snippets::VectorDims>& shapes,
std::vector<std::vector<size_t>>& layouts,
size_t in_num) {
size_t new_batch_dim, new_kernel_dim;
if (loops_to_split.empty() || !SplitDimensionM::split(master_shape, concurrency, new_batch_dim, new_kernel_dim))
return false;
if (!SplitDimensionM::split(master_shape, concurrency, new_batch_dim, new_kernel_dim))
return;

update_master_shape(master_shape, new_batch_dim, new_kernel_dim);
update_split_loops_info(map, new_kernel_dim);
update_shapes(shapes, new_batch_dim, new_kernel_dim);
update_layouts(layouts);
return true;
}

void RuntimeConfigurator::ParallelWAOptimizer::update_master_shape(VectorDims& master_shape, size_t new_batch_dim, size_t new_kernel_dim) {
Expand Down

0 comments on commit e51cd8a

Please sign in to comment.