Skip to content

Commit

Permalink
src/common/*transformations/ API1.0 clean up (openvinotoolkit#21574)
Browse files Browse the repository at this point in the history
* `src/common/transformations/` API1.0 cleanup

* `src/common/low_precision_transformations/` API1.0 cleanup

* Fix comments

* Fix
  • Loading branch information
vurusovs authored Dec 13, 2023
1 parent 34b2b66 commit ef14b50
Show file tree
Hide file tree
Showing 35 changed files with 107 additions and 115 deletions.
2 changes: 0 additions & 2 deletions src/common/low_precision_transformations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ ov_build_target_faster(${TARGET_NAME}_obj UNITY)
target_link_libraries(${TARGET_NAME}_obj PRIVATE openvino::itt)

target_include_directories(${TARGET_NAME}_obj PRIVATE $<BUILD_INTERFACE:${PUBLIC_HEADERS_DIR}>
$<BUILD_INTERFACE:$<TARGET_PROPERTY:ngraph,INTERFACE_INCLUDE_DIRECTORIES>>
$<BUILD_INTERFACE:$<TARGET_PROPERTY:inference_engine_transformations,INTERFACE_INCLUDE_DIRECTORIES>>)

add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME}_obj)
Expand All @@ -46,7 +45,6 @@ target_link_libraries(${TARGET_NAME} INTERFACE openvino::runtime)

target_include_directories(${TARGET_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:$<TARGET_PROPERTY:ngraph,INTERFACE_INCLUDE_DIRECTORIES>>
$<BUILD_INTERFACE:$<TARGET_PROPERTY:inference_engine_transformations,INTERFACE_INCLUDE_DIRECTORIES>>)

# LTO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include <memory>
#include <ngraph/ngraph.hpp>
#include "openvino/pass/pattern/matcher.hpp"
#include "low_precision/layer_transformation.hpp"

namespace ov {
Expand All @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API BatchToSpaceTransformation : public LayerTransforma
OPENVINO_RTTI("BatchToSpaceTransformation", "0");
BatchToSpaceTransformation(const Params& params = Params());
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> op) const override;
bool transform(TransformationContext& context, ngraph::pattern::Matcher &m) override;
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "ngraph/visibility.hpp"
#include "openvino/core/visibility.hpp"

/**
* @file lpt_visibility.hpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include <ngraph/ngraph.hpp>
#include "openvino/pass/pattern/matcher.hpp"
#include "low_precision/eltwise_base_transformation.hpp"

namespace ov {
Expand All @@ -23,7 +23,7 @@ class LP_TRANSFORMATIONS_API MultiplyPartialTransformation : public EltwiseBaseT
public:
OPENVINO_RTTI("MultiplyPartialTransformation", "0");
MultiplyPartialTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ngraph::pattern::Matcher &m) override;
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ class LP_TRANSFORMATIONS_API NetworkHelper {
std::shared_ptr<ov::Node> input = nullptr);

static std::shared_ptr<ov::Node> makeDequantizationSubtract(
const ngraph::Output<ov::Node>& parent,
const ngraph::Output<ov::Node>& subtract_constant);
const ov::Output<ov::Node>& parent,
const ov::Output<ov::Node>& subtract_constant);

static bool areQuantizeAndDequantizeSupportedForSubtract(const std::shared_ptr<const ov::Node>& node,
const std::vector<ov::element::Type>& defaultPrecisions = precision_set::get_int8_support());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include <memory>
#include <ngraph/ngraph.hpp>
#include "openvino/pass/pattern/matcher.hpp"
#include "low_precision/layer_transformation.hpp"

namespace ov {
Expand All @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API SpaceToBatchTransformation : public LayerTransforma
OPENVINO_RTTI("SpaceToBatchTransformation", "0");
SpaceToBatchTransformation(const Params& params = Params());
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> op) const override;
bool transform(TransformationContext& context, ngraph::pattern::Matcher &m) override;
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ bool MultiplyToGroupConvolutionTransformation::transform(TransformationContext&
const auto weightsNode = std::make_shared<ov::opset1::Constant>(weightsPrecision, weightsShape, weightsBuffer);

const size_t spatialDimsSize = pShape.rank().get_length() - 2;
ngraph::Strides strides(spatialDimsSize, 1ul);
ngraph::CoordinateDiff pads(spatialDimsSize, 0ul);
ngraph::Strides dilations(spatialDimsSize, 1ul);
ov::Strides strides(spatialDimsSize, 1ul);
ov::CoordinateDiff pads(spatialDimsSize, 0ul);
ov::Strides dilations(spatialDimsSize, 1ul);

const auto convolution = std::make_shared<ov::op::TypeRelaxed<ov::opset1::GroupConvolution>>(
std::vector<element::Type>{ element::f32, element::f32 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include <transformations/utils/utils.hpp>
#include <transformations/init_node_info.hpp>
#include <ngraph/opsets/opset2.hpp>
#include <low_precision/batch_to_space.hpp>

#include "common_test_utils/ov_test_utils.hpp"
Expand Down Expand Up @@ -51,14 +50,14 @@ class BatchToSpaceTransformationTestValues {
};

typedef std::tuple<
ngraph::PartialShape,
ov::PartialShape,
BatchToSpaceTransformationTestValues> BatchToSpaceTransformationParams;

class BatchToSpaceTransformation : public LayerTransformation,
public testing::WithParamInterface<BatchToSpaceTransformationParams> {
public:
void SetUp() override {
const ngraph::PartialShape input_shape = std::get<0>(GetParam());
const ov::PartialShape input_shape = std::get<0>(GetParam());
const BatchToSpaceTransformationTestValues test_values = std::get<1>(GetParam());

actualFunction = ngraph::builder::subgraph::BatchToSpaceFunction::get(
Expand All @@ -85,7 +84,7 @@ class BatchToSpaceTransformation : public LayerTransformation,
}

static std::string getTestCaseName(testing::TestParamInfo<BatchToSpaceTransformationParams> obj) {
const ngraph::PartialShape shape = std::get<0>(obj.param);
const ov::PartialShape shape = std::get<0>(obj.param);
const BatchToSpaceTransformationTestValues testValues = std::get<1>(obj.param);

std::ostringstream result;
Expand All @@ -109,7 +108,7 @@ TEST_P(BatchToSpaceTransformation, CompareFunctions) {
}

namespace testValues {
const std::vector<ngraph::PartialShape> input_shapes = {
const std::vector<ov::PartialShape> input_shapes = {
{4, 3, 50, 86}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ConvertSubtractConstantTransformationTestValues {
ngraph::builder::subgraph::DequantizationOperations dequantizationOnActivations;
ngraph::builder::subgraph::DequantizationOperations dequantizationOnWeights;
ngraph::builder::subgraph::Constant weights;
ngraph:: builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ov::element::Type precisionAfterOperation;
ngraph::builder::subgraph::DequantizationOperations dequantizationAfter;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class ConvolutionBackpropDataTransformationTestValues {
public:
ov::element::Type precisionBeforeDequantization;
ngraph::builder::subgraph::DequantizationOperations dequantizationOnActivations;
ngraph:: builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph:: builder::subgraph::DequantizationOperations dequantizationOnWeights;
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::DequantizationOperations dequantizationOnWeights;
std::shared_ptr<ov::op::v0::Constant> weights;
callback_function_type callback;

Expand Down Expand Up @@ -85,7 +85,7 @@ class ConvolutionBackpropDataTransformationTestValues {
public:
ov::element::Type precisionBeforeDequantization;
ngraph::builder::subgraph::DequantizationOperations dequantizationOnActivations;
ngraph:: builder::subgraph::DequantizationOperations dequantizationOnWeights;
ngraph::builder::subgraph::DequantizationOperations dequantizationOnWeights;
ngraph::builder::subgraph::DequantizationOperations dequantizationAfter;
std::shared_ptr<ov::op::v0::Constant> weights;
bool transformed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ConvolutionQDqTransformationTestValues {
ngraph::builder::subgraph::DequantizationOperations dequantizationOnActivations;
ngraph::builder::subgraph::DequantizationOperations dequantizationOnWeights;
ngraph::builder::subgraph::Constant weights;
ngraph:: builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ov::element::Type precisionAfterOperation;
ngraph::builder::subgraph::DequantizationOperations dequantizationAfter;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ class ConvolutionTransformationTestValues {
ov::element::Type precisionBeforeDequantization;
ngraph::builder::subgraph::DequantizationOperations dequantizationOnActivations;
std::shared_ptr<ov::op::v0::Constant> weights;
ngraph:: builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
};

class Expected {
public:
ov::element::Type precisionBeforeDequantization;
ngraph::builder::subgraph::DequantizationOperations dequantizationBefore;
std::shared_ptr<ov::op::v0::Constant> weights;
ngraph:: builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ov::element::Type precisionAfterOperation;
ngraph::builder::subgraph::DequantizationOperations dequantizationAfter;
ov::element::Type precisionAfterDequantization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class FakeQuantizeOnWeightsWithUnsupportedChildTestValues {
class Actual {
public:
std::shared_ptr<ov::op::v0::Constant> weights;
ngraph:: builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
};

class Expected {
public:
std::shared_ptr<ov::op::v0::Constant> weights;
ngraph:: builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
};

TestTransformationParams params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ using namespace ov::pass;
namespace {
class ActualValues {
public:
ngraph:: builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData;
ngraph:: builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData;
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
};

class ExpectedValues {
public:
element::Type fakeQuantizeOnDataOutPrecision;
ngraph:: builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData;
ngraph:: builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData;
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
};

class FakeQuantizePrecisionSelectionTransformationTestValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class FakeQuantizeTransformationTestValues {
addNotPrecisionPreservedOperation(addNotPrecisionPreservedOperation) {}

TestTransformationParams params;
ngraph:: builder::subgraph::FakeQuantizeOnDataWithConstant actual;
ngraph:: builder::subgraph::FakeQuantizeOnDataWithConstant expected;
ngraph::builder::subgraph::FakeQuantizeOnDataWithConstant actual;
ngraph::builder::subgraph::FakeQuantizeOnDataWithConstant expected;
ov::element::Type expectedFakeQuantizeOnDataPrecision;
std::map<ov::element::Type, ngraph::builder::subgraph::DequantizationOperations> expectedValues;
// add not precision preserved operation to set output precision for FakeQuantize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ class FakeQuantizeWithNotOptimalTransformationTestValues {
public:
class Values {
public:
ngraph:: builder::subgraph::FakeQuantizeOnDataWithConstant fqOnData;
ngraph:: builder::subgraph::DequantizationOperations::Convert convertOnData;
ngraph:: builder::subgraph::DequantizationOperations dequantizationOnData;
ngraph:: builder::subgraph::Constant constantOnWeights;
ngraph:: builder::subgraph::FakeQuantizeOnWeights fqOnWeights;
ngraph:: builder::subgraph::DequantizationOperations dequantizationOnWeights;
ngraph:: builder::subgraph::DequantizationOperations dequantizationAfter;
ngraph::builder::subgraph::FakeQuantizeOnDataWithConstant fqOnData;
ngraph::builder::subgraph::DequantizationOperations::Convert convertOnData;
ngraph::builder::subgraph::DequantizationOperations dequantizationOnData;
ngraph::builder::subgraph::Constant constantOnWeights;
ngraph::builder::subgraph::FakeQuantizeOnWeights fqOnWeights;
ngraph::builder::subgraph::DequantizationOperations dequantizationOnWeights;
ngraph::builder::subgraph::DequantizationOperations dequantizationAfter;
};
TestTransformationParams params;
Values actual;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ class FakeQuantizeWithDynamicIntervalsTransformation : public LayerTransformatio
auto fakeQuantize = std::make_shared<ov::op::v0::FakeQuantize>(input, inputLow, inputHigh, outputLow, outputHigh, levels);
fakeQuantize->set_friendly_name("fakeQuantize");

ngraph::ResultVector results{ std::make_shared<ov::op::v0::Result>(fakeQuantize) };
ov::ResultVector results{ std::make_shared<ov::op::v0::Result>(fakeQuantize) };

ngraph::ParameterVector inputs{ input };
ov::ParameterVector inputs{ input };
if (as_type_ptr<ov::op::v0::Parameter>(inputLow)) {
inputs.push_back(as_type_ptr<ov::op::v0::Parameter>(inputLow));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class FoldConvertTransformation : public LayerTransformation, public testing::Wi
output->set_friendly_name("output");

return std::make_shared<ov::Model>(
ngraph::ResultVector{ std::make_shared<ov::op::v0::Result>(output) },
ngraph::ParameterVector{ input },
ov::ResultVector{ std::make_shared<ov::op::v0::Result>(output) },
ov::ParameterVector{ input },
"FoldConvertTransformation");
};
actualFunction = createFunction(testValues.precision, inputShape, testValues.dequantizationActual);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FoldFakeQuantizeInTransformationsTestValues {
public:
std::vector<float> constValues;
ov::element::Type constPrecision;
ngraph:: builder::subgraph::FakeQuantizeOnData fakeQuantize;
ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize;
ov::element::Type fqOutPrecision;
};

Expand Down Expand Up @@ -90,10 +90,10 @@ class FoldFakeQuantizeInTransformations
testValues.actual.fqOutPrecision);
fq = ov::pass::low_precision::NetworkHelper::fold_fake_quantize(as_type_ptr<ov::op::v0::FakeQuantize>(fq),
testValues.roundValues);
ngraph::ResultVector results{std::make_shared<ov::op::v0::Result>(fq)};
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(fq)};
actualFunction = std::make_shared<ov::Model>(
results,
parameter ? ngraph::ParameterVector{parameter} : ngraph::ParameterVector{},
parameter ? ov::ParameterVector{parameter} : ov::ParameterVector{},
"FoldFakeQuantizeFunction");

referenceFunction =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ using namespace ov::pass;

class GetDequantizationBelowTestValues {
public:
ngraph:: builder::subgraph::FakeQuantizeOnData fakeQuantize;
ngraph:: builder::subgraph::DequantizationOperations dequantization;
ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize;
ngraph::builder::subgraph::DequantizationOperations dequantization;
};

inline std::ostream& operator<<(std::ostream& os, const std::vector<float>& values) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GroupConvolutionTestValues {
ov::element::Type precisionBeforeDequantization;
ngraph::builder::subgraph::DequantizationOperations dequantization;
std::shared_ptr<ov::op::v0::Constant> weights;
ngraph:: builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::DequantizationOperations dequantizationOnWeights;
};

Expand All @@ -38,7 +38,7 @@ class GroupConvolutionTestValues {
ov::element::Type precisionBeforeDequantization;
ngraph::builder::subgraph::DequantizationOperations dequantizationBefore;
std::shared_ptr<ov::op::v0::Constant> weights;
ngraph:: builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
ngraph::builder::subgraph::DequantizationOperations dequantizationOnWeights;
ov::element::Type precisionAfterOperation;
ngraph::builder::subgraph::DequantizationOperations dequantizationAfter;
Expand Down
Loading

0 comments on commit ef14b50

Please sign in to comment.