forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into river/capi_add_status_for_wait_for
- Loading branch information
Showing
81 changed files
with
1,979 additions
and
832 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/common/snippets/include/snippets/pass/extract_constants.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "subgraph_pass.hpp" | ||
|
||
namespace ov { | ||
namespace snippets { | ||
namespace pass { | ||
|
||
/** | ||
* @interface ExtractConstants | ||
* @brief Moves up Constants which aren't scalars outside of the Subgraph's body and replaces them with Parameters inside body | ||
* @ingroup snippets | ||
*/ | ||
class ExtractConstants: public CommonOptimizations::SubgraphPass { | ||
public: | ||
OPENVINO_RTTI("ExtractConstants", "0"); | ||
ExtractConstants() = default; | ||
|
||
bool run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgraph) override; | ||
}; | ||
|
||
|
||
} // namespace pass | ||
} // namespace snippets | ||
} // namespace ov |
29 changes: 29 additions & 0 deletions
29
src/common/snippets/include/snippets/pass/extract_unsupported_transposes.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "subgraph_pass.hpp" | ||
|
||
namespace ov { | ||
namespace snippets { | ||
namespace pass { | ||
|
||
/** | ||
* @interface ExtractUnsupportedTransposes | ||
* @brief Moves up unsupported Transposes on Parameter outputs from body | ||
* @ingroup snippets | ||
*/ | ||
class ExtractUnsupportedTransposes: public CommonOptimizations::SubgraphPass { | ||
public: | ||
OPENVINO_RTTI("ExtractUnsupportedTransposes", "0"); | ||
ExtractUnsupportedTransposes() = default; | ||
|
||
bool run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgraph) override; | ||
}; | ||
|
||
|
||
} // namespace pass | ||
} // namespace snippets | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/common/snippets/include/snippets/pass/split_dimension_m.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "subgraph_pass.hpp" | ||
|
||
namespace ov { | ||
namespace snippets { | ||
namespace pass { | ||
|
||
/** | ||
* @interface SplitDimensionM | ||
* @brief Inserts Reshape nodes before inputs and after outputs of Subgraphs with MatMul inside | ||
* to split dimension M for MatMuls. It allows to increase work amount for parallelism | ||
* @ingroup snippets | ||
*/ | ||
class SplitDimensionM: public CommonOptimizations::SubgraphPass { | ||
public: | ||
OPENVINO_RTTI("SplitDimensionM", "0"); | ||
SplitDimensionM(size_t concurrency) : m_concurrency(concurrency) {} | ||
|
||
bool run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgraph) override; | ||
|
||
// Return True if the MatMul node is supported by this optimization | ||
static bool is_supported_matmul(const std::shared_ptr<const ov::Node>& node); | ||
// Returns True if parallelism work amount (concurrency) can be increased by this optimization | ||
static bool can_be_optimized(const std::shared_ptr<const ov::Node>& node, size_t concurrency); | ||
|
||
private: | ||
static std::shared_ptr<ov::op::v0::MatMul> get_matmul(const std::shared_ptr<op::Subgraph>& subgraph); | ||
static std::pair<size_t, size_t> get_splited_dimensions(size_t batch_dim, size_t m_dim, size_t optimal_parallelism_work_amount); | ||
static bool split(const ov::Shape& shape, size_t optimal_parallelism_work_amount, size_t& batch_m_dim, size_t& new_m_dim); | ||
|
||
void reshape_subgraph(const std::shared_ptr<op::Subgraph>& subgraph, const ov::Shape& shape, size_t batch_m_dim, size_t new_m_dim); | ||
|
||
size_t m_concurrency; | ||
}; | ||
|
||
|
||
} // namespace pass | ||
} // namespace snippets | ||
} // namespace ov |
49 changes: 49 additions & 0 deletions
49
src/common/snippets/include/snippets/pass/subgraph_manager.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
#include <typeinfo> | ||
#include <vector> | ||
|
||
#include "snippets/pass/common_optimizations.hpp" | ||
|
||
#include "snippets/pass/subgraph_pass.hpp" | ||
#include "snippets/op/subgraph.hpp" | ||
|
||
namespace ov { | ||
namespace snippets { | ||
namespace pass { | ||
/** | ||
* @brief Manager class allows to manage transformation passes (SubgraphPasses) on Subgraph ops. | ||
* See SubgraphPasses description for more details. | ||
* It's light version of ov::Manager implementation the purpose of which is to change only Subgraph as separate node in model. | ||
* @ingroup snippets | ||
*/ | ||
class CommonOptimizations::SubgraphManager { | ||
public: | ||
SubgraphManager() = default; | ||
|
||
/// @brief Register given transformation class type to execution list | ||
/// @return shared_ptr to the transformation instance | ||
template <typename T, class... Args> | ||
std::shared_ptr<T> register_pass(Args&&... args) { | ||
static_assert(std::is_base_of<SubgraphPass, T>::value, "pass not derived from SubgraphPass base"); | ||
auto pass = std::make_shared<T>(std::forward<Args>(args)...); | ||
m_pass_list.push_back(std::static_pointer_cast<SubgraphPass>(pass)); | ||
return pass; | ||
} | ||
|
||
/// @brief Runs registered transformations on a given model | ||
/// @param subgraph Input model | ||
/// @return Returns true if the model was changed by transformations, false otherwise. | ||
bool run_passes(std::shared_ptr<ov::snippets::op::Subgraph> subgraph); | ||
|
||
protected: | ||
std::vector<std::shared_ptr<SubgraphPass>> m_pass_list; | ||
}; | ||
} // namespace pass | ||
} // namespace snippets | ||
} // namespace ov |
45 changes: 45 additions & 0 deletions
45
src/common/snippets/include/snippets/pass/subgraph_pass.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <typeinfo> | ||
|
||
#include "snippets/pass/common_optimizations.hpp" | ||
|
||
|
||
namespace ov { | ||
namespace snippets { | ||
namespace pass { | ||
|
||
/** | ||
* @brief Base class for Subgraph passes. | ||
* The pass runs on `Subgraph` op that allows users to transform | ||
* `Subgraph` as node and `body` of this `Subgraph` as model at the same time. | ||
* These passes may change `Subgraph` as node, its `body` and other ops around `Subgraph` in model. | ||
* To avoid unsafe changes of other ops in model, SubgraphPass is not derived from ov::Pass to avoid | ||
* registration to ov::Model | ||
* @ingroup snippets | ||
*/ | ||
class CommonOptimizations::SubgraphPass { | ||
public: | ||
SubgraphPass() = default; | ||
virtual ~SubgraphPass() = default; | ||
|
||
virtual bool run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgraph) = 0; | ||
|
||
void set_name(const std::string& name) { m_name = name; } | ||
std::string get_name() const { return m_name; } | ||
|
||
using type_info_t = DiscreteTypeInfo; | ||
virtual const type_info_t& get_type_info() const = 0; | ||
|
||
private: | ||
std::string m_name; | ||
}; | ||
|
||
|
||
} // namespace pass | ||
} // namespace snippets | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.