Skip to content

Commit

Permalink
Transformations: API 2.0 transition part 4
Browse files Browse the repository at this point in the history
  • Loading branch information
itikhono committed Oct 13, 2023
1 parent 157041e commit eb9a553
Show file tree
Hide file tree
Showing 38 changed files with 189 additions and 332 deletions.
4 changes: 2 additions & 2 deletions src/common/low_precision_transformations/include/itt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ namespace domains {
} // namespace itt
} // namespace low_precision
} // namespace pass
} // namespace ngraph
} // namespace ov

/*
* 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
* INTERNAL_OP_SCOPE macro allows to disable parts of internal openvino operations if they are not used
*/
#if defined(SELECTIVE_BUILD_ANALYZER)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace pass {
namespace low_precision {

/**
* @brief NetworkHelper class encapsulates manipulations with nGraph function.
* @brief NetworkHelper class encapsulates manipulations with ov::Model.
*/
class LP_TRANSFORMATIONS_API NetworkHelper {
public:
Expand Down
11 changes: 5 additions & 6 deletions src/common/low_precision_transformations/src/batch_to_space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
#include "low_precision/batch_to_space.hpp"

#include <memory>
#include <ngraph/ngraph.hpp>
#include <openvino/op/batch_to_space.hpp>
#include <ngraph/pattern/op/wrap_type.hpp>

#include "openvino/op/batch_to_space.hpp"
#include "openvino/pass/pattern/op/wrap_type.hpp"
#include "low_precision/network_helper.hpp"
#include "itt.hpp"

Expand All @@ -20,15 +19,15 @@ BatchToSpaceTransformation::BatchToSpaceTransformation(const Params& params) : L
MATCHER_SCOPE(BatchToSpaceTransformation);
auto matcher = pattern::wrap_type<ov::op::v1::BatchToSpace>();

ngraph::graph_rewrite_callback callback = [this](pattern::Matcher& m) {
ov::graph_rewrite_callback callback = [this](pattern::Matcher& m) {
auto op = m.get_match_root();
if (transformation_callback(op)) {
return false;
}
return transform(*context, m);
};

auto m = std::make_shared<ngraph::pattern::Matcher>(matcher, matcher_name);
auto m = std::make_shared<ov::pass::pattern::Matcher>(matcher, matcher_name);
this->register_matcher(m, callback);
}

Expand All @@ -45,7 +44,7 @@ bool BatchToSpaceTransformation::canBeTransformed(const TransformationContext& c
return dequantization.isPerTensor();
}

bool BatchToSpaceTransformation::transform(TransformationContext& context, ngraph::pattern::Matcher& m) {
bool BatchToSpaceTransformation::transform(TransformationContext& context, ov::pass::pattern::Matcher& m) {
if (!canBeTransformed(context, m.get_match_root())) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ size_t NetworkHelper::getGroupsCount(std::shared_ptr<Node> layer) {
}

void NetworkHelper::removeLayer(std::shared_ptr<Node> layer) {
ngraph::replace_output_update_name(layer->output(0), layer->input_value(0));
ov::replace_output_update_name(layer->output(0), layer->input_value(0));
}

std::shared_ptr<Node> NetworkHelper::swapMultiplyAndAdd(std::shared_ptr<ov::opset1::Add> addAfterMultiply, const int multiplyBranch) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/reshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ bool ReshapeTransformation::canBeTransformed(const TransformationContext& contex
const auto inputs = op->get_output_target_inputs(0);
if (inputs.size() == 1ul) {
const auto consumer = inputs.begin()->get_node();
ignorePerTensorQuantizationCheck = ngraph::as_type<ov::opset1::MatMul>(consumer) != nullptr;
ignorePerTensorQuantizationCheck = ov::as_type<ov::opset1::MatMul>(consumer) != nullptr;
}
}

Expand Down
12 changes: 5 additions & 7 deletions src/common/low_precision_transformations/src/space_to_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
#include "low_precision/space_to_batch.hpp"

#include <memory>
#include <ngraph/ngraph.hpp>
#include <openvino/op/space_to_batch.hpp>

#include <ngraph/pattern/op/wrap_type.hpp>

#include "openvino/op/space_to_batch.hpp"
#include "openvino/pass/pattern/op/wrap_type.hpp"
#include "low_precision/network_helper.hpp"
#include "itt.hpp"

Expand All @@ -21,15 +19,15 @@ SpaceToBatchTransformation::SpaceToBatchTransformation(const Params& params) : L
MATCHER_SCOPE(SpaceToBatchTransformation);
auto matcher = pattern::wrap_type<ov::op::v1::SpaceToBatch>();

ngraph::graph_rewrite_callback callback = [this](pattern::Matcher& m) {
ov::graph_rewrite_callback callback = [this](pattern::Matcher& m) {
auto op = m.get_match_root();
if (transformation_callback(op)) {
return false;
}
return transform(*context, m);
};

auto m = std::make_shared<ngraph::pattern::Matcher>(matcher, matcher_name);
auto m = std::make_shared<ov::pass::pattern::Matcher>(matcher, matcher_name);
this->register_matcher(m, callback);
}

Expand All @@ -46,7 +44,7 @@ bool SpaceToBatchTransformation::canBeTransformed(const TransformationContext& c
return dequantization.isPerTensor();
}

bool SpaceToBatchTransformation::transform(TransformationContext& context, ngraph::pattern::Matcher& m) {
bool SpaceToBatchTransformation::transform(TransformationContext& context, ov::pass::pattern::Matcher& m) {
if (!canBeTransformed(context, m.get_match_root())) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/transpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ bool TransposeTransformation::canBeTransformed(const TransformationContext& cont
}
}
if (dequantization.multiply != nullptr) {
const auto mulConst = ov::as_type_ptr<ngraph::op::v0::Constant>(dequantization.multiplyConstant);
const auto mulConst = ov::as_type_ptr<ov::op::v0::Constant>(dequantization.multiplyConstant);
if (!NetworkHelper::isScalarLike(mulConst)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ bool WeightableLayerTransformation::canBeTransformed(const TransformationContext
//
// [1] no other consumers for FQ sitting on weights (neither Result node, nor any others -
// original code includes separate checks for node being output and other consumers present; for
// ngraph it is a single check for number of consumers).
// openvino it is a single check for number of consumers).
//
// [2] if weights is anything except a constant with data_type other than i8; this check is overriden by
// stronger check from Convolution patter which expects FQ only on weights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace ngraph::builder::subgraph;
class GetDequantizationTestValues {
public:
FakeQuantizeOnData fakeQuantize;
// actual dequantization to create nGraph function to run NetworkHelper::getDequantization
// actual dequantization to create ov::Model to run NetworkHelper::getDequantization
DequantizationOperations actualDequantization;
DequantizationOperations expectedDequantization;
};
Expand Down
Loading

0 comments on commit eb9a553

Please sign in to comment.