Added CC macro to transformations (#3795)
* Added CC macro to transformations * Fixed typo * Added MATCHER_SCOPE * Fixed review comments * Try to remove MATCHER_CALLBACK_SCOPE * Fixed matcher name * Fixed MATCHER_SCOPE * Added documentation * Fixed typo * Fixed CC for linux * Fixed names * Fixed docs * Fixed typo * FIxed comments * Add more CC macros
This commit is contained in:
parent
3baa305e0a
commit
e82018221c
@ -253,6 +253,13 @@ To eliminate operation, nGraph has special method that considers all limitations
|
||||
`replace_output_update_name` in case of successful replacement it automatically preserves friendly name and runtime info.
|
||||
|
||||
|
||||
## Transformation conditional compilation
|
||||
|
||||
Transformation library has two internal macros to support conditional compilation feature.
|
||||
|
||||
* `MATCHER_SCOPE(region)` - allows to disable the MatcherPass if matcher isn't used. The region name should be unique. This macro creates a local variable `matcher_name` which you should use as a matcher name.
|
||||
* `RUN_ON_FUNCTION_SCOPE(region)` - allows to disable run_on_function pass if it isn't used. The region name should be unique.
|
||||
|
||||
## Transformation writing essentials <a name="transformation_writing_essentials"></a>
|
||||
|
||||
When developing a transformation, you need to follow these transformation rules:
|
||||
|
@ -81,12 +81,7 @@ bool ngraph::pass::ConvertOpSet1ToLegacy::run_on_function(std::shared_ptr<ngraph
|
||||
manager.register_pass<ngraph::pass::ConstantFolding>();
|
||||
|
||||
// Convolution/Deconvolution/FullyConnected fusions
|
||||
auto convert_convolutions = manager.register_pass<ngraph::pass::GraphRewrite>();
|
||||
convert_convolutions->add_matcher<ngraph::pass::ConvertConvolution>();
|
||||
convert_convolutions->add_matcher<ngraph::pass::ConvertGroupConvolution>();
|
||||
convert_convolutions->add_matcher<ngraph::pass::ConvertDeconvolution>();
|
||||
convert_convolutions->add_matcher<ngraph::pass::ConvertGroupDeconvolution>();
|
||||
convert_convolutions->set_name("ngraph::pass::ConvertConvolutions");
|
||||
manager.register_pass<ngraph::pass::ConvertConvolutions>();
|
||||
|
||||
// Convolution/Deconvolution/FullyConnected fusions
|
||||
auto fusion = manager.register_pass<ngraph::pass::GraphRewrite>();
|
||||
|
@ -295,4 +295,4 @@ ngraph::pass::ConvertPriorBoxClusteredToLegacy::ConvertPriorBoxClusteredToLegacy
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(unsqueeze, "ConvertPriorBoxClusteredToLegacy");
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ ie_add_vs_version_file(NAME ${TARGET_NAME}
|
||||
FILEDESCRIPTION "Inference Engine Transformations library")
|
||||
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC ${NGRAPH_LIBRARIES}
|
||||
PRIVATE openvino::itt ngraph::builder pugixml)
|
||||
PRIVATE openvino::conditional_compilation openvino::itt ngraph::builder pugixml)
|
||||
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${PUBLIC_HEADERS_DIR}
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
|
@ -48,37 +48,19 @@ public:
|
||||
class ngraph::pass::ConvertReduceMeanToPooling: public ConvertReduceBase {
|
||||
public:
|
||||
NGRAPH_RTTI_DECLARATION;
|
||||
ConvertReduceMeanToPooling() {
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(
|
||||
ngraph::pattern::wrap_type<opset1::ReduceMean>({pattern::any_input(pattern::has_static_shape()),
|
||||
pattern::wrap_type<opset1::Constant>()},
|
||||
pattern::has_static_shape()), "ConvertReduceMean");
|
||||
register_matcher(m, convert_reduce_to_pooling<opset1::ReduceMean>());
|
||||
}
|
||||
ConvertReduceMeanToPooling();
|
||||
};
|
||||
|
||||
class ngraph::pass::ConvertReduceMaxToPooling: public ConvertReduceBase {
|
||||
public:
|
||||
NGRAPH_RTTI_DECLARATION;
|
||||
ConvertReduceMaxToPooling() {
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(
|
||||
ngraph::pattern::wrap_type<opset1::ReduceMax>({pattern::any_input(pattern::has_static_shape()),
|
||||
pattern::wrap_type<opset1::Constant>()},
|
||||
pattern::has_static_shape()), "ConvertReduceMax");
|
||||
register_matcher(m, convert_reduce_to_pooling<opset1::ReduceMax>());
|
||||
}
|
||||
ConvertReduceMaxToPooling();
|
||||
};
|
||||
|
||||
class ngraph::pass::ConvertReduceSumToPooling: public ConvertReduceBase {
|
||||
public:
|
||||
NGRAPH_RTTI_DECLARATION;
|
||||
ConvertReduceSumToPooling() {
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(
|
||||
ngraph::pattern::wrap_type<opset1::ReduceSum>({pattern::any_input(pattern::has_static_shape()),
|
||||
pattern::wrap_type<opset1::Constant>()},
|
||||
pattern::has_static_shape()), "ConvertReduceSum");
|
||||
register_matcher(m, convert_reduce_to_pooling<opset1::ReduceSum>());
|
||||
}
|
||||
ConvertReduceSumToPooling();
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
71
inference-engine/src/transformations/src/itt.hpp
Normal file
71
inference-engine/src/transformations/src/itt.hpp
Normal file
@ -0,0 +1,71 @@
|
||||
//*****************************************************************************
|
||||
// Copyright 2017-2020 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//*****************************************************************************
|
||||
|
||||
/**
|
||||
* @brief Defines openvino domains for tracing
|
||||
* @file itt.hpp
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <openvino/cc/selective_build.h>
|
||||
#include <openvino/itt.hpp>
|
||||
|
||||
namespace ngraph {
|
||||
namespace pass {
|
||||
namespace itt {
|
||||
namespace domains {
|
||||
OV_ITT_DOMAIN(IETransform);
|
||||
} // namespace domains
|
||||
} // namespace itt
|
||||
} // namespace pass
|
||||
} // namespace ngraph
|
||||
|
||||
OV_CC_DOMAINS(ngraph_pass);
|
||||
OV_CC_DOMAINS(internal_op);
|
||||
|
||||
/*
|
||||
* RUN_ON_FUNCTION_SCOPE macro allows to disable the run_on_function pass
|
||||
* MATCHER_SCOPE macro allows to disable the MatcherPass if matcher isn't applied
|
||||
* INTERNAL_OP_SCOPE macro allows to disable parts of internal nGraph operations if they are not used
|
||||
*/
|
||||
#if defined(SELECTIVE_BUILD_ANALYZER)
|
||||
#define RUN_ON_FUNCTION_SCOPE(region) OV_SCOPE(ngraph_pass, OV_CC_CAT(region, _run_on_function))
|
||||
#define MATCHER_SCOPE(region) \
|
||||
const std::string matcher_name(OV_CC_TOSTRING(region))
|
||||
|
||||
#define INTERNAL_OP_SCOPE(region) OV_SCOPE(internal_op, region)
|
||||
|
||||
#elif defined(SELECTIVE_BUILD)
|
||||
|
||||
#define MATCHER_SCOPE_(scope, region) \
|
||||
if (OV_CC_SCOPE_IS_ENABLED(OV_CC_CAT3(scope, _, region)) == 0) \
|
||||
throw ngraph::ngraph_error(std::string(OV_CC_TOSTRING(OV_CC_CAT3(scope, _, region))) + \
|
||||
" is disabled!")
|
||||
|
||||
#define MATCHER_SCOPE(region) \
|
||||
const std::string matcher_name(OV_CC_TOSTRING(region)); \
|
||||
if (OV_CC_SCOPE_IS_ENABLED(OV_CC_CAT3(ngraph_pass, _, region)) == 0) \
|
||||
return
|
||||
#define INTERNAL_OP_SCOPE(region) MATCHER_SCOPE_(internal_op, region)
|
||||
#define RUN_ON_FUNCTION_SCOPE(region) MATCHER_SCOPE_(ngraph_pass, OV_CC_CAT(region, _run_on_function))
|
||||
|
||||
#else
|
||||
#define MATCHER_SCOPE(region) \
|
||||
const std::string matcher_name(OV_CC_TOSTRING(region))
|
||||
#define INTERNAL_OP_SCOPE(region)
|
||||
#define RUN_ON_FUNCTION_SCOPE(region)
|
||||
#endif
|
@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "ngraph_ops/convolution_ie.hpp"
|
||||
#include "itt.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
@ -99,6 +100,7 @@ op::ConvolutionIE::ConvolutionIE(const Output<Node>& data_batch,
|
||||
}
|
||||
|
||||
void op::ConvolutionIE::validate_and_infer_types() {
|
||||
INTERNAL_OP_SCOPE(ConvolutionIE_validate_and_infer_types);
|
||||
PartialShape data_batch_shape = get_input_partial_shape(0);
|
||||
PartialShape filters_shape = get_input_partial_shape(1);
|
||||
|
||||
@ -145,6 +147,7 @@ void op::ConvolutionIE::validate_and_infer_types() {
|
||||
}
|
||||
|
||||
shared_ptr<Node> op::ConvolutionIE::clone_with_new_inputs(const ngraph::OutputVector & new_args) const {
|
||||
INTERNAL_OP_SCOPE(ConvolutionIE_clone_with_new_inputs);
|
||||
if (new_args.size() == 2) {
|
||||
return make_shared<ConvolutionIE>(new_args.at(0),
|
||||
new_args.at(1),
|
||||
@ -172,6 +175,7 @@ shared_ptr<Node> op::ConvolutionIE::clone_with_new_inputs(const ngraph::OutputVe
|
||||
}
|
||||
|
||||
bool op::ConvolutionIE::visit_attributes(AttributeVisitor& visitor) {
|
||||
INTERNAL_OP_SCOPE(ConvolutionIE_visit_attributes);
|
||||
visitor.on_attribute("strides", m_strides);
|
||||
visitor.on_attribute("dilations", m_dilations);
|
||||
visitor.on_attribute("pads_begin", m_pads_begin);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <ngraph/ops.hpp>
|
||||
#include "itt.hpp"
|
||||
|
||||
#include "ngraph_ops/deconvolution_ie.hpp"
|
||||
|
||||
@ -64,6 +65,7 @@ op::DeconvolutionIE::DeconvolutionIE(const Output<Node>& data,
|
||||
}
|
||||
|
||||
void op::DeconvolutionIE::validate_and_infer_types() {
|
||||
INTERNAL_OP_SCOPE(DeconvolutionIE_validate_and_infer_types);
|
||||
// To calculate output shape we use opset1::GroupConvolutionBackPropData
|
||||
// but before we need to reshape weights from I(G*O)YX to GIOYX
|
||||
auto weights = input_value(1);
|
||||
@ -89,6 +91,7 @@ void op::DeconvolutionIE::validate_and_infer_types() {
|
||||
}
|
||||
|
||||
shared_ptr<Node> op::DeconvolutionIE::clone_with_new_inputs(const ngraph::OutputVector &new_args) const {
|
||||
INTERNAL_OP_SCOPE(DeconvolutionIE_clone_with_new_inputs);
|
||||
if (new_args.size() == 2) {
|
||||
return make_shared<DeconvolutionIE>(new_args.at(0),
|
||||
new_args.at(1),
|
||||
@ -117,10 +120,11 @@ shared_ptr<Node> op::DeconvolutionIE::clone_with_new_inputs(const ngraph::Output
|
||||
}
|
||||
|
||||
bool op::DeconvolutionIE::visit_attributes(AttributeVisitor& visitor) {
|
||||
visitor.on_attribute("strides", m_strides);
|
||||
visitor.on_attribute("dilations", m_dilations);
|
||||
visitor.on_attribute("pads_begin", m_pads_begin);
|
||||
visitor.on_attribute("pads_end", m_pads_end);
|
||||
visitor.on_attribute("group", m_group);
|
||||
return true;
|
||||
INTERNAL_OP_SCOPE(DeconvolutionIE_visit_attributes);
|
||||
visitor.on_attribute("strides", m_strides);
|
||||
visitor.on_attribute("dilations", m_dilations);
|
||||
visitor.on_attribute("pads_begin", m_pads_begin);
|
||||
visitor.on_attribute("pads_end", m_pads_end);
|
||||
visitor.on_attribute("group", m_group);
|
||||
return true;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <ngraph/opsets/opset5.hpp>
|
||||
#include "ngraph_ops/nms_ie_internal.hpp"
|
||||
#include "itt.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
@ -40,6 +41,7 @@ op::internal::NonMaxSuppressionIEInternal::NonMaxSuppressionIEInternal(const Out
|
||||
}
|
||||
|
||||
std::shared_ptr<Node> op::internal::NonMaxSuppressionIEInternal::clone_with_new_inputs(const ngraph::OutputVector &new_args) const {
|
||||
INTERNAL_OP_SCOPE(internal_NonMaxSuppressionIEInternal_clone_with_new_inputs);
|
||||
if (new_args.size() == 6) {
|
||||
return make_shared<NonMaxSuppressionIEInternal>(new_args.at(0), new_args.at(1), new_args.at(2), new_args.at(3),
|
||||
new_args.at(4), new_args.at(5), m_center_point_box, m_sort_result_descending,
|
||||
@ -53,6 +55,7 @@ std::shared_ptr<Node> op::internal::NonMaxSuppressionIEInternal::clone_with_new_
|
||||
}
|
||||
|
||||
bool op::internal::NonMaxSuppressionIEInternal::visit_attributes(AttributeVisitor& visitor) {
|
||||
INTERNAL_OP_SCOPE(internal_NonMaxSuppressionIEInternal_visit_attributes);
|
||||
visitor.on_attribute("center_point_box", m_center_point_box);
|
||||
visitor.on_attribute("sort_result_descending", m_sort_result_descending);
|
||||
visitor.on_attribute("output_type", m_output_type);
|
||||
@ -79,6 +82,7 @@ int64_t op::internal::NonMaxSuppressionIEInternal::max_boxes_output_from_input()
|
||||
}
|
||||
|
||||
void op::internal::NonMaxSuppressionIEInternal::validate_and_infer_types() {
|
||||
INTERNAL_OP_SCOPE(internal_NonMaxSuppressionIEInternal_validate_and_infer_types);
|
||||
const auto boxes_ps = get_input_partial_shape(boxes_port);
|
||||
const auto scores_ps = get_input_partial_shape(scores_port);
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <set>
|
||||
|
||||
#include "transformations/common_optimizations/algebraic_simplification.hpp"
|
||||
#include "itt.hpp"
|
||||
|
||||
#include <ngraph/log.hpp>
|
||||
#include <ngraph/opsets/opset2.hpp>
|
||||
@ -234,6 +235,7 @@ static bool replace_transpose_with_reshape(shared_ptr<Node> transpose) {
|
||||
}
|
||||
|
||||
bool pass::AlgebraicSimplification::run_on_function(shared_ptr<Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(AlgebraicSimplification);
|
||||
static const unordered_map<NodeTypeInfo, function<bool(shared_ptr<Node>)>> ops_to_simplifiers =
|
||||
{{opset3::Gather::type_info, simplify_gather},
|
||||
{opset2::ShapeOf::type_info, simplify_gather_shapeof},
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/broadcast_elementwise_fusion.hpp"
|
||||
|
||||
#include <ngraph/opsets/opset5.hpp>
|
||||
@ -51,6 +52,7 @@ bool can_eliminate_broadcast(const ngraph::Output<ngraph::Node>& eltwise,
|
||||
}
|
||||
|
||||
ngraph::pass::BroadcastElementwiseFusion::BroadcastElementwiseFusion() {
|
||||
MATCHER_SCOPE(BroadcastElementwiseFusion);
|
||||
auto broadcast_input = pattern::any_input();
|
||||
auto broadcast = pattern::wrap_type<ngraph::opset5::Broadcast>({broadcast_input, pattern::any_input()});
|
||||
auto eltwise_input = pattern::any_input();
|
||||
@ -76,6 +78,6 @@ ngraph::pass::BroadcastElementwiseFusion::BroadcastElementwiseFusion() {
|
||||
return false;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(eltwise, "BroadcastElementwiseFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(eltwise, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -11,11 +11,13 @@
|
||||
#include <ngraph/opsets/opset5.hpp>
|
||||
#include <ngraph/rt_info.hpp>
|
||||
#include <ngraph/pattern/op/wrap_type.hpp>
|
||||
#include "itt.hpp"
|
||||
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ClampFusion, "ClampFusion", 0);
|
||||
|
||||
ngraph::pass::ClampFusion::ClampFusion() {
|
||||
MATCHER_SCOPE(ClampFusion);
|
||||
auto data_pattern = ngraph::pattern::any_input();
|
||||
auto min_const_pattern = ngraph::pattern::wrap_type<opset5::Constant>();
|
||||
auto max_const_pattern = ngraph::pattern::wrap_type<opset5::Constant>();
|
||||
@ -53,6 +55,6 @@ ngraph::pass::ClampFusion::ClampFusion() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(min_pattern, "ClampFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(min_pattern, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "transformations/init_node_info.hpp"
|
||||
#include "transformations/itt.hpp"
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/algebraic_simplification.hpp"
|
||||
#include "transformations/common_optimizations/broadcast_elementwise_fusion.hpp"
|
||||
#include "transformations/common_optimizations/nop_elimination.hpp"
|
||||
@ -55,6 +55,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::CommonOptimizations, "CommonOptimizations", 0);
|
||||
|
||||
bool ngraph::pass::CommonOptimizations::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(CommonOptimizations);
|
||||
ngraph::pass::Manager manager(get_pass_config());
|
||||
|
||||
// This pass must be called first in pipeline
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#include <ngraph/opsets/opset1.hpp>
|
||||
#include <ngraph/rt_info.hpp>
|
||||
@ -16,6 +17,7 @@
|
||||
#include <ngraph_ops/deconvolution_ie.hpp>
|
||||
|
||||
#include <transformations/utils/utils.hpp>
|
||||
#include "itt.hpp"
|
||||
|
||||
using namespace ngraph;
|
||||
|
||||
@ -65,127 +67,139 @@ bool IsConvInLowPrecision(const std::shared_ptr<Conv>& conv) {
|
||||
}
|
||||
|
||||
template <class Conv>
|
||||
ngraph::matcher_pass_callback get_callback() {
|
||||
ngraph::matcher_pass_callback callback = [](ngraph::pattern::Matcher &m) {
|
||||
auto eltwise = m.get_match_root();
|
||||
bool conv_callback(ngraph::pattern::Matcher &m) {
|
||||
auto eltwise = m.get_match_root();
|
||||
|
||||
std::shared_ptr<ngraph::opset1::Constant> m_const;
|
||||
std::shared_ptr<Conv> m_conv;
|
||||
// FIXME: use auto [m_conv, m_const] when C++17 is available
|
||||
std::tie(m_conv, m_const) = parse_eltwise_inputs<Conv, ngraph::opset1::Constant>(eltwise);
|
||||
if (!m_conv || !m_const) {
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<ngraph::opset1::Constant> m_const;
|
||||
std::shared_ptr<Conv> m_conv;
|
||||
// FIXME: use auto [m_conv, m_const] when C++17 is available
|
||||
std::tie(m_conv, m_const) = parse_eltwise_inputs<Conv, ngraph::opset1::Constant>(eltwise);
|
||||
if (!m_conv || !m_const) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto & const_shape = m_const->get_shape();
|
||||
const auto & output_pshape = m_conv->get_output_partial_shape(0);
|
||||
const auto & const_shape = m_const->get_shape();
|
||||
const auto & output_pshape = m_conv->get_output_partial_shape(0);
|
||||
|
||||
if (output_pshape.rank().is_dynamic() || output_pshape[1].is_dynamic()) {
|
||||
return false;
|
||||
}
|
||||
if (output_pshape.rank().is_dynamic() || output_pshape[1].is_dynamic()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto & output_rank = output_pshape.rank().get_length();
|
||||
const auto & output_rank = output_pshape.rank().get_length();
|
||||
|
||||
const int64_t channel_dim = output_pshape[1].get_length();
|
||||
const int64_t channel_dim = output_pshape[1].get_length();
|
||||
|
||||
bool is_scalar_multiplier(shape_size(const_shape) == 1);
|
||||
bool is_scalar_multiplier(shape_size(const_shape) == 1);
|
||||
|
||||
// Check that constant has shape [1, C, 1, 1] where the number of 1 is equal to
|
||||
// the number of spatial dimensions or it's a scalar. That means that Constant
|
||||
// applied per channel and can be fused into Convolution weights.
|
||||
// Also Constant shape rank must be less or equal Convolution output shape
|
||||
// otherwise fusion will break output broadcasting
|
||||
auto expected_shape = Shape(output_rank, 1);
|
||||
expected_shape[1] = channel_dim;
|
||||
// Check that constant has shape [1, C, 1, 1] where the number of 1 is equal to
|
||||
// the number of spatial dimensions or it's a scalar. That means that Constant
|
||||
// applied per channel and can be fused into Convolution weights.
|
||||
// Also Constant shape rank must be less or equal Convolution output shape
|
||||
// otherwise fusion will break output broadcasting
|
||||
auto expected_shape = Shape(output_rank, 1);
|
||||
expected_shape[1] = channel_dim;
|
||||
|
||||
if (op::util::check_for_broadcast(expected_shape, const_shape)) {
|
||||
return false;
|
||||
}
|
||||
if (op::util::check_for_broadcast(expected_shape, const_shape)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Broadcast constant to [1, C, 1, 1] where the number of 1 is equal to
|
||||
// the number of weights dimensions.
|
||||
Output<Node> final_const = m_const;
|
||||
if (is_scalar_multiplier) {
|
||||
final_const = op::util::broadcastTo(m_const, expected_shape);
|
||||
}
|
||||
// Broadcast constant to [1, C, 1, 1] where the number of 1 is equal to
|
||||
// the number of weights dimensions.
|
||||
Output<Node> final_const = m_const;
|
||||
if (is_scalar_multiplier) {
|
||||
final_const = op::util::broadcastTo(m_const, expected_shape);
|
||||
}
|
||||
|
||||
if (final_const.get_shape().size() > 1) {
|
||||
final_const = std::make_shared<ngraph::opset1::Reshape>(final_const,
|
||||
ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{1}, {channel_dim}), true);
|
||||
}
|
||||
if (final_const.get_shape().size() > 1) {
|
||||
final_const = std::make_shared<ngraph::opset1::Reshape>(final_const,
|
||||
ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{1}, {channel_dim}), true);
|
||||
}
|
||||
|
||||
ngraph::Output<ngraph::Node> new_conv, new_weights, new_bias;
|
||||
if (std::dynamic_pointer_cast<ngraph::opset1::Add>(eltwise)) {
|
||||
// Fuse: ConvolutionIE/DeconvolutionIE->Add
|
||||
if (m_conv->inputs().size() == 2) {
|
||||
new_bias = final_const;
|
||||
} else {
|
||||
new_bias = std::make_shared<ngraph::opset1::Add>(final_const, m_conv->input_value(2));
|
||||
}
|
||||
new_conv = m_conv->clone_with_new_inputs({m_conv->input_value(0), m_conv->input_value(1), new_bias});
|
||||
} else if (std::is_same<Conv, ngraph::op::ConvolutionIE>() && std::dynamic_pointer_cast<ngraph::opset1::Multiply>(eltwise) &&
|
||||
!IsConvInLowPrecision(m_conv)) {
|
||||
// Fuse: ConvolutionIE->Mul
|
||||
auto weights_shape = m_conv->input(1).get_shape();
|
||||
|
||||
ngraph::Shape weights_const_shape(weights_shape.size(), 1);
|
||||
weights_const_shape[0] = weights_shape[0];
|
||||
|
||||
auto const_reshape = std::make_shared<ngraph::opset1::Reshape>(final_const,
|
||||
ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{weights_const_shape.size()}, weights_const_shape), true);
|
||||
new_weights = std::make_shared<ngraph::opset1::Multiply> (m_conv->input_value(1), const_reshape);
|
||||
if (m_conv->inputs().size() == 2) {
|
||||
new_conv = m_conv->clone_with_new_inputs({m_conv->input_value(0), new_weights});
|
||||
} else {
|
||||
auto bias_reshape = std::make_shared<ngraph::opset1::Reshape>(final_const,
|
||||
ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{1}, {weights_shape[0]}), true);
|
||||
new_bias = std::make_shared<ngraph::opset1::Multiply>(bias_reshape, final_const);
|
||||
new_conv = m_conv->clone_with_new_inputs({m_conv->input_value(0), new_weights, new_bias});
|
||||
}
|
||||
ngraph::Output<ngraph::Node> new_conv, new_weights, new_bias;
|
||||
if (std::dynamic_pointer_cast<ngraph::opset1::Add>(eltwise)) {
|
||||
// Fuse: ConvolutionIE/DeconvolutionIE->Add
|
||||
if (m_conv->inputs().size() == 2) {
|
||||
new_bias = final_const;
|
||||
} else {
|
||||
return false;
|
||||
new_bias = std::make_shared<ngraph::opset1::Add>(final_const, m_conv->input_value(2));
|
||||
}
|
||||
new_conv = m_conv->clone_with_new_inputs({m_conv->input_value(0), m_conv->input_value(1), new_bias});
|
||||
} else if (std::is_same<Conv, ngraph::op::ConvolutionIE>() && std::dynamic_pointer_cast<ngraph::opset1::Multiply>(eltwise) &&
|
||||
!IsConvInLowPrecision(m_conv)) {
|
||||
// Fuse: ConvolutionIE->Mul
|
||||
auto weights_shape = m_conv->input(1).get_shape();
|
||||
|
||||
ngraph::copy_runtime_info({m_conv, eltwise}, new_conv.get_node_shared_ptr());
|
||||
new_conv.get_node_shared_ptr()->set_friendly_name(m.get_match_root()->get_friendly_name());
|
||||
ngraph::replace_node(m.get_match_root(), new_conv.get_node_shared_ptr());
|
||||
return true;
|
||||
};
|
||||
return callback;
|
||||
ngraph::Shape weights_const_shape(weights_shape.size(), 1);
|
||||
weights_const_shape[0] = weights_shape[0];
|
||||
|
||||
auto const_reshape = std::make_shared<ngraph::opset1::Reshape>(final_const,
|
||||
ngraph::opset1::Constant::create(ngraph::element::i64,
|
||||
ngraph::Shape{weights_const_shape.size()},
|
||||
weights_const_shape),
|
||||
true);
|
||||
new_weights = std::make_shared<ngraph::opset1::Multiply> (m_conv->input_value(1), const_reshape);
|
||||
if (m_conv->inputs().size() == 2) {
|
||||
new_conv = m_conv->clone_with_new_inputs({m_conv->input_value(0), new_weights});
|
||||
} else {
|
||||
auto bias_reshape = std::make_shared<ngraph::opset1::Reshape>(final_const,
|
||||
ngraph::opset1::Constant::create(ngraph::element::i64,
|
||||
ngraph::Shape{1},
|
||||
{weights_shape[0]}),
|
||||
true);
|
||||
new_bias = std::make_shared<ngraph::opset1::Multiply>(bias_reshape, final_const);
|
||||
new_conv = m_conv->clone_with_new_inputs({m_conv->input_value(0), new_weights, new_bias});
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
ngraph::copy_runtime_info({m_conv, eltwise}, new_conv.get_node_shared_ptr());
|
||||
new_conv.get_node_shared_ptr()->set_friendly_name(m.get_match_root()->get_friendly_name());
|
||||
ngraph::replace_node(m.get_match_root(), new_conv.get_node_shared_ptr());
|
||||
return true;
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvAddFusion, "ConvAddFusion", 0);
|
||||
|
||||
ngraph::pass::ConvAddFusion::ConvAddFusion() {
|
||||
MATCHER_SCOPE(ConvAddFusion);
|
||||
auto conv = ngraph::pattern::wrap_type<op::ConvolutionIE>(pattern::consumers_count(1));
|
||||
auto add = ngraph::pattern::wrap_type<opset1::Add>({conv, std::make_shared<pattern::op::Label>()});
|
||||
|
||||
matcher_pass_callback callback = get_callback<op::ConvolutionIE>();
|
||||
matcher_pass_callback callback = [](ngraph::pattern::Matcher &m) {
|
||||
return conv_callback<op::ConvolutionIE>(m);
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(add, "ConvAddFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(add, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvMultiplyFusion, "ConvMultiplyFusion", 0);
|
||||
|
||||
ngraph::pass::ConvMultiplyFusion::ConvMultiplyFusion() {
|
||||
MATCHER_SCOPE(ConvMultiplyFusion);
|
||||
auto conv = ngraph::pattern::wrap_type<op::ConvolutionIE>(pattern::consumers_count(1));
|
||||
auto add = ngraph::pattern::wrap_type<opset1::Multiply>({conv, std::make_shared<pattern::op::Label>()});
|
||||
|
||||
matcher_pass_callback callback = get_callback<op::ConvolutionIE>();
|
||||
matcher_pass_callback callback = [](ngraph::pattern::Matcher &m) {
|
||||
return conv_callback<op::ConvolutionIE>(m);
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(add, "ConvMultiplyFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(add, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::DeconvAddFusion, "DeconvAddFusion", 0);
|
||||
|
||||
ngraph::pass::DeconvAddFusion::DeconvAddFusion() {
|
||||
MATCHER_SCOPE(DeconvAddFusion);
|
||||
auto conv = ngraph::pattern::wrap_type<op::DeconvolutionIE>(pattern::consumers_count(1));
|
||||
auto add = ngraph::pattern::wrap_type<opset1::Add>({conv, std::make_shared<pattern::op::Label>()});
|
||||
|
||||
matcher_pass_callback callback = get_callback<op::DeconvolutionIE>();
|
||||
matcher_pass_callback callback = [](ngraph::pattern::Matcher &m){
|
||||
return conv_callback<op::DeconvolutionIE>(m);
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(add, "DeconvAddFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(add, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "transformations/common_optimizations/conv_mul_fusion.hpp"
|
||||
#include "itt.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@ -18,6 +19,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvolutionMultiplyFusion, "ConvolutionMultiplyFusion", 0);
|
||||
|
||||
ngraph::pass::ConvolutionMultiplyFusion::ConvolutionMultiplyFusion() {
|
||||
MATCHER_SCOPE(ConvolutionMultiplyFusion);
|
||||
auto input = pattern::any_input();
|
||||
auto weights = ngraph::pattern::any_input(pattern::has_static_dim(0) /* has OIYX layout */);
|
||||
auto conv = ngraph::pattern::wrap_type<opset4::Convolution>({input, weights}, pattern::consumers_count(1));
|
||||
@ -74,13 +76,14 @@ ngraph::pass::ConvolutionMultiplyFusion::ConvolutionMultiplyFusion() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, "ConvolutionMultiplyFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::GroupConvolutionMultiplyFusion, "GroupConvolutionMultiplyFusion", 0);
|
||||
|
||||
ngraph::pass::GroupConvolutionMultiplyFusion::GroupConvolutionMultiplyFusion() {
|
||||
MATCHER_SCOPE(GroupConvolutionMultiplyFusion);
|
||||
auto input = pattern::any_input();
|
||||
auto weights = ngraph::pattern::any_input();//pattern::has_static_dims({0, 1}) /* has GOIYX layout */);
|
||||
auto conv = ngraph::pattern::wrap_type<opset4::GroupConvolution>({input, weights}, pattern::consumers_count(1));
|
||||
@ -139,13 +142,14 @@ ngraph::pass::GroupConvolutionMultiplyFusion::GroupConvolutionMultiplyFusion() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, "GroupConvolutionMultiplyFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvolutionBackpropDataMultiplyFusion, "ConvolutionBackpropDataMultiplyFusion", 0);
|
||||
|
||||
ngraph::pass::ConvolutionBackpropDataMultiplyFusion::ConvolutionBackpropDataMultiplyFusion() {
|
||||
MATCHER_SCOPE(ConvolutionBackpropDataMultiplyFusion);
|
||||
auto input = pattern::any_input();
|
||||
auto weights = ngraph::pattern::any_input(pattern::has_static_dim(1) /* has IOYX layout */);
|
||||
auto conv = ngraph::pattern::wrap_type<opset4::ConvolutionBackpropData>({input, weights}, pattern::consumers_count(1));
|
||||
@ -202,13 +206,14 @@ ngraph::pass::ConvolutionBackpropDataMultiplyFusion::ConvolutionBackpropDataMult
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, "ConvolutionBackpropDataMultiplyFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::GroupConvolutionBackpropDataMultiplyFusion, "GroupConvolutionBackpropDataMultiplyFusion", 0);
|
||||
|
||||
ngraph::pass::GroupConvolutionBackpropDataMultiplyFusion::GroupConvolutionBackpropDataMultiplyFusion() {
|
||||
MATCHER_SCOPE(GroupConvolutionBackpropDataMultiplyFusion);
|
||||
auto input = pattern::any_input();
|
||||
auto weights = ngraph::pattern::any_input(pattern::has_static_dims({0, 2}) /* has GIOYX layout */);
|
||||
auto conv = ngraph::pattern::wrap_type<opset4::GroupConvolutionBackpropData>({input, weights}, pattern::consumers_count(1));
|
||||
@ -267,6 +272,6 @@ ngraph::pass::GroupConvolutionBackpropDataMultiplyFusion::GroupConvolutionBackpr
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, "GroupConvolutionMultiplyFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "transformations/common_optimizations/convert_quantize_dequantize.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
#include "itt.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@ -57,6 +58,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertQuantizeDequantize, "ConvertQuantizeDequantize", 0);
|
||||
|
||||
ngraph::pass::ConvertQuantizeDequantize::ConvertQuantizeDequantize() {
|
||||
MATCHER_SCOPE(ConvertQuantizeDequantize);
|
||||
auto data_pattern = ngraph::pattern::any_input();
|
||||
auto input_low_pattern = ngraph::pattern::any_input();
|
||||
auto input_high_pattern = ngraph::pattern::any_input();
|
||||
@ -149,6 +151,6 @@ ngraph::pass::ConvertQuantizeDequantize::ConvertQuantizeDequantize() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul_pattern, "ConvertQuantizeDequantize");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul_pattern, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "transformations/common_optimizations/depth_to_space_fusion.hpp"
|
||||
#include "itt.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@ -84,6 +85,7 @@ bool check_depth_first(const ngraph::Shape& shape_input, const ngraph::Shape& sh
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::DepthToSpaceFusion, "DepthToSpaceFusion", 0);
|
||||
|
||||
ngraph::pass::DepthToSpaceFusion::DepthToSpaceFusion() {
|
||||
MATCHER_SCOPE(DepthToSpaceFusion);
|
||||
auto input0 = std::make_shared<pattern::op::Label>(element::f32, Shape{1, 1, 1, 1});
|
||||
auto input1 = std::make_shared<pattern::op::Label>(element::i64, Shape{4});
|
||||
auto input2 = std::make_shared<pattern::op::Label>(element::i64, Shape{4});
|
||||
@ -159,6 +161,6 @@ ngraph::pass::DepthToSpaceFusion::DepthToSpaceFusion() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(reshape_after, "DepthToSpaceFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(reshape_after, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/fq_mul_fusion.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
@ -15,29 +16,29 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::FakeQuantizeMulFusion, "FakeQuantizeMulFusion", 0);
|
||||
|
||||
namespace {
|
||||
std::pair<ngraph::Output<ngraph::Node>, ngraph::Output<ngraph::Node>>
|
||||
get_adjusted_output_range(ngraph::Output<ngraph::Node> out_low,
|
||||
ngraph::Output<ngraph::Node> out_high,
|
||||
ngraph::Output<ngraph::Node> multiplier) {
|
||||
const auto mul_out_low = std::make_shared<ngraph::opset4::Multiply>(out_low, multiplier);
|
||||
const auto mul_out_high = std::make_shared<ngraph::opset4::Multiply>(out_high, multiplier);
|
||||
copy_runtime_info({out_low.get_node_shared_ptr(), multiplier.get_node_shared_ptr()},
|
||||
mul_out_low);
|
||||
copy_runtime_info({out_high.get_node_shared_ptr(), multiplier.get_node_shared_ptr()},
|
||||
mul_out_high);
|
||||
std::pair<ngraph::Output<ngraph::Node>, ngraph::Output<ngraph::Node>>
|
||||
get_adjusted_output_range(ngraph::Output<ngraph::Node> out_low,
|
||||
ngraph::Output<ngraph::Node> out_high,
|
||||
ngraph::Output<ngraph::Node> multiplier) {
|
||||
const auto mul_out_low = std::make_shared<ngraph::opset4::Multiply>(out_low, multiplier);
|
||||
const auto mul_out_high = std::make_shared<ngraph::opset4::Multiply>(out_high, multiplier);
|
||||
copy_runtime_info({out_low.get_node_shared_ptr(), multiplier.get_node_shared_ptr()},
|
||||
mul_out_low);
|
||||
copy_runtime_info({out_high.get_node_shared_ptr(), multiplier.get_node_shared_ptr()},
|
||||
mul_out_high);
|
||||
|
||||
ngraph::OutputVector new_out_low(1), new_out_high(1);
|
||||
ngraph::OutputVector new_out_low(1), new_out_high(1);
|
||||
|
||||
if (!mul_out_low->constant_fold(new_out_low, {out_low, multiplier})) {
|
||||
new_out_low[0] = mul_out_low;
|
||||
if (!mul_out_low->constant_fold(new_out_low, {out_low, multiplier})) {
|
||||
new_out_low[0] = mul_out_low;
|
||||
}
|
||||
|
||||
if (!mul_out_high->constant_fold(new_out_high, {out_high, multiplier})) {
|
||||
new_out_high[0] = mul_out_high;
|
||||
}
|
||||
|
||||
return {new_out_low[0], new_out_high[0]};
|
||||
}
|
||||
|
||||
if (!mul_out_high->constant_fold(new_out_high, {out_high, multiplier})) {
|
||||
new_out_high[0] = mul_out_high;
|
||||
}
|
||||
|
||||
return {new_out_low[0], new_out_high[0]};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// This transformation multiplies the "output_low" and "output_high" inputs of the FQ operation
|
||||
@ -62,49 +63,49 @@ namespace {
|
||||
//
|
||||
|
||||
ngraph::pass::FakeQuantizeMulFusion::FakeQuantizeMulFusion() {
|
||||
const auto fq_output_low_p = ngraph::pattern::any_input();
|
||||
const auto fq_output_high_p = ngraph::pattern::any_input();
|
||||
MATCHER_SCOPE(FakeQuantizeMulFusion);
|
||||
const auto fq_output_low_p = ngraph::pattern::any_input();
|
||||
const auto fq_output_high_p = ngraph::pattern::any_input();
|
||||
|
||||
const auto fq_node_p = ngraph::pattern::wrap_type<opset4::FakeQuantize>(
|
||||
{ngraph::pattern::any_input(),
|
||||
ngraph::pattern::any_input(),
|
||||
ngraph::pattern::any_input(),
|
||||
fq_output_low_p,
|
||||
fq_output_high_p},
|
||||
pattern::consumers_count(1));
|
||||
const auto fq_node_p = ngraph::pattern::wrap_type<opset4::FakeQuantize>(
|
||||
{ngraph::pattern::any_input(),
|
||||
ngraph::pattern::any_input(),
|
||||
ngraph::pattern::any_input(),
|
||||
fq_output_low_p,
|
||||
fq_output_high_p},
|
||||
pattern::consumers_count(1));
|
||||
|
||||
const auto mul_constant_p = ngraph::pattern::wrap_type<opset4::Constant>();
|
||||
const auto mul_node_p = ngraph::pattern::wrap_type<opset4::Multiply>(
|
||||
{fq_node_p, mul_constant_p}, pattern::consumers_count(1));
|
||||
const auto mul_constant_p = ngraph::pattern::wrap_type<opset4::Constant>();
|
||||
const auto mul_node_p = ngraph::pattern::wrap_type<opset4::Multiply>(
|
||||
{fq_node_p, mul_constant_p}, pattern::consumers_count(1));
|
||||
|
||||
ngraph::matcher_pass_callback callback = [=](pattern::Matcher &m) {
|
||||
const auto& pattern_map = m.get_pattern_value_map();
|
||||
ngraph::matcher_pass_callback callback = [=](pattern::Matcher &m) {
|
||||
const auto& pattern_map = m.get_pattern_value_map();
|
||||
|
||||
const auto fq_node = pattern_map.at(fq_node_p).get_node_shared_ptr();
|
||||
const auto fq_node = pattern_map.at(fq_node_p).get_node_shared_ptr();
|
||||
|
||||
const auto original_output_low = pattern_map.at(fq_output_low_p);
|
||||
const auto original_output_high = pattern_map.at(fq_output_high_p);
|
||||
const auto mul_constant = pattern_map.at(mul_constant_p);
|
||||
const auto original_output_low = pattern_map.at(fq_output_low_p);
|
||||
const auto original_output_high = pattern_map.at(fq_output_high_p);
|
||||
const auto mul_constant = pattern_map.at(mul_constant_p);
|
||||
|
||||
const auto new_output_limits = get_adjusted_output_range(
|
||||
original_output_low, original_output_high, mul_constant);
|
||||
const auto new_output_limits = get_adjusted_output_range(
|
||||
original_output_low, original_output_high, mul_constant);
|
||||
|
||||
const auto new_fq_node = fq_node->clone_with_new_inputs({fq_node->input_value(0),
|
||||
fq_node->input_value(1),
|
||||
fq_node->input_value(2),
|
||||
new_output_limits.first,
|
||||
new_output_limits.second});
|
||||
const auto new_fq_node = fq_node->clone_with_new_inputs({fq_node->input_value(0),
|
||||
fq_node->input_value(1),
|
||||
fq_node->input_value(2),
|
||||
new_output_limits.first,
|
||||
new_output_limits.second});
|
||||
|
||||
const auto mul_node = pattern_map.at(mul_node_p).get_node_shared_ptr();
|
||||
replace_node(mul_node, new_fq_node);
|
||||
const auto mul_node = pattern_map.at(mul_node_p).get_node_shared_ptr();
|
||||
replace_node(mul_node, new_fq_node);
|
||||
|
||||
new_fq_node->set_friendly_name(fq_node->get_friendly_name());
|
||||
copy_runtime_info({fq_node, mul_node}, new_fq_node);
|
||||
new_fq_node->set_friendly_name(fq_node->get_friendly_name());
|
||||
copy_runtime_info({fq_node, mul_node}, new_fq_node);
|
||||
|
||||
return true;
|
||||
};
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul_node_p,
|
||||
"FakeQuantizeMulFusion");
|
||||
this->register_matcher(m, callback);
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul_node_p, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/fq_reshape_fusion.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::FakeQuantizeReshapeFusion, "FakeQuantizeReshapeFusion", 0);
|
||||
|
||||
ngraph::pass::FakeQuantizeReshapeFusion::FakeQuantizeReshapeFusion() {
|
||||
MATCHER_SCOPE(FakeQuantizeReshapeFusion);
|
||||
const auto fq_node_p = ngraph::pattern::wrap_type<opset4::FakeQuantize>(
|
||||
{ngraph::pattern::wrap_type<opset4::Constant>(), // for weights only
|
||||
ngraph::pattern::any_input(),
|
||||
@ -74,6 +76,6 @@ ngraph::pass::FakeQuantizeReshapeFusion::FakeQuantizeReshapeFusion() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(reshape_node_p, "FakeQuantizeReshapeFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(reshape_node_p, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/hsigmoid_fusion.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
@ -16,6 +17,7 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::HSigmoidFusion, "HSigmoidFusion", 0);
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::HSigmoidFusionWithReluDiv, "HSigmoidFusionWithReluDiv", 0);
|
||||
|
||||
ngraph::pass::HSigmoidFusionWithReluDiv::HSigmoidFusionWithReluDiv() {
|
||||
MATCHER_SCOPE(HSigmoidFusionWithReluDiv);
|
||||
// Replaces a sub-graph ((min(Relu(x + 3), 6)) / 6 with a HSigmoid op.
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto add_constant = ngraph::pattern::wrap_type<ngraph::opset4::Constant>();
|
||||
@ -55,13 +57,14 @@ ngraph::pass::HSigmoidFusionWithReluDiv::HSigmoidFusionWithReluDiv() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(div, "HSigmoidWithReluDivFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(div, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::HSigmoidFusionWithReluMul, "HSigmoidFusionWithReluMul", 0);
|
||||
|
||||
ngraph::pass::HSigmoidFusionWithReluMul::HSigmoidFusionWithReluMul() {
|
||||
MATCHER_SCOPE(HSigmoidFusionWithReluMul);
|
||||
// Replaces a sub-graph ((min(Relu(x + 3), 6)) * const(1/6) with a HSigmoid op.
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto add_constant = ngraph::pattern::wrap_type<ngraph::opset4::Constant>();
|
||||
@ -102,13 +105,14 @@ ngraph::pass::HSigmoidFusionWithReluMul::HSigmoidFusionWithReluMul() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul_second, "HSigmoidWithReluMulFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul_second, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::HSigmoidFusionWithoutRelu, "HSigmoidFusionWithoutRelu", 0);
|
||||
|
||||
ngraph::pass::HSigmoidFusionWithoutRelu::HSigmoidFusionWithoutRelu() {
|
||||
MATCHER_SCOPE(HSigmoidFusionWithoutRelu);
|
||||
// Replaces a sub-graph (min(max(x + 3, 0), 6) / 6) with a HSigmoid op.
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto add_constant = ngraph::pattern::wrap_type<ngraph::opset4::Constant>();
|
||||
@ -152,13 +156,14 @@ ngraph::pass::HSigmoidFusionWithoutRelu::HSigmoidFusionWithoutRelu() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(div, "HSigmoidWithoutReluFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(div, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::HSigmoidFusionWithClamp, "HSigmoidFusionWithClamp", 0);
|
||||
|
||||
ngraph::pass::HSigmoidFusionWithClamp::HSigmoidFusionWithClamp() {
|
||||
MATCHER_SCOPE(HSigmoidFusionWithClamp);
|
||||
// Replaces a sub-graph (Clamp(x + 3, 0, 6) * const(1/6)) with a HSigmoid op.
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto add_constant = ngraph::pattern::wrap_type<ngraph::opset4::Constant>();
|
||||
@ -193,6 +198,6 @@ ngraph::pass::HSigmoidFusionWithClamp::HSigmoidFusionWithClamp() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul_first, "HSigmoidWithClampFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul_first, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/hswish_fusion.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
@ -16,6 +17,7 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::HSwishFusion, "HSwishFusion", 0);
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::HSwishFusionWithReluDiv, "HSwishFusionWithReluDiv", 0);
|
||||
|
||||
ngraph::pass::HSwishFusionWithReluDiv::HSwishFusionWithReluDiv() {
|
||||
MATCHER_SCOPE(HSwishFusionWithReluDiv);
|
||||
// Replaces a sub-graph (x * (min(Relu(x + 3), 6)) / 6 with a HSwish op.
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto add_constant = ngraph::pattern::wrap_type<ngraph::opset4::Constant>();
|
||||
@ -60,13 +62,14 @@ ngraph::pass::HSwishFusionWithReluDiv::HSwishFusionWithReluDiv() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(div, "HSwishWithReluDivFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(div, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::HSwishFusionWithReluMul, "HSwishFusionWithReluMul", 0);
|
||||
|
||||
ngraph::pass::HSwishFusionWithReluMul::HSwishFusionWithReluMul() {
|
||||
MATCHER_SCOPE(HSwishFusionWithReluMul);
|
||||
// Replaces a sub-graph (x * (min(Relu(x + 3), 6)) * const(1/6) with a HSwish op.
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto add_constant = ngraph::pattern::wrap_type<ngraph::opset4::Constant>();
|
||||
@ -111,13 +114,14 @@ ngraph::pass::HSwishFusionWithReluMul::HSwishFusionWithReluMul() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul_second, "HSwishWithReluMulFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul_second, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::HSwishFusionWithoutRelu, "HSwishFusionWithoutRelu", 0);
|
||||
|
||||
ngraph::pass::HSwishFusionWithoutRelu::HSwishFusionWithoutRelu() {
|
||||
MATCHER_SCOPE(HSwishFusionWithoutRelu);
|
||||
// Replaces a sub-graph x * (min(max(x + 3, 0), 6) / 6) with a HSwish op.
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto add_constant = ngraph::pattern::wrap_type<ngraph::opset4::Constant>();
|
||||
@ -166,13 +170,14 @@ ngraph::pass::HSwishFusionWithoutRelu::HSwishFusionWithoutRelu() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, "HSwishWithoutReluFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::HSwishFusionWithClamp, "HSwishFusionWithClamp", 0);
|
||||
|
||||
ngraph::pass::HSwishFusionWithClamp::HSwishFusionWithClamp() {
|
||||
MATCHER_SCOPE(HSwishFusionWithClamp);
|
||||
// Replaces a sub-graph x * (Clamp(x + 3, 0, 6) * const(1/6)) with a HSwish op.
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto add_constant = ngraph::pattern::wrap_type<ngraph::opset4::Constant>();
|
||||
@ -211,6 +216,6 @@ ngraph::pass::HSwishFusionWithClamp::HSwishFusionWithClamp() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul_second, "HSwishWithClampFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul_second, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/lin_op_sequence_fusion.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -31,6 +32,7 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::LinOpSequenceFusion, "LinOpSequenceFusion",
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::AddMultiplyFusion, "AddMultiplyFusion", 0);
|
||||
|
||||
ngraph::pass::AddMultiplyFusion::AddMultiplyFusion() {
|
||||
MATCHER_SCOPE(AddMultiplyFusion);
|
||||
// Create Add->Multiply pattern where Add has exactly one consumer
|
||||
auto m_data = ngraph::pattern::any_input();
|
||||
auto m_add_constant = ngraph::pattern::wrap_type<opset3::Constant>();
|
||||
@ -70,13 +72,14 @@ ngraph::pass::AddMultiplyFusion::AddMultiplyFusion() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(m_mul, "AddMultiplyFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(m_mul, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::AddAddFusion, "AddAddFusion", 0);
|
||||
|
||||
ngraph::pass::AddAddFusion::AddAddFusion() {
|
||||
MATCHER_SCOPE(AddAddFusion);
|
||||
// Create Add->Add pattern where first Add has exactly one consumer
|
||||
auto m_data = ngraph::pattern::any_input();
|
||||
auto m_add1_constant = ngraph::pattern::wrap_type<opset3::Constant>();
|
||||
@ -104,13 +107,14 @@ ngraph::pass::AddAddFusion::AddAddFusion() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(m_add2, "AddAddFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(m_add2, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::MultiplyMultiplyFusion, "MultiplyMultiplyFusion", 0);
|
||||
|
||||
ngraph::pass::MultiplyMultiplyFusion::MultiplyMultiplyFusion() {
|
||||
MATCHER_SCOPE(MultiplyMultiplyFusion);
|
||||
// Create Multiply->Multiply pattern where first Multiply has exactly one consumer
|
||||
auto m_data = ngraph::pattern::any_input();
|
||||
auto m_mul1_constant = ngraph::pattern::wrap_type<opset3::Constant>();
|
||||
@ -138,6 +142,6 @@ ngraph::pass::MultiplyMultiplyFusion::MultiplyMultiplyFusion() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(m_mul2, "MultiplyMultiplyFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(m_mul2, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/mish_fusion.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::MishFusion, "MishFusion", 0);
|
||||
|
||||
ngraph::pass::MishFusion::MishFusion() {
|
||||
MATCHER_SCOPE(MishFusion);
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto exp = std::make_shared<ngraph::opset4::Exp>(input);
|
||||
auto add = std::make_shared<ngraph::opset4::Add>(exp, ngraph::pattern::wrap_type<ngraph::opset4::Constant>());
|
||||
@ -37,6 +39,6 @@ ngraph::pass::MishFusion::MishFusion() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, "MishFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, matcher_name);
|
||||
register_matcher(m, matcher_pass_callback);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
// limitations under the License.
|
||||
//*****************************************************************************
|
||||
|
||||
#include "itt.hpp"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <typeindex>
|
||||
@ -329,6 +330,7 @@ static bool eliminate_squeeze(const std::shared_ptr<Node>& node) {
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::NopElimination, "NopElimination", 0);
|
||||
|
||||
bool pass::NopElimination::run_on_function(std::shared_ptr<Function> function) {
|
||||
RUN_ON_FUNCTION_SCOPE(NopElimination);
|
||||
static const std::unordered_map<NodeTypeInfo, std::function<bool(const std::shared_ptr<Node>&)>>
|
||||
dispatcher{{TI(opset3::Pad), &eliminate_nop},
|
||||
{TI(opset3::Convert), &eliminate_convert},
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/normalize_l2_fusion.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
@ -17,6 +18,7 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::NormalizeL2Fusion, "NormalizeL2Fusion", 0);
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::NormalizeL2FusionWithMax, "NormalizeL2FusionWithMax", 0);
|
||||
|
||||
ngraph::pass::NormalizeL2FusionWithMax::NormalizeL2FusionWithMax() {
|
||||
MATCHER_SCOPE(NormalizeL2FusionWithMax);
|
||||
auto input = ngraph::pattern::any_input();
|
||||
|
||||
auto exp = ngraph::pattern::wrap_type<ngraph::opset4::Constant>();
|
||||
@ -63,13 +65,14 @@ ngraph::pass::NormalizeL2FusionWithMax::NormalizeL2FusionWithMax() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(divide, "NormalizeL2FusionWithMax");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(divide, matcher_name);
|
||||
register_matcher(m, matcher_pass_callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::NormalizeL2FusionWithAdd, "NormalizeL2FusionWithAdd", 0);
|
||||
|
||||
ngraph::pass::NormalizeL2FusionWithAdd::NormalizeL2FusionWithAdd() {
|
||||
MATCHER_SCOPE(NormalizeL2FusionWithAdd);
|
||||
auto input = ngraph::pattern::any_input();
|
||||
|
||||
auto exp = ngraph::pattern::wrap_type<ngraph::opset4::Constant>();
|
||||
@ -116,6 +119,6 @@ ngraph::pass::NormalizeL2FusionWithAdd::NormalizeL2FusionWithAdd() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(divide, "NormalizeL2FusionWithMax");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(divide, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "itt.hpp"
|
||||
#include <transformations/common_optimizations/optimize_strided_slice.hpp>
|
||||
#include <ngraph/opsets/opset1.hpp>
|
||||
#include <ngraph/opsets/opset3.hpp>
|
||||
@ -15,6 +16,7 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::StridedSliceOptimization, "StridedSliceOpti
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::UselessStridedSliceEraser, "UselessStridedSliceEraser", 0);
|
||||
|
||||
bool ngraph::pass::UselessStridedSliceEraser::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(UselessStridedSliceEraser);
|
||||
bool rewritten = false;
|
||||
for (auto & node : f->get_ordered_ops()) {
|
||||
// Recursively apply transformation for sub-graph based operations
|
||||
@ -89,6 +91,7 @@ bool strided_slices_perform_the_same(std::shared_ptr<ngraph::opset1::StridedSlic
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::SharedStridedSliceEraser, "SharedStridedSliceEraser", 0);
|
||||
|
||||
bool ngraph::pass::SharedStridedSliceEraser::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(SharedStridedSliceEraser);
|
||||
bool graph_rewritten = false;
|
||||
|
||||
std::map<ngraph::Output<Node>, std::vector<std::shared_ptr<ngraph::opset1::StridedSlice>>> source_to_ss;
|
||||
@ -120,6 +123,7 @@ bool ngraph::pass::SharedStridedSliceEraser::run_on_function(std::shared_ptr<ngr
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::GroupedStridedSliceOptimizer, "GroupedStridedSliceOptimizer", 0);
|
||||
|
||||
bool ngraph::pass::GroupedStridedSliceOptimizer::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(GroupedStridedSliceOptimizer);
|
||||
bool graph_rewritten = false;
|
||||
using planned_slice = std::pair<std::shared_ptr<ngraph::opset1::StridedSlice>, ngraph::SlicePlan>;
|
||||
|
||||
@ -232,6 +236,7 @@ bool ngraph::pass::GroupedStridedSliceOptimizer::run_on_function(std::shared_ptr
|
||||
}
|
||||
|
||||
bool ngraph::pass::StridedSliceOptimization::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(StridedSliceOptimization);
|
||||
bool rewritten = UselessStridedSliceEraser().run_on_function(f);
|
||||
rewritten |= SharedStridedSliceEraser().run_on_function(f);
|
||||
rewritten |= GroupedStridedSliceOptimizer().run_on_function(f);
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/pull_transpose_through_fq.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::PullTransposeThroughFQUp, "PullTransposeThroughFQUp", 0);
|
||||
|
||||
ngraph::pass::PullTransposeThroughFQUp::PullTransposeThroughFQUp() {
|
||||
MATCHER_SCOPE(PullTransposeThroughFQUp);
|
||||
auto m_fq = pattern::wrap_type<opset1::FakeQuantize>({pattern::any_input(pattern::has_static_rank()),
|
||||
pattern::any_input(pattern::has_static_rank()),
|
||||
pattern::any_input(pattern::has_static_rank()),
|
||||
@ -57,6 +59,6 @@ ngraph::pass::PullTransposeThroughFQUp::PullTransposeThroughFQUp() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(m_transpose, "PullTransposeThroughFQUp");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(m_transpose, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@ -13,6 +14,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::RemoveFilteringBoxesBySize, "RemoveFilteringBoxesBySize", 0);
|
||||
|
||||
ngraph::pass::RemoveFilteringBoxesBySize::RemoveFilteringBoxesBySize() {
|
||||
MATCHER_SCOPE(RemoveFilteringBoxesBySize);
|
||||
// variadic split
|
||||
auto data = std::make_shared<pattern::op::Label>(element::f32, Shape{1000, 4});
|
||||
auto sizes = opset3::Constant::create(element::i64, Shape{4}, std::vector<int64_t >({1, 1, 1, 1}));
|
||||
@ -103,6 +105,6 @@ ngraph::pass::RemoveFilteringBoxesBySize::RemoveFilteringBoxesBySize() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(cast, "RemoveFilteringBoxesBySize");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(cast, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/softplus_fusion.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::SoftPlusFusion, "SoftPlusFusion", 0);
|
||||
|
||||
ngraph::pass::SoftPlusFusion::SoftPlusFusion() {
|
||||
MATCHER_SCOPE(SoftPlusFusion);
|
||||
// fuses ln(exp(x) + 1.0) operations into SoftPlus(x)
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto exp = std::make_shared<ngraph::opset4::Exp>(input);
|
||||
@ -50,6 +52,6 @@ ngraph::pass::SoftPlusFusion::SoftPlusFusion() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(log, "SoftPlusFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(log, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/softplus_to_mish_fusion.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::SoftPlusToMishFusion, "SoftPlusToMishFusion", 0);
|
||||
|
||||
ngraph::pass::SoftPlusToMishFusion::SoftPlusToMishFusion() {
|
||||
MATCHER_SCOPE(SoftPlusToMishFusion);
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto softplus = ngraph::pattern::wrap_type<ngraph::opset4::SoftPlus>({input}, pattern::consumers_count(1));
|
||||
auto tanh = ngraph::pattern::wrap_type<ngraph::opset4::Tanh>({softplus}, pattern::consumers_count(1));
|
||||
@ -33,6 +35,6 @@ ngraph::pass::SoftPlusToMishFusion::SoftPlusToMishFusion() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, "SoftPlusToMishFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/common_optimizations/swish_fusion.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -32,6 +33,7 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::SwishFusion, "SwishFusion", 0);
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::SwishFusionWithSigmoid, "SwishFusionWithSigmoid", 0);
|
||||
|
||||
ngraph::pass::SwishFusionWithSigmoid::SwishFusionWithSigmoid() {
|
||||
MATCHER_SCOPE(SwishFusionWithSigmoid);
|
||||
// replaces a sub-graphs x * Sigmoid(x) with a Swish op.
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto sigmoid = std::make_shared<ngraph::opset4::Sigmoid>(input);
|
||||
@ -51,13 +53,14 @@ ngraph::pass::SwishFusionWithSigmoid::SwishFusionWithSigmoid() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, "SwishWithSigmoidFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::SwishFusionWithSigmoidWithBeta, "SwishFusionWithSigmoidWithBeta", 0);
|
||||
|
||||
ngraph::pass::SwishFusionWithSigmoidWithBeta::SwishFusionWithSigmoidWithBeta() {
|
||||
MATCHER_SCOPE(SwishFusionWithSigmoidWithBeta);
|
||||
// replaces a sub-graphs x * Sigmoid(x * beta) with a Swish op.
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto beta = ngraph::pattern::any_input();
|
||||
@ -96,13 +99,14 @@ ngraph::pass::SwishFusionWithSigmoidWithBeta::SwishFusionWithSigmoidWithBeta() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, "SwishWithSigmoidWithBetaFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mul, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::SwishFusionWithBeta, "SwishFusionWithBeta", 0);
|
||||
|
||||
ngraph::pass::SwishFusionWithBeta::SwishFusionWithBeta() {
|
||||
MATCHER_SCOPE(SwishFusionWithBeta);
|
||||
// replaces a sub-graphs x / (1.0 + exp(-x * beta)) with a Swish op.
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto beta = ngraph::pattern::any_input();
|
||||
@ -137,13 +141,14 @@ ngraph::pass::SwishFusionWithBeta::SwishFusionWithBeta() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(div, "SwishWithBetaFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(div, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::SwishFusionWithoutBeta, "SwishFusionWithoutBeta", 0);
|
||||
|
||||
ngraph::pass::SwishFusionWithoutBeta::SwishFusionWithoutBeta() {
|
||||
MATCHER_SCOPE(SwishFusionWithoutBeta);
|
||||
// replaces a sub-graphs x / (1.0 + exp(-x)) with a Swish op.
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto neg = std::make_shared<ngraph::opset4::Negative>(input);
|
||||
@ -174,6 +179,6 @@ ngraph::pass::SwishFusionWithoutBeta::SwishFusionWithoutBeta() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(div, "SwishWithoutBetaFusion");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(div, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/control_flow/unroll_tensor_iterator.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
@ -16,6 +17,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::UnrollTensorIterator, "UnrollTensorIterator", 0);
|
||||
|
||||
bool ngraph::pass::UnrollTensorIterator::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(UnrollTensorIterator);
|
||||
for (const auto& op : f->get_ops()) {
|
||||
auto ti = std::dynamic_pointer_cast<ngraph::opset4::TensorIterator>(op);
|
||||
if (!ti || transformation_callback(ti)) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/convert_precision.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -77,6 +78,7 @@ bool fuse_type_to_reduce_logical(std::shared_ptr<ngraph::Node> & node, ngraph::e
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertPrecision, "ConvertPrecision", 0);
|
||||
|
||||
bool ngraph::pass::ConvertPrecision::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(ConvertPrecision);
|
||||
static std::map<ngraph::NodeTypeInfo, std::function<bool(std::shared_ptr<Node>&, element::Type, size_t idx)>> type_to_fuse {
|
||||
{opset4::Parameter::type_info, fuse_type_to_parameter},
|
||||
{opset4::Convert::type_info, fuse_type_to_convert},
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/init_node_info.hpp"
|
||||
#include "transformations/rt_info/fused_names_attribute.hpp"
|
||||
#include "transformations/rt_info/primitives_priority_attribute.hpp"
|
||||
@ -16,6 +17,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::InitNodeInfo, "InitNodeInfo", 0);
|
||||
|
||||
bool ngraph::pass::InitNodeInfo::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(InitNodeInfo);
|
||||
std::vector<std::shared_ptr<Variant> > attributes {
|
||||
std::make_shared<VariantWrapper<FusedNames> >(FusedNames())
|
||||
};
|
||||
|
@ -1,35 +0,0 @@
|
||||
//*****************************************************************************
|
||||
// Copyright 2017-2020 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//*****************************************************************************
|
||||
|
||||
/**
|
||||
* @brief Defines openvino domains for tracing
|
||||
* @file itt.hpp
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <openvino/itt.hpp>
|
||||
|
||||
namespace ngraph {
|
||||
namespace pass {
|
||||
namespace itt {
|
||||
namespace domains {
|
||||
OV_ITT_DOMAIN(IETransform);
|
||||
OV_ITT_DOMAIN(nGraphPass_LT);
|
||||
} // namespace domains
|
||||
} // namespace itt
|
||||
} // namespace pass
|
||||
} // namespace ngraph
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/batch_norm_decomposition.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -17,6 +18,7 @@ using namespace ngraph;
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::BatchNormDecomposition, "BatchNormDecomposition", 0);
|
||||
|
||||
ngraph::pass::BatchNormDecomposition::BatchNormDecomposition() {
|
||||
MATCHER_SCOPE(BatchNormDecomposition);
|
||||
auto bn = pattern::wrap_type<opset1::BatchNormInference>({
|
||||
pattern::any_input(pattern::has_static_rank()),
|
||||
pattern::any_input(pattern::has_static_shape()),
|
||||
@ -73,7 +75,7 @@ ngraph::pass::BatchNormDecomposition::BatchNormDecomposition() {
|
||||
|
||||
return true;
|
||||
};
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(bn, "BatchNormDecomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(bn, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
@ -81,6 +83,7 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::BatchNormV5Decomposition, "BatchNormDecompo
|
||||
|
||||
// TODO: this pass will be unified with BatchNormDecomposition pass
|
||||
ngraph::pass::BatchNormV5Decomposition::BatchNormV5Decomposition() {
|
||||
MATCHER_SCOPE(BatchNormV5Decomposition);
|
||||
auto bn = pattern::wrap_type<opset5::BatchNormInference>({
|
||||
pattern::any_input(pattern::has_static_rank()),
|
||||
pattern::any_input(pattern::has_static_shape()),
|
||||
@ -137,6 +140,6 @@ ngraph::pass::BatchNormV5Decomposition::BatchNormV5Decomposition() {
|
||||
|
||||
return true;
|
||||
};
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(bn, "BatchNormDecomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(bn, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -16,6 +17,7 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::BidirectionalGRUSequenceDecomposition, "Bid
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::BidirectionalRNNSequenceDecomposition, "BidirectionalRNNSequenceDecomposition", 0);
|
||||
|
||||
ngraph::pass::BidirectionalLSTMSequenceDecomposition::BidirectionalLSTMSequenceDecomposition() {
|
||||
MATCHER_SCOPE(BidirectionalLSTMSequenceDecomposition);
|
||||
auto lstm_sequence_ngraph = ngraph::pattern::wrap_type<ngraph::opset5::LSTMSequence>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher &m) {
|
||||
@ -79,11 +81,12 @@ ngraph::pass::BidirectionalLSTMSequenceDecomposition::BidirectionalLSTMSequenceD
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(lstm_sequence_ngraph, "BidirectionalLSTMSequenceDecomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(lstm_sequence_ngraph, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
ngraph::pass::BidirectionalGRUSequenceDecomposition::BidirectionalGRUSequenceDecomposition() {
|
||||
MATCHER_SCOPE(BidirectionalGRUSequenceDecomposition);
|
||||
auto gru_sequence_ngraph = ngraph::pattern::wrap_type<ngraph::opset5::GRUSequence>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher &m) {
|
||||
@ -143,11 +146,12 @@ ngraph::pass::BidirectionalGRUSequenceDecomposition::BidirectionalGRUSequenceDec
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(gru_sequence_ngraph, "BidirectionalGRUSequenceDecomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(gru_sequence_ngraph, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
ngraph::pass::BidirectionalRNNSequenceDecomposition::BidirectionalRNNSequenceDecomposition() {
|
||||
MATCHER_SCOPE(BidirectionalRNNSequenceDecomposition);
|
||||
auto rnn_sequence_ngraph = ngraph::pattern::wrap_type<ngraph::opset5::RNNSequence>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher &m) {
|
||||
@ -205,6 +209,6 @@ ngraph::pass::BidirectionalRNNSequenceDecomposition::BidirectionalRNNSequenceDec
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(rnn_sequence_ngraph, "BidirectionalRNNSequenceDecomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(rnn_sequence_ngraph, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_batch_to_space.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertBatchToSpace, "ConvertBatchToSpace", 0);
|
||||
|
||||
void ngraph::pass::ConvertBatchToSpace::convert_batch_to_space() {
|
||||
MATCHER_SCOPE(ConvertBatchToSpace_convert_batch_to_space);
|
||||
auto batch_to_space = ngraph::pattern::wrap_type<ngraph::opset3::BatchToSpace>();
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
auto batch_to_space = std::dynamic_pointer_cast<ngraph::opset3::BatchToSpace> (m.get_match_root());
|
||||
@ -121,11 +123,12 @@ void ngraph::pass::ConvertBatchToSpace::convert_batch_to_space() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(batch_to_space, "ConvertBatchToSpace");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(batch_to_space, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
void ngraph::pass::ConvertBatchToSpace::convert_batch_to_space_by_elements() {
|
||||
MATCHER_SCOPE(ConvertBatchToSpace_convert_batch_to_space_by_elements);
|
||||
auto batch_to_space = ngraph::pattern::wrap_type<ngraph::opset3::BatchToSpace>();
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
auto batch_to_space = std::dynamic_pointer_cast<ngraph::opset3::BatchToSpace> (m.get_match_root());
|
||||
@ -220,6 +223,6 @@ void ngraph::pass::ConvertBatchToSpace::convert_batch_to_space_by_elements() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(batch_to_space, "ConvertBatchToSpace");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(batch_to_space, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_broadcast3.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -55,6 +56,7 @@ bool make_compatible_shape(const ngraph::PartialShape & input_shape, std::vector
|
||||
}
|
||||
|
||||
ngraph::pass::ConvertBroadcast3::ConvertBroadcast3() {
|
||||
MATCHER_SCOPE(ConvertBroadcast3);
|
||||
auto broadcast = pattern::wrap_type<opset3::Broadcast>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
@ -106,6 +108,6 @@ ngraph::pass::ConvertBroadcast3::ConvertBroadcast3() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<pattern::Matcher>(broadcast, "ConvertBroadcast3");
|
||||
auto m = std::make_shared<pattern::Matcher>(broadcast, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_broadcast_to_tiles.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertBroadcastToTiles, "ConvertBroadcastToTiles", 0);
|
||||
|
||||
ngraph::pass::ConvertBroadcastToTiles::ConvertBroadcastToTiles() {
|
||||
MATCHER_SCOPE(ConvertBroadcastToTiles);
|
||||
auto broadcast = ngraph::pattern::wrap_type<ngraph::opset1::Broadcast>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
@ -96,6 +98,6 @@ ngraph::pass::ConvertBroadcastToTiles::ConvertBroadcastToTiles() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(broadcast, "ConvertBroadcastToTile");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(broadcast, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_convolutions.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -19,6 +20,7 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertConvolutions, "ConvertConvolutions",
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertConvolution, "ConvertConvolution", 0);
|
||||
|
||||
ngraph::pass::ConvertConvolution::ConvertConvolution() {
|
||||
MATCHER_SCOPE(ConvertConvolution);
|
||||
auto conv = ngraph::pattern::wrap_type<opset1::Convolution>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
@ -42,13 +44,14 @@ ngraph::pass::ConvertConvolution::ConvertConvolution() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(conv, "ConvertConvolution");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(conv, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertGroupConvolution, "ConvertGroupConvolution", 0);
|
||||
|
||||
ngraph::pass::ConvertGroupConvolution::ConvertGroupConvolution() {
|
||||
MATCHER_SCOPE(ConvertGroupConvolution);
|
||||
auto gconv = ngraph::pattern::wrap_type<opset1::GroupConvolution>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
@ -88,13 +91,14 @@ ngraph::pass::ConvertGroupConvolution::ConvertGroupConvolution() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(gconv, "ConvertGroupConvolution");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(gconv, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertDeconvolution, "ConvertDeconvolution", 0);
|
||||
|
||||
ngraph::pass::ConvertDeconvolution::ConvertDeconvolution() {
|
||||
MATCHER_SCOPE(ConvertDeconvolution);
|
||||
auto conv = ngraph::pattern::wrap_type<opset1::ConvolutionBackpropData>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
@ -120,13 +124,14 @@ ngraph::pass::ConvertDeconvolution::ConvertDeconvolution() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(conv, "ConvertConvolutionBackpropData");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(conv, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertGroupDeconvolution, "ConvertGroupDeconvolution", 0);
|
||||
|
||||
ngraph::pass::ConvertGroupDeconvolution::ConvertGroupDeconvolution() {
|
||||
MATCHER_SCOPE(ConvertGroupDeconvolution);
|
||||
auto gconv = ngraph::pattern::wrap_type<opset1::GroupConvolutionBackpropData>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
@ -164,6 +169,6 @@ ngraph::pass::ConvertGroupDeconvolution::ConvertGroupDeconvolution() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(gconv, "ConvertGroupConvolutionBackpropData");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(gconv, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_depth_to_space.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertDepthToSpace, "ConvertDepthToSpace", 0);
|
||||
|
||||
ngraph::pass::ConvertDepthToSpace::ConvertDepthToSpace() {
|
||||
MATCHER_SCOPE(ConvertDepthToSpace);
|
||||
auto dts_node = ngraph::pattern::wrap_type<ngraph::opset1::DepthToSpace>({pattern::any_input(pattern::has_static_shape())});
|
||||
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
@ -100,6 +102,6 @@ ngraph::pass::ConvertDepthToSpace::ConvertDepthToSpace() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(dts_node, "ConvertDepthToSpace");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(dts_node, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_divide.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertDivide, "ConvertDivide", 0);
|
||||
|
||||
ngraph::pass::ConvertDivide::ConvertDivide() {
|
||||
MATCHER_SCOPE(ConvertDivide);
|
||||
auto div = ngraph::pattern::wrap_type<ngraph::opset1::Divide>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
@ -34,6 +36,6 @@ ngraph::pass::ConvertDivide::ConvertDivide() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(div, "ConvertDivide");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(div, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "transformations/op_conversions/convert_gather_0d.hpp"
|
||||
|
||||
#include "itt.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@ -14,6 +16,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertGather0D, "ConvertGather0D", 0);
|
||||
|
||||
ngraph::pass::ConvertGather0D::ConvertGather0D() {
|
||||
MATCHER_SCOPE(ConvertGather0D);
|
||||
auto gather = ngraph::pattern::wrap_type<opset1::Gather>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher &m) {
|
||||
@ -47,6 +50,6 @@ ngraph::pass::ConvertGather0D::ConvertGather0D() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m1 = std::make_shared<ngraph::pattern::Matcher>(gather, "ConvertGather0D");
|
||||
auto m1 = std::make_shared<ngraph::pattern::Matcher>(gather, matcher_name);
|
||||
this->register_matcher(m1, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include <memory>
|
||||
#include <ngraph/opsets/opset2.hpp>
|
||||
#include <transformations/op_conversions/convert_gelu.hpp>
|
||||
@ -13,6 +14,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertGELU, "ConvertGELU", 0);
|
||||
|
||||
ngraph::pass::ConvertGELU::ConvertGELU() {
|
||||
MATCHER_SCOPE(ConvertGELU);
|
||||
auto input = std::make_shared<pattern::op::Label>(element::f32, Shape{});
|
||||
auto gelu = std::make_shared<ngraph::opset2::Gelu>(input);
|
||||
|
||||
@ -37,6 +39,6 @@ ngraph::pass::ConvertGELU::ConvertGELU() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(gelu, "ConvertGELU");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(gelu, matcher_name);
|
||||
register_matcher(m, callback, PassProperty::CHANGE_DYNAMIC_STATE);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_interpolate1_to_interpolate4.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -15,6 +16,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertInterpolate1ToInterpolate4, "ConvertInterpolate1ToInterpolate4", 0);
|
||||
|
||||
ngraph::pass::ConvertInterpolate1ToInterpolate4::ConvertInterpolate1ToInterpolate4() {
|
||||
MATCHER_SCOPE(ConvertInterpolate1ToInterpolate4);
|
||||
auto interpolate1 = ngraph::pattern::wrap_type<ngraph::opset1::Interpolate>({pattern::any_input(pattern::has_static_rank()), pattern::any_input()});
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
auto interpolate1 = std::dynamic_pointer_cast<ngraph::opset1::Interpolate>(m.get_match_root());
|
||||
@ -64,6 +66,6 @@ ngraph::pass::ConvertInterpolate1ToInterpolate4::ConvertInterpolate1ToInterpolat
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(interpolate1, "ConvertInterpolate1ToInterpolate4");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(interpolate1, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_minimum_to_power_and_max.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertMinimum, "ConvertMinimum", 0);
|
||||
|
||||
ngraph::pass::ConvertMinimum::ConvertMinimum() {
|
||||
MATCHER_SCOPE(ConvertMinimum);
|
||||
auto minimum = ngraph::pattern::wrap_type<opset1::Minimum>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
@ -43,6 +45,6 @@ ngraph::pass::ConvertMinimum::ConvertMinimum() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(minimum, "ConvertMinimum");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(minimum, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_mod.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertMod, "ConvertMod", 0);
|
||||
|
||||
ngraph::pass::ConvertMod::ConvertMod() {
|
||||
MATCHER_SCOPE(ConvertMod);
|
||||
auto mod = ngraph::pattern::wrap_type<opset1::Mod>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
@ -45,6 +47,6 @@ ngraph::pass::ConvertMod::ConvertMod() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mod, "ConvertMod");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mod, matcher_name);
|
||||
this->register_matcher(m, callback, PassProperty::CHANGE_DYNAMIC_STATE);
|
||||
}
|
||||
|
@ -12,9 +12,12 @@
|
||||
#include <ngraph/opsets/opset6.hpp>
|
||||
#include <ngraph/pattern/op/wrap_type.hpp>
|
||||
|
||||
#include "itt.hpp"
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertMVN1ToMVN6, "ConvertMVN1ToMVN6", 0);
|
||||
|
||||
ngraph::pass::ConvertMVN1ToMVN6::ConvertMVN1ToMVN6() {
|
||||
MATCHER_SCOPE(ConvertMVN1ToMVN6);
|
||||
auto mvn = pattern::wrap_type<ngraph::opset2::MVN>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
@ -47,6 +50,6 @@ ngraph::pass::ConvertMVN1ToMVN6::ConvertMVN1ToMVN6() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<pattern::Matcher>(mvn, "ConvertMVN1ToMVN6");
|
||||
auto m = std::make_shared<pattern::Matcher>(mvn, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_negative.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertNegative, "ConvertNegative", 0);
|
||||
|
||||
ngraph::pass::ConvertNegative::ConvertNegative() {
|
||||
MATCHER_SCOPE(ConvertNegative);
|
||||
auto neg = ngraph::pattern::wrap_type<ngraph::opset1::Negative>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
@ -30,6 +32,6 @@ ngraph::pass::ConvertNegative::ConvertNegative() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(neg, "ConvertNegative");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(neg, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@ -17,6 +18,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertNMSToNMSIEInternal, "ConvertNMSToNMSIEInternal", 0);
|
||||
|
||||
ngraph::pass::ConvertNMSToNMSIEInternal::ConvertNMSToNMSIEInternal() {
|
||||
MATCHER_SCOPE(ConvertNMSToNMSIEInternal);
|
||||
auto nms = ngraph::pattern::wrap_type<ngraph::opset5::NonMaxSuppression>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher &m) {
|
||||
@ -118,6 +120,6 @@ ngraph::pass::ConvertNMSToNMSIEInternal::ConvertNMSToNMSIEInternal() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(nms, "ConvertNMSToNMSIEInternal");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(nms, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_pad_to_group_conv.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -15,6 +16,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertPadToGroupConvolution, "ConvertPadToGroupConvolution", 0);
|
||||
|
||||
ngraph::pass::ConvertPadToGroupConvolution::ConvertPadToGroupConvolution() {
|
||||
MATCHER_SCOPE(ConvertPadToGroupConvolution);
|
||||
auto neg = ngraph::pattern::wrap_type<opset4::Pad>(pattern::has_static_dim(1));
|
||||
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
@ -80,6 +82,6 @@ ngraph::pass::ConvertPadToGroupConvolution::ConvertPadToGroupConvolution() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(neg, "ConvertPadToGroupConvolution");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(neg, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_previous_nms_to_nms_5.hpp"
|
||||
|
||||
#include <list>
|
||||
@ -161,35 +162,38 @@ struct NMSAttributes {
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertNMS4ToNMS5, "ConvertNMS4ToNMS5", 0);
|
||||
|
||||
ngraph::pass::ConvertNMS4ToNMS5::ConvertNMS4ToNMS5() {
|
||||
MATCHER_SCOPE(ConvertNMS4ToNMS5);
|
||||
auto nms = ngraph::pattern::wrap_type<ngraph::opset4::NonMaxSuppression>();
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
return callback_func(m, this);
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(nms, "ConvertNMS4ToNMS5");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(nms, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertNMS3ToNMS5, "ConvertNMS3ToNMS5", 0);
|
||||
|
||||
ngraph::pass::ConvertNMS3ToNMS5::ConvertNMS3ToNMS5() {
|
||||
MATCHER_SCOPE(ConvertNMS3ToNMS5);
|
||||
auto nms = ngraph::pattern::wrap_type<ngraph::opset3::NonMaxSuppression>();
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
return callback_func(m, this);
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(nms, "ConvertNMS3ToNMS5");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(nms, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertNMS1ToNMS5, "ConvertNMS1ToNMS5", 0);
|
||||
|
||||
ngraph::pass::ConvertNMS1ToNMS5::ConvertNMS1ToNMS5() {
|
||||
MATCHER_SCOPE(ConvertNMS1ToNMS5);
|
||||
auto nms = ngraph::pattern::wrap_type<ngraph::opset1::NonMaxSuppression>();
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
return callback_func(m, this);
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(nms, "ConvertNMS1ToNMS5");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(nms, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,9 +2,34 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_reduce_to_pooling.hpp"
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertReduceToPooling, "ConvertReduceToPooling", 0);
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertReduceMeanToPooling, "ConvertReduceMeanToPooling", 0);
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertReduceMaxToPooling, "ConvertReduceMaxToPooling", 0);
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertReduceSumToPooling, "ConvertReduceSumToPooling", 0);
|
||||
|
||||
ngraph::pass::ConvertReduceMeanToPooling::ConvertReduceMeanToPooling() {
|
||||
MATCHER_SCOPE(ConvertReduceMeanToPooling);
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(ngraph::pattern::wrap_type<opset1::ReduceMean>({pattern::any_input(pattern::has_static_shape()),
|
||||
pattern::wrap_type<opset1::Constant>()},
|
||||
pattern::has_static_shape()), matcher_name);
|
||||
register_matcher(m, convert_reduce_to_pooling<opset1::ReduceMean>());
|
||||
}
|
||||
ngraph::pass::ConvertReduceMaxToPooling::ConvertReduceMaxToPooling() {
|
||||
MATCHER_SCOPE(ConvertReduceMaxToPooling);
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(
|
||||
ngraph::pattern::wrap_type<opset1::ReduceMax>({pattern::any_input(pattern::has_static_shape()),
|
||||
pattern::wrap_type<opset1::Constant>()},
|
||||
pattern::has_static_shape()), matcher_name);
|
||||
register_matcher(m, convert_reduce_to_pooling<opset1::ReduceMax>());
|
||||
}
|
||||
ngraph::pass::ConvertReduceSumToPooling::ConvertReduceSumToPooling() {
|
||||
MATCHER_SCOPE(ConvertReduceSumToPooling);
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(
|
||||
ngraph::pattern::wrap_type<opset1::ReduceSum>({pattern::any_input(pattern::has_static_shape()),
|
||||
pattern::wrap_type<opset1::Constant>()},
|
||||
pattern::has_static_shape()), matcher_name);
|
||||
register_matcher(m, convert_reduce_to_pooling<opset1::ReduceSum>());
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_scatter_elements_to_scatter.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -15,6 +16,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertScatterElementsToScatter, "ConvertScatterElementsToScatter", 0);
|
||||
|
||||
ngraph::pass::ConvertScatterElementsToScatter::ConvertScatterElementsToScatter() {
|
||||
MATCHER_SCOPE(ConvertScatterElementsToScatter);
|
||||
auto data = std::make_shared<pattern::op::Label>(element::f32, Shape{1});
|
||||
auto indices = std::make_shared<pattern::op::Label>(element::i64, Shape{1});
|
||||
auto updates = std::make_shared<pattern::op::Label>(element::f32, Shape{1});
|
||||
@ -208,7 +210,7 @@ ngraph::pass::ConvertScatterElementsToScatter::ConvertScatterElementsToScatter()
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(scatter, "ConvertScatterElementsToScatter");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(scatter, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
#include "itt.hpp"
|
||||
#include "ngraph/builder/autobroadcast.hpp"
|
||||
#include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp"
|
||||
|
||||
@ -84,6 +85,7 @@ namespace {
|
||||
} // namespace
|
||||
|
||||
ngraph::pass::ConvertRNNSequenceToTensorIterator::ConvertRNNSequenceToTensorIterator() {
|
||||
MATCHER_SCOPE(ConvertRNNSequenceToTensorIterator);
|
||||
// X, H, seq_lengths - static, W,R,B - any
|
||||
auto rnn_seq = ngraph::pattern::wrap_type<opset5::RNNSequence>({pattern::any_input(pattern::has_static_shape()),
|
||||
pattern::any_input(pattern::has_static_shape()),
|
||||
@ -237,11 +239,12 @@ ngraph::pass::ConvertRNNSequenceToTensorIterator::ConvertRNNSequenceToTensorIter
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(rnn_seq, "ConvertRNNSequenceToTensorIterator");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(rnn_seq, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
ngraph::pass::ConvertGRUSequenceToTensorIterator::ConvertGRUSequenceToTensorIterator() {
|
||||
MATCHER_SCOPE(ConvertGRUSequenceToTensorIterator);
|
||||
// X, H, seq_lengths - static, W,R,B - any
|
||||
auto rnn_seq = ngraph::pattern::wrap_type<opset5::GRUSequence>({pattern::any_input(pattern::has_static_shape()),
|
||||
pattern::any_input(pattern::has_static_shape()),
|
||||
@ -395,11 +398,12 @@ ngraph::pass::ConvertGRUSequenceToTensorIterator::ConvertGRUSequenceToTensorIter
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(rnn_seq, "ConvertGRUSequenceToTensorIterator");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(rnn_seq, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
ngraph::pass::ConvertLSTMSequenceToTensorIterator::ConvertLSTMSequenceToTensorIterator() {
|
||||
MATCHER_SCOPE(ConvertLSTMSequenceToTensorIterator);
|
||||
// X, H, C, seq_lengths - static, W,R,B - any
|
||||
auto rnn_seq = ngraph::pattern::wrap_type<opset5::LSTMSequence>({pattern::any_input(pattern::has_static_shape()),
|
||||
pattern::any_input(pattern::has_static_shape()),
|
||||
@ -581,6 +585,6 @@ ngraph::pass::ConvertLSTMSequenceToTensorIterator::ConvertLSTMSequenceToTensorIt
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(rnn_seq, "ConvertLSTMSequenceToTensorIterator");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(rnn_seq, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_shapeof3.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -15,6 +16,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertShapeOf3, "ConvertShapeOf3", 0);
|
||||
|
||||
ngraph::pass::ConvertShapeOf3::ConvertShapeOf3() {
|
||||
MATCHER_SCOPE(ConvertShapeOf3);
|
||||
auto shapeof = pattern::wrap_type<ngraph::opset3::ShapeOf>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
@ -42,6 +44,6 @@ ngraph::pass::ConvertShapeOf3::ConvertShapeOf3() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(shapeof, "ConvertShapeOf3");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(shapeof, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_shuffle_channels3.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -16,6 +17,7 @@ using namespace ngraph;
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertShuffleChannels3, "ConvertShuffleChannels3", 0);
|
||||
|
||||
ngraph::pass::ConvertShuffleChannels3::ConvertShuffleChannels3() {
|
||||
MATCHER_SCOPE(ConvertShuffleChannels3);
|
||||
auto input = std::make_shared<pattern::op::Label>(element::f32, Shape{1, 1, 1, 1});
|
||||
auto shuffle_channels = std::make_shared<::opset3::ShuffleChannels>(input);
|
||||
|
||||
@ -97,6 +99,6 @@ ngraph::pass::ConvertShuffleChannels3::ConvertShuffleChannels3() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(shuffle_channels, "ConvertShuffleChannels3");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(shuffle_channels, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_space_to_batch.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertSpaceToBatch, "ConvertSpaceToBatch", 0);
|
||||
|
||||
void ngraph::pass::ConvertSpaceToBatch::convert_space_to_batch() {
|
||||
MATCHER_SCOPE(ConvertSpaceToBatch_convert_space_to_batch);
|
||||
auto space_to_batch = ngraph::pattern::wrap_type<ngraph::opset3::SpaceToBatch>();
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
auto space_to_batch = std::dynamic_pointer_cast<ngraph::opset3::SpaceToBatch> (m.get_match_root());
|
||||
@ -112,11 +114,12 @@ void ngraph::pass::ConvertSpaceToBatch::convert_space_to_batch() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(space_to_batch, "ConvertSpaceToBatch");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(space_to_batch, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
void ngraph::pass::ConvertSpaceToBatch::convert_space_to_batch_by_elements() {
|
||||
MATCHER_SCOPE(ConvertSpaceToBatch_convert_space_to_batch_by_elements);
|
||||
auto space_to_batch = ngraph::pattern::wrap_type<ngraph::opset3::SpaceToBatch>();
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
auto space_to_batch = std::dynamic_pointer_cast<ngraph::opset3::SpaceToBatch> (m.get_match_root());
|
||||
@ -203,7 +206,6 @@ void ngraph::pass::ConvertSpaceToBatch::convert_space_to_batch_by_elements() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(space_to_batch, "ConvertSpaceToBatch");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(space_to_batch, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_space_to_depth.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertSpaceToDepth, "ConvertSpaceToDepth", 0);
|
||||
|
||||
ngraph::pass::ConvertSpaceToDepth::ConvertSpaceToDepth() {
|
||||
MATCHER_SCOPE(ConvertSpaceToDepth);
|
||||
auto dts = ngraph::pattern::wrap_type<ngraph::opset1::SpaceToDepth>({pattern::any_input(pattern::has_static_shape())});
|
||||
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
@ -89,6 +91,6 @@ ngraph::pass::ConvertSpaceToDepth::ConvertSpaceToDepth() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(dts, "ConvertSpaceToDepth");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(dts, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_subtract.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertSubtract, "ConvertSubtract", 0);
|
||||
|
||||
ngraph::pass::ConvertSubtract::ConvertSubtract() {
|
||||
MATCHER_SCOPE(ConvertSubtract);
|
||||
auto sub = ngraph::pattern::wrap_type<ngraph::opset1::Subtract>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
@ -63,6 +65,6 @@ ngraph::pass::ConvertSubtract::ConvertSubtract() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(sub, "ConvertSubtract");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(sub, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_ti_to_sequences.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
@ -22,6 +23,7 @@ NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertTensorIteratorToRNNSequence, "Conver
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertTensorIteratorToGRUSequence, "ConvertTensorIteratorToGRUSequence", 0);
|
||||
|
||||
ngraph::pass::ConvertTensorIteratorToLSTMSequence::ConvertTensorIteratorToLSTMSequence() {
|
||||
MATCHER_SCOPE(ConvertTensorIteratorToLSTMSequence);
|
||||
auto tensor_iterator = std::make_shared<ngraph::pattern::op::Label>(ngraph::element::f32,
|
||||
ngraph::Shape{}, ngraph::pattern::has_class<ngraph::opset5::TensorIterator>());
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher &m) {
|
||||
@ -191,11 +193,12 @@ ngraph::pass::ConvertTensorIteratorToLSTMSequence::ConvertTensorIteratorToLSTMSe
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(tensor_iterator, "ConvertTensorIteratorToLSTMSequence");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(tensor_iterator, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
ngraph::pass::ConvertTensorIteratorToRNNSequence::ConvertTensorIteratorToRNNSequence() {
|
||||
MATCHER_SCOPE(ConvertTensorIteratorToRNNSequence);
|
||||
auto tensor_iterator = std::make_shared<ngraph::pattern::op::Label>(ngraph::element::f32,
|
||||
ngraph::Shape{}, ngraph::pattern::has_class<ngraph::opset5::TensorIterator>());
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher &m) {
|
||||
@ -344,11 +347,12 @@ ngraph::pass::ConvertTensorIteratorToRNNSequence::ConvertTensorIteratorToRNNSequ
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(tensor_iterator, "ConvertTensorIteratorToRNNSequence");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(tensor_iterator, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
ngraph::pass::ConvertTensorIteratorToGRUSequence::ConvertTensorIteratorToGRUSequence() {
|
||||
MATCHER_SCOPE(ConvertTensorIteratorToGRUSequence);
|
||||
auto tensor_iterator = std::make_shared<ngraph::pattern::op::Label>(ngraph::element::f32,
|
||||
ngraph::Shape{}, ngraph::pattern::has_class<ngraph::opset5::TensorIterator>());
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher &m) {
|
||||
@ -498,6 +502,6 @@ ngraph::pass::ConvertTensorIteratorToGRUSequence::ConvertTensorIteratorToGRUSequ
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(tensor_iterator, "ConvertTensorIteratorToGRUSequence");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(tensor_iterator, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/convert_topk3.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -17,6 +18,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertTopK3, "ConvertTopK3", 0);
|
||||
|
||||
ngraph::pass::ConvertTopK3::ConvertTopK3() {
|
||||
MATCHER_SCOPE(ConvertTopK3);
|
||||
auto topk = pattern::wrap_type<opset3::TopK>();
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
@ -61,6 +63,6 @@ ngraph::pass::ConvertTopK3::ConvertTopK3() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(topk, "ConvertTopK3");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(topk, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/gru_cell_decomposition.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -15,6 +16,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::GRUCellDecomposition, "GRUCellDecomposition", 0);
|
||||
|
||||
ngraph::pass::GRUCellDecomposition::GRUCellDecomposition() {
|
||||
MATCHER_SCOPE(GRUCellDecomposition);
|
||||
auto gru_cell = ngraph::pattern::wrap_type<opset4::GRUCell>();
|
||||
ngraph::matcher_pass_callback callback = [this](ngraph::pattern::Matcher& m) {
|
||||
auto gru_cell = std::dynamic_pointer_cast<ngraph::opset4::GRUCell> (m.get_match_root());
|
||||
@ -101,6 +103,6 @@ ngraph::pass::GRUCellDecomposition::GRUCellDecomposition() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(gru_cell, "GRUCellDecomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(gru_cell, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/hsigmoid_decomposition.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -13,6 +14,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::HSigmoidDecomposition, "HSigmoidDecomposition", 0);
|
||||
|
||||
ngraph::pass::HSigmoidDecomposition::HSigmoidDecomposition() {
|
||||
MATCHER_SCOPE(HSigmoidDecomposition);
|
||||
// Decomposes HSigmoid(x) op into sub-graph (min(Relu(x + 3), 6) * const(1/6)
|
||||
auto hsigmoid = ngraph::pattern::wrap_type<opset5::HSigmoid>();
|
||||
|
||||
@ -40,6 +42,6 @@ ngraph::pass::HSigmoidDecomposition::HSigmoidDecomposition() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(hsigmoid, "HSigmoidDecomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(hsigmoid, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/hswish_decomposition.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -13,6 +14,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::HSwishDecomposition, "HSwishDecomposition", 0);
|
||||
|
||||
ngraph::pass::HSwishDecomposition::HSwishDecomposition() {
|
||||
MATCHER_SCOPE(HSwishDecomposition);
|
||||
// Decomposes HSwish(x) op into sub-graph x * (min(Relu(x + 3), 6) * const(1/6)
|
||||
auto hswish = ngraph::pattern::wrap_type<opset4::HSwish>();
|
||||
|
||||
@ -41,6 +43,6 @@ ngraph::pass::HSwishDecomposition::HSwishDecomposition() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(hswish, "HSwishDecomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(hswish, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/log_softmax_decomposition.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -13,6 +14,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::LogSoftmaxDecomposition, "LogSoftmaxDecomposition", 0);
|
||||
|
||||
ngraph::pass::LogSoftmaxDecomposition::LogSoftmaxDecomposition() {
|
||||
MATCHER_SCOPE(LogSoftmaxDecomposition);
|
||||
// Decomposes LogSoftmax(x, axis) op into sub-graph x - log(reduce_sum(exp(x), axis))
|
||||
auto log_softmax = ngraph::pattern::wrap_type<opset5::LogSoftmax>();
|
||||
|
||||
@ -39,6 +41,6 @@ ngraph::pass::LogSoftmaxDecomposition::LogSoftmaxDecomposition() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(log_softmax, "LogSoftmaxDecomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(log_softmax, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/lstm_cell_decomposition.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -16,6 +17,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::LSTMCellDecomposition, "LSTMCellDecomposition", 0);
|
||||
|
||||
ngraph::pass::LSTMCellDecomposition::LSTMCellDecomposition() {
|
||||
MATCHER_SCOPE(LSTMCellDecomposition);
|
||||
auto is_supported_lstm_cell = [](const std::shared_ptr<Node>& n) {
|
||||
return pattern::has_class<ngraph::opset1::LSTMCell>()(n) || pattern::has_class<ngraph::opset4::LSTMCell>()(n);
|
||||
};
|
||||
@ -86,6 +88,6 @@ ngraph::pass::LSTMCellDecomposition::LSTMCellDecomposition() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(any_lstm, "LSTMCellDecomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(any_lstm, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -9,10 +9,12 @@
|
||||
#include <ngraph/opsets/opset6.hpp>
|
||||
#include <ngraph/rt_info.hpp>
|
||||
#include <ngraph/pattern/op/wrap_type.hpp>
|
||||
#include "itt.hpp"
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::MVN6Decomposition, "MVN6Decomposition", 0);
|
||||
|
||||
ngraph::pass::MVN6Decomposition::MVN6Decomposition() {
|
||||
MATCHER_SCOPE(MVN6Decomposition);
|
||||
// Decomposes MVN(x, axes) op if normalize_variance is false into sub-graph
|
||||
// x - ReduceMean(x, axes), if normalize_variance is true into sub-graph
|
||||
// (x - ReduceMean(x, axes)) / Sqrt(ReduceSum((x - ReduceMean(x, axes)) ^ 2))
|
||||
@ -67,6 +69,6 @@ ngraph::pass::MVN6Decomposition::MVN6Decomposition() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mvn, "MVN6Decomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(mvn, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/reduce_l1_decomposition.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -13,6 +14,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ReduceL1Decomposition, "ReduceL1Decomposition", 0);
|
||||
|
||||
ngraph::pass::ReduceL1Decomposition::ReduceL1Decomposition() {
|
||||
MATCHER_SCOPE(ReduceL1Decomposition);
|
||||
// decomposes ReduceL1 operations into ReduceSum(abs(x))
|
||||
auto reduce_l1 = ngraph::pattern::wrap_type<opset4::ReduceL1>();
|
||||
|
||||
@ -34,7 +36,7 @@ ngraph::pass::ReduceL1Decomposition::ReduceL1Decomposition() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(reduce_l1, "ReduceL1Decomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(reduce_l1, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/reduce_l2_decomposition.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -13,6 +14,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ReduceL2Decomposition, "ReduceL2Decomposition", 0);
|
||||
|
||||
ngraph::pass::ReduceL2Decomposition::ReduceL2Decomposition() {
|
||||
MATCHER_SCOPE(ReduceL2Decomposition);
|
||||
// decomposes ReduceL2 operations into sqrt(ReduceSum(x * x))
|
||||
auto reduce_l2 = ngraph::pattern::wrap_type<opset4::ReduceL2>();
|
||||
|
||||
@ -35,7 +37,7 @@ ngraph::pass::ReduceL2Decomposition::ReduceL2Decomposition() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(reduce_l2, "ReduceL2Decomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(reduce_l2, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/rnn_cell_decomposition.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -15,6 +16,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::RNNCellDecomposition, "RNNCellDecomposition", 0);
|
||||
|
||||
ngraph::pass::RNNCellDecomposition::RNNCellDecomposition() {
|
||||
MATCHER_SCOPE(RNNCellDecomposition);
|
||||
auto rnn_cell = ngraph::pattern::wrap_type<opset4::RNNCell>();
|
||||
ngraph::matcher_pass_callback callback = [this](ngraph::pattern::Matcher& m) {
|
||||
auto rnn_cell = std::dynamic_pointer_cast<ngraph::opset4::RNNCell> (m.get_match_root());
|
||||
@ -49,6 +51,6 @@ ngraph::pass::RNNCellDecomposition::RNNCellDecomposition() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(rnn_cell, "RNNCellDecomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(rnn_cell, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/op_conversions/softplus_decomposition.hpp"
|
||||
|
||||
#include <memory>
|
||||
@ -14,6 +15,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::SoftPlusDecomposition, "SoftPlusDecomposition", 0);
|
||||
|
||||
ngraph::pass::SoftPlusDecomposition::SoftPlusDecomposition() {
|
||||
MATCHER_SCOPE(SoftPlusDecomposition);
|
||||
// decomposes SoftPlus(x) operation into ln(exp(x) + 1.0)
|
||||
auto input = ngraph::pattern::any_input();
|
||||
auto softplus = std::make_shared<ngraph::opset4::SoftPlus>(input);
|
||||
@ -38,6 +40,6 @@ ngraph::pass::SoftPlusDecomposition::SoftPlusDecomposition() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(softplus, "SoftPlusDecomposition");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(softplus, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "transformations/op_conversions/convert_batch_to_space.hpp"
|
||||
#include "transformations/op_conversions/convert_space_to_batch.hpp"
|
||||
#include "transformations/itt.hpp"
|
||||
#include "itt.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@ -16,6 +16,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertOpSet2ToOpSet1, "ConvertOpSet2ToOpSet1", 0);
|
||||
|
||||
bool ngraph::pass::ConvertOpSet2ToOpSet1::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(ConvertOpSet2ToOpSet1);
|
||||
ngraph::pass::Manager manager(get_pass_config());
|
||||
|
||||
manager.register_pass<ngraph::pass::ConvertSpaceToBatch>();
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "transformations/op_conversions/convert_shuffle_channels3.hpp"
|
||||
#include "transformations/op_conversions/convert_topk3.hpp"
|
||||
#include "transformations/op_conversions/softplus_decomposition.hpp"
|
||||
#include "transformations/itt.hpp"
|
||||
#include "itt.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@ -19,6 +19,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertOpSet3ToOpSet2, "ConvertOpSet3ToOpSet2", 0);
|
||||
|
||||
bool ngraph::pass::ConvertOpSet3ToOpSet2::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(ConvertOpSet3ToOpSet2);
|
||||
ngraph::pass::Manager manager(get_pass_config());
|
||||
|
||||
manager.register_pass<ngraph::pass::ConvertBroadcast3>();
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
@ -501,6 +502,7 @@ void ngfunction_2_irv10(pugi::xml_document& doc,
|
||||
// ! [function_pass:serialize_cpp]
|
||||
// serialize.cpp
|
||||
bool pass::Serialize::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(Serialize);
|
||||
// prepare data
|
||||
pugi::xml_document xml_doc;
|
||||
std::ofstream bin_file(m_binPath, std::ios::out | std::ios::binary);
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "transformations/smart_reshape/matmul_sr.hpp"
|
||||
#include "transformations/smart_reshape/utils.hpp"
|
||||
|
||||
@ -49,6 +50,7 @@ bool relax_hc_reshape_followed_by_matmul(const ngraph::pattern::PatternValueMap
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ReshapeAMatMul, "ReshapeAMatMul", 0);
|
||||
|
||||
ngraph::pass::ReshapeAMatMul::ReshapeAMatMul() {
|
||||
MATCHER_SCOPE(ReshapeAMatMul);
|
||||
auto other_input_label = pattern::any_input();
|
||||
auto reshape_input_label = pattern::any_input();
|
||||
auto reshape_pattern_label = pattern::any_input();
|
||||
@ -57,16 +59,16 @@ ngraph::pass::ReshapeAMatMul::ReshapeAMatMul() {
|
||||
|
||||
matcher_pass_callback callback = [=](pattern::Matcher &m) -> bool {
|
||||
const auto & pattern_to_output = m.get_pattern_value_map();
|
||||
return relax_hc_reshape_followed_by_matmul(
|
||||
pattern_to_output, matmul_label, reshape_label, other_input_label, reshape_pattern_label, true);
|
||||
return relax_hc_reshape_followed_by_matmul(pattern_to_output, matmul_label, reshape_label, other_input_label, reshape_pattern_label, true);
|
||||
};
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(matmul_label, "ReshapeMatMul_A");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(matmul_label, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ReshapeBMatMul, "ReshapeBMatMul", 0);
|
||||
|
||||
ngraph::pass::ReshapeBMatMul::ReshapeBMatMul() {
|
||||
MATCHER_SCOPE(ReshapeBMatMul);
|
||||
auto other_input_label = pattern::any_input();
|
||||
auto reshape_input_label = pattern::any_input();
|
||||
auto reshape_pattern_label = pattern::any_input();
|
||||
@ -75,16 +77,16 @@ ngraph::pass::ReshapeBMatMul::ReshapeBMatMul() {
|
||||
|
||||
matcher_pass_callback callback = [=](pattern::Matcher &m) -> bool {
|
||||
const auto & pattern_to_output = m.get_pattern_value_map();
|
||||
return relax_hc_reshape_followed_by_matmul(
|
||||
pattern_to_output, matmul_label, reshape_label, other_input_label, reshape_pattern_label, false);
|
||||
return relax_hc_reshape_followed_by_matmul(pattern_to_output, matmul_label, reshape_label, other_input_label, reshape_pattern_label, false);
|
||||
};
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(matmul_label, "ReshapeMatMul_B");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(matmul_label, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::TransposeMatMul, "TransposeMatMul", 0);
|
||||
|
||||
ngraph::pass::TransposeMatMul::TransposeMatMul() {
|
||||
MATCHER_SCOPE(TransposeMatMul);
|
||||
auto matmul_label = ngraph::pattern::wrap_type<opset4::MatMul>();
|
||||
|
||||
matcher_pass_callback callback = [=](pattern::Matcher &m) -> bool {
|
||||
@ -136,6 +138,6 @@ ngraph::pass::TransposeMatMul::TransposeMatMul() {
|
||||
}
|
||||
return false;
|
||||
};
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(matmul_label, "TransposeMatMul");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(matmul_label, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,14 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include <ngraph/pass/constant_folding.hpp>
|
||||
#include <transformations/smart_reshape/mimic_set_batch_size.hpp>
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::MimicSetBatchSize, "MimicSetBatchSize", 0);
|
||||
|
||||
bool ngraph::pass::MimicSetBatchSize::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(MimicSetBatchSize);
|
||||
// extracting ratio of out to in 0-index dimension value from the folded function
|
||||
auto specialized_function = ngraph::clone_function(*f);
|
||||
ngraph::pass::Manager manager;
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include <transformations/smart_reshape/proposal_scales_stridedslice.hpp>
|
||||
|
||||
#include <ngraph/ngraph.hpp>
|
||||
@ -31,6 +32,7 @@ bool crop_scales_for_proposal(const ngraph::pattern::PatternValueMap & pattern_t
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::Proposal1Scales, "Proposal1Scales", 0);
|
||||
|
||||
ngraph::pass::Proposal1Scales::Proposal1Scales() {
|
||||
MATCHER_SCOPE(Proposal1Scales);
|
||||
auto parameter_label = ngraph::pattern::wrap_type<opset5::Parameter>([](const Output<Node> &output) {
|
||||
const auto & shape = output.get_partial_shape();
|
||||
return shape.rank().is_static() && shape.rank().get_length() == 2 && shape[1].is_static() && (shape[1].get_length() == 3 || shape[1].get_length() == 4);
|
||||
@ -42,13 +44,14 @@ ngraph::pass::Proposal1Scales::Proposal1Scales() {
|
||||
matcher_pass_callback callback = [parameter_label, proposal_label](pattern::Matcher &m) -> bool {
|
||||
return crop_scales_for_proposal(m.get_pattern_value_map(), parameter_label, proposal_label);
|
||||
};
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(proposal_label, "Proposal1Scales");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(proposal_label, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::Proposal4Scales, "Proposal4Scales", 0);
|
||||
|
||||
ngraph::pass::Proposal4Scales::Proposal4Scales() {
|
||||
MATCHER_SCOPE(Proposal4Scales);
|
||||
auto parameter_label = ngraph::pattern::wrap_type<opset5::Parameter>([](const Output<Node> &output) {
|
||||
const auto & shape = output.get_partial_shape();
|
||||
return shape.rank().is_static() && shape.rank().get_length() == 2 && shape[1].is_static() && (shape[1].get_length() == 3 || shape[1].get_length() == 4);
|
||||
@ -60,6 +63,6 @@ ngraph::pass::Proposal4Scales::Proposal4Scales() {
|
||||
matcher_pass_callback callback = [parameter_label, proposal_label](pattern::Matcher &m) -> bool {
|
||||
return crop_scales_for_proposal(m.get_pattern_value_map(), parameter_label, proposal_label);
|
||||
};
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(proposal_label, "Proposal4Scales");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(proposal_label, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include <transformations/smart_reshape/reshape_to_1D.hpp>
|
||||
|
||||
#include <ngraph/ngraph.hpp>
|
||||
@ -13,6 +14,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::ReshapeTo1D, "ReshapeTo1D", 0);
|
||||
|
||||
ngraph::pass::ReshapeTo1D::ReshapeTo1D() {
|
||||
MATCHER_SCOPE(ReshapeTo1D);
|
||||
auto reshape_label = ngraph::pattern::wrap_type<opset5::Reshape>({pattern::any_input(), ngraph::pattern::wrap_type<opset5::Constant>()},
|
||||
[](const Output<Node> & output) { return output.get_partial_shape().rank().is_static() && output.get_partial_shape().rank().get_length() == 1; });
|
||||
|
||||
@ -20,6 +22,6 @@ ngraph::pass::ReshapeTo1D::ReshapeTo1D() {
|
||||
m.get_match_root()->input(1).replace_source_output(ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {-1}));
|
||||
return true;
|
||||
};
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(reshape_label, "ReshapeTo1D");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(reshape_label, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <ngraph/pass/constant_folding.hpp>
|
||||
|
||||
#include <transformations/init_node_info.hpp>
|
||||
#include <transformations/itt.hpp>
|
||||
#include <itt.hpp>
|
||||
#include <transformations/smart_reshape/mimic_set_batch_size.hpp>
|
||||
#include <transformations/smart_reshape/reshape_to_1D.hpp>
|
||||
#include <transformations/smart_reshape/set_batch_size.hpp>
|
||||
@ -17,6 +17,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::SetBatchSize, "SetBatchSize", 0);
|
||||
|
||||
bool ngraph::pass::SetBatchSize::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(SetBatchSize);
|
||||
OV_ITT_SCOPED_TASK(itt::domains::IETransform, "ngraph::pass::SetBatchSize");
|
||||
|
||||
ngraph::pass::Manager manager;
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "itt.hpp"
|
||||
#include <memory>
|
||||
|
||||
#include <ngraph/pass/manager.hpp>
|
||||
@ -17,6 +18,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::SmartReshape, "SmartReshape", 0);
|
||||
|
||||
bool ngraph::pass::SmartReshape::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(SmartReshape);
|
||||
ngraph::pass::Manager static_manager;
|
||||
// This pass must be called first in pipeline
|
||||
static_manager.register_pass<ngraph::pass::InitNodeInfo>();
|
||||
|
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <transformations/itt.hpp>
|
||||
#include <itt.hpp>
|
||||
#include <transformations/smart_reshape/strided_slice_squeeze.hpp>
|
||||
|
||||
#include <ngraph/ngraph.hpp>
|
||||
@ -14,6 +14,7 @@
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::StridedSliceSqueeze, "ngraph::pass::StridedSliceSqueeze", 0);
|
||||
|
||||
ngraph::pass::StridedSliceSqueeze::StridedSliceSqueeze() {
|
||||
MATCHER_SCOPE(StridedSliceSqueeze);
|
||||
auto ss_label = ngraph::pattern::wrap_type<opset5::StridedSlice>(pattern::consumers_count(1));
|
||||
auto squeeze_label = ngraph::pattern::wrap_type<opset5::Squeeze>({ss_label, ngraph::pattern::wrap_type<opset5::Constant>()});
|
||||
|
||||
@ -75,12 +76,13 @@ ngraph::pass::StridedSliceSqueeze::StridedSliceSqueeze() {
|
||||
copy_runtime_info(slice, new_slice);
|
||||
return true;
|
||||
};
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(squeeze_label, "ngraph::pass::StridedSliceSqueeze");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(squeeze_label, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
NGRAPH_RTTI_DEFINITION(ngraph::pass::SqueezeStridedSlice, "ngraph::pass::SqueezeStridedSlice", 0);
|
||||
|
||||
ngraph::pass::SqueezeStridedSlice::SqueezeStridedSlice() {
|
||||
MATCHER_SCOPE(SqueezeStridedSlice);
|
||||
auto squeeze_label = ngraph::pattern::wrap_type<opset5::Squeeze>(
|
||||
{pattern::any_input(), ngraph::pattern::wrap_type<opset5::Constant>()}, pattern::consumers_count(1));
|
||||
auto ss_label = ngraph::pattern::wrap_type<opset5::StridedSlice>({squeeze_label, pattern::any_input(), pattern::any_input(), pattern::any_input()});
|
||||
@ -138,7 +140,7 @@ ngraph::pass::SqueezeStridedSlice::SqueezeStridedSlice() {
|
||||
copy_runtime_info(slice, new_slice);
|
||||
return true;
|
||||
};
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(ss_label, "ngraph::pass::SqueezeStridedSlice");
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(ss_label, matcher_name);
|
||||
register_matcher(m, callback);
|
||||
}
|
||||
|
||||
@ -162,6 +164,7 @@ bool squeezes_perform_the_same(std::shared_ptr<ngraph::opset5::Squeeze> lhs, std
|
||||
}
|
||||
|
||||
bool ngraph::pass::SharedSqueeze::run_on_function(std::shared_ptr<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(SharedSqueeze);
|
||||
OV_ITT_SCOPED_TASK(itt::domains::IETransform, "ngraph::pass::SharedSqueeze");
|
||||
|
||||
bool graph_rewritten = false;
|
||||
@ -190,4 +193,4 @@ bool ngraph::pass::SharedSqueeze::run_on_function(std::shared_ptr<ngraph::Functi
|
||||
}
|
||||
}
|
||||
return graph_rewritten;
|
||||
}
|
||||
}
|
||||
|
@ -38,16 +38,23 @@ namespace ngraph
|
||||
}
|
||||
}
|
||||
OV_CC_DOMAINS(ngraph_op);
|
||||
OV_ITT_DOMAIN(SIMPLE_ngraph_pass);
|
||||
|
||||
#if defined(SELECTIVE_BUILD_ANALYZER)
|
||||
#define NGRAPH_OP_SCOPE(region) OV_SCOPE(ngraph_op, region)
|
||||
#define NGRAPH_PASS_CALLBACK(matcher) \
|
||||
openvino::itt::handle_t m_callback_handle; \
|
||||
m_callback_handle = openvino::itt::handle(matcher->get_name()); \
|
||||
OV_ITT_SCOPED_TASK(SIMPLE_ngraph_pass, m_callback_handle)
|
||||
#elif defined(SELECTIVE_BUILD)
|
||||
#define NGRAPH_OP_SCOPE(region) \
|
||||
if (OV_CC_SCOPE_IS_ENABLED(OV_CC_CAT3(ngraph_op, _, region)) == 0) \
|
||||
throw ngraph::ngraph_error(std::string(OV_CC_TOSTRING(OV_CC_CAT3(ngraph_op, _, region))) + \
|
||||
" is disabled!")
|
||||
#define NGRAPH_PASS_CALLBACK(matcher)
|
||||
#else
|
||||
#define NGRAPH_OP_SCOPE(region) OV_ITT_SCOPED_TASK(ngraph::itt::domains::ngraph_op, #region)
|
||||
#define NGRAPH_PASS_CALLBACK(matcher)
|
||||
#endif
|
||||
|
||||
#define NGRAPH_TYPE_CASE(region, a, ...) \
|
||||
|
@ -251,6 +251,7 @@ void pass::GraphRewrite::add_matcher(const shared_ptr<pattern::Matcher>& m,
|
||||
if (m->match(node->output(0)))
|
||||
{
|
||||
NGRAPH_DEBUG << "Matcher " << m->get_name() << " matched " << node;
|
||||
NGRAPH_PASS_CALLBACK(m);
|
||||
bool status = callback(*m.get());
|
||||
// explicitly clear Matcher state because it holds pointers to matched nodes
|
||||
m->clear_state();
|
||||
@ -387,6 +388,7 @@ void ngraph::pass::MatcherPass::register_matcher(const std::shared_ptr<ngraph::p
|
||||
if (m->match(node->output(0)))
|
||||
{
|
||||
NGRAPH_DEBUG << "Matcher " << m->get_name() << " matched " << node;
|
||||
NGRAPH_PASS_CALLBACK(m);
|
||||
bool status = callback(*m.get());
|
||||
// explicitly clear Matcher state because it holds pointers to matched nodes
|
||||
m->clear_state();
|
||||
@ -401,5 +403,7 @@ bool ngraph::pass::MatcherPass::apply(std::shared_ptr<ngraph::Node> node)
|
||||
{
|
||||
OV_ITT_SCOPED_TASK(itt::domains::nGraph, "ngraph::pass::MatcherPass::apply");
|
||||
m_new_nodes.clear();
|
||||
return m_handler(node);
|
||||
if (m_handler)
|
||||
return m_handler(node);
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user