Skip to content

Commit

Permalink
Docs and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
v-Golubev committed Nov 13, 2024
1 parent c0d352f commit 142bf9b
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ namespace ov {
namespace snippets {
namespace lowered {
namespace pass {

/**
* @class MHAParallelWAOptimizer
* @brief Optimizes the dynamic MHA execution increasing parallel work amount dy dividing Brgemm's "M" dimension to "parallel_m"
* and "kernel_m". Uses heuristics from snippets::pass::SplitDimensionM for dimension splitting.
* The optimizer performs the following steps:
* - Identifies applicable Brgemm operations within the LinearIR.
* - Finds parameters whose shapes and layouts need to be adjusted after the split.
* - Determines loops that should be adjusted.
*/
class MHAParallelWAOptimizer : public lowered::pass::RuntimeOptimizer {
public:
MHAParallelWAOptimizer() = default;
Expand Down
38 changes: 22 additions & 16 deletions src/common/snippets/include/snippets/runtime_configurator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,6 @@ class RuntimeConfigurator {
RuntimeConfigurator(std::shared_ptr<RuntimeConfig> c);
virtual ~RuntimeConfigurator() = default;

// Note that get_type_info_static and get_type_info are needed to mimic OPENVINO_RTTI interface,
// so the standard OPENVINO_RTTI(...) macros could be used in derived classes.
_OPENVINO_HIDDEN_METHOD static const ::ov::DiscreteTypeInfo& get_type_info_static() {
static ::ov::DiscreteTypeInfo type_info_static {"RuntimeConfigurator"};
type_info_static.hash();
return type_info_static;
}

virtual const DiscreteTypeInfo& get_type_info() const {
return get_type_info_static();
}

const char* get_type_name() const {
return get_type_info().name;
}

/**
* @brief Update RuntimeConfig based on new state of LinearIR and return its
* @param linear_ir LinearIR
Expand Down Expand Up @@ -111,6 +95,18 @@ class RuntimeConfigurator {
const std::vector<size_t>& get_io_data_sizes() const { return m_io_data_sizes; }
const std::map<size_t, std::set<lowered::BufferExpressionPtr>>& get_dynamic_buffer_clusters() const { return m_dynamic_buffer_clusters; }

/**
* @brief Computes the offsets for each dimension of a tensor shape.
*
* This function calculates the offsets for each dimension of a tensor shape, which represent the distance between
* consecutive elements of the corresponding dimension. If a dimension size is 1, the next dimension starts
* immediately, and the stride is 0.
* @param shape The shape of the tensor.
* @param offsets The offsets which should be updated.
* @param offsets_size Requested offsets size vector.
* @param dim_step The initial step size for the dimensions.
* @param idx_stride Defines the number of dimensions that should be skipped in the offsets vector.
*/
static void compute_offsets(const ov::snippets::VectorDims& shape,
ov::snippets::VectorDims& offsets,
size_t offsets_size,
Expand All @@ -122,13 +118,23 @@ class RuntimeConfigurator {
std::vector<int64_t> ptr_increments;
std::vector<int64_t> finalization_offsets;
};
/**
* @brief Retrieves the runtime parameters for a given UnifiedLoopInfo.
* @param unified_loop_info The UnifiedLoopInfo for which the runtime parameters are to be retrieved.
* @return A LoopInfoRuntimeParams object containing the runtime parameters.
*/
static UnifiedLoopInfoRtParams get_loop_runtime_params(const lowered::UnifiedLoopInfoPtr& unified_loop_info);
using LoopInfoRuntimeParamsMap = std::unordered_map<lowered::UnifiedLoopInfoPtr, UnifiedLoopInfoRtParams>;
/**
* @brief Update Loop informations in LinearIR: Unified and ExpandedLoopInfo
* @param linear_ir LinearIR
*/
static void update_loop_info(const lowered::LinearIRCPtr& linear_ir);
/**
* @brief Updates the ExpandedLoopInfo based on the initialized runtime parameters.
* @param expanded_loop_info The ExpandedLoopInfo to be updated.
* @param initialized_info_map A map containing the initialized runtime parameters for UnifiedLoopInfo.
*/
static void update_expanded_loop_info(const lowered::ExpandedLoopInfoPtr& expanded_loop_info,
LoopInfoRuntimeParamsMap& initializated_info_map);
/**
Expand Down
5 changes: 5 additions & 0 deletions src/common/snippets/include/snippets/runtime_optimizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace ov {
namespace snippets {
namespace lowered {
namespace pass {
/**
* @class RuntimeOptimizer
* @brief Base class for runtime optimizers that operate on LinearIR and RuntimeConfigurator during
* RuntimeConfigurator::update stage.
*/
class RuntimeOptimizer : public ConstPass {
public:
RuntimeOptimizer() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
namespace ov {
namespace intel_cpu {

/**
* @class BrgemmCopyBLoopPortsAdjuster
* @brief A runtime optimizer that adjusts blocked loops parameters for Brgemm operations which require repacking.
*/
class BrgemmCopyBLoopPortsAdjuster : public ov::snippets::lowered::pass::RuntimeOptimizer {
public:
BrgemmCopyBLoopPortsAdjuster() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class CPURuntimeConfig : public ov::snippets::RuntimeConfig {

class CPURuntimeConfigurator : public ov::snippets::RuntimeConfigurator {
public:
OPENVINO_RTTI("CPURuntimeConfigurator", "0", ov::snippets::RuntimeConfigurator)
CPURuntimeConfigurator();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ namespace ov {
namespace intel_cpu {

class CPURuntimeConfigurator;
/**
* @class BrgemmExternalRepackingAdjuster
* @brief A runtime optimizer that creates the memory descs for BRGEMM inputs which require external repacking.
* The generated memory descs are stored in the CPU runtime config.
*/
class BrgemmExternalRepackingAdjuster : public ov::snippets::lowered::pass::RuntimeOptimizer {
public:
BrgemmExternalRepackingAdjuster() = default;
Expand Down

0 comments on commit 142bf9b

Please sign in to comment.