Remove legacy API from tests/ov_helpers/ (#21254)

* Remove legacy API from `tests/ov_helpers/`

* Build fix

* `ngraph::Function`->`ov::Model`

* ClangFormat

* Remove extra `#include <ngraph/ngraph.hpp>`

* Clean up headers

* `NGRAPH_CHECK` -> `OPENVINO_ASSERT`

* Refactor includes

* Fix precommit
This commit is contained in:
Vitaliy Urusovskij 2023-11-30 12:40:52 +04:00 committed by GitHub
parent 243898560f
commit 718b5a60bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
169 changed files with 3984 additions and 4048 deletions

View File

@ -96,7 +96,7 @@ public:
const InterpolateTransformationTestValues testValues = GetParam();
if (testValues.opset_version == 1) {
ngraph::op::InterpolateAttrs interpAttrs;
ov::op::v0::Interpolate::Attributes interpAttrs;
interpAttrs.axes = testValues.interpAttrs.axes;
interpAttrs.mode = testValues.interpAttrs.mode;
interpAttrs.align_corners = testValues.interpAttrs.align_corners;
@ -124,7 +124,7 @@ public:
testValues.expected.precisionAfterOperation,
testValues.expected.dequantizationAfter);
} else if (testValues.opset_version == 4) {
ngraph::op::v4::Interpolate::InterpolateAttrs interp4Attrs;
ov::op::v4::Interpolate::InterpolateAttrs interp4Attrs;
interp4Attrs.mode = testValues.interp4Attrs.mode;
interp4Attrs.coordinate_transformation_mode = testValues.interp4Attrs.coordinate_transformation_mode;
interp4Attrs.pads_begin = testValues.interp4Attrs.pads_begin;
@ -424,8 +424,8 @@ const std::vector<InterpolateTransformationTestValues> testValues {
LayerTransformation::createParamsU8I8(),
interpAttributes(),
interp4Attributes(
ngraph::op::v4::Interpolate::InterpolateMode::NEAREST,
ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL,
ov::op::v4::Interpolate::InterpolateMode::NEAREST,
ov::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL,
{0, 0, 0, 0},
{0, 0, 0, 0}),
4,
@ -449,8 +449,8 @@ const std::vector<InterpolateTransformationTestValues> testValues {
LayerTransformation::createParamsU8I8(),
interpAttributes(),
interp4Attributes(
ngraph::op::v4::Interpolate::InterpolateMode::NEAREST,
ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL,
ov::op::v4::Interpolate::InterpolateMode::NEAREST,
ov::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL,
{0, 0, 0, 0},
{0, 0, 0, 0}),
4,
@ -474,8 +474,8 @@ const std::vector<InterpolateTransformationTestValues> testValues {
LayerTransformation::createParamsU8I8(),
interpAttributes(),
interp4Attributes(
ngraph::op::v4::Interpolate::InterpolateMode::NEAREST,
ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL,
ov::op::v4::Interpolate::InterpolateMode::NEAREST,
ov::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL,
{0, 0, 0, 0},
{0, 0, 0, 0}),
4,
@ -499,8 +499,8 @@ const std::vector<InterpolateTransformationTestValues> testValues {
LayerTransformation::createParamsU8I8(),
interpAttributes(),
interp4Attributes(
ngraph::op::v4::Interpolate::InterpolateMode::NEAREST,
ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL,
ov::op::v4::Interpolate::InterpolateMode::NEAREST,
ov::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL,
{0, 0, 0, 0},
{0, 0, 0, 0}),
4,
@ -524,8 +524,8 @@ const std::vector<InterpolateTransformationTestValues> testValues {
LayerTransformation::createParamsU8I8(),
interpAttributes(),
interp4Attributes(
ngraph::op::v4::Interpolate::InterpolateMode::LINEAR_ONNX,
ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL,
ov::op::v4::Interpolate::InterpolateMode::LINEAR_ONNX,
ov::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL,
{0, 0, 0, 0},
{0, 0, 0, 0}),
4,
@ -549,8 +549,8 @@ const std::vector<InterpolateTransformationTestValues> testValues {
LayerTransformation::createParamsU8I8(),
interpAttributes(),
interp4Attributes(
ngraph::op::v4::Interpolate::InterpolateMode::NEAREST,
ngraph::op::v4::Interpolate::CoordinateTransformMode::ALIGN_CORNERS,
ov::op::v4::Interpolate::InterpolateMode::NEAREST,
ov::op::v4::Interpolate::CoordinateTransformMode::ALIGN_CORNERS,
{0, 0, 0, 0},
{0, 0, 0, 0}),
4,
@ -574,8 +574,8 @@ const std::vector<InterpolateTransformationTestValues> testValues {
LayerTransformation::createParamsU8I8(),
interpAttributes(),
interp4Attributes(
ngraph::op::v4::Interpolate::InterpolateMode::NEAREST,
ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL,
ov::op::v4::Interpolate::InterpolateMode::NEAREST,
ov::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL,
{0, 0, 0, 1},
{0, 0, 1, 0}),
4,

View File

@ -6,7 +6,7 @@
#include <map>
#include "openvino/pass/manager.hpp"
#include "layer_transformation.hpp"
#include "common_test_utils/test_common.hpp"
@ -14,7 +14,7 @@
#include "low_precision/common/precisions_restriction.hpp"
#include "low_precision/common/quantization_granularity_restriction.hpp"
class SimpleLowPrecisionTransformer : public ngraph::pass::FunctionPass{
class SimpleLowPrecisionTransformer : public ov::pass::ModelPass{
public:
SimpleLowPrecisionTransformer(
const std::vector<ov::pass::low_precision::PrecisionsRestriction>& precisionRestrictions = {},

View File

@ -5,8 +5,8 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <low_precision/layer_transformation.hpp>
#include "low_precision/layer_transformation.hpp"
#include "elementwise.hpp"
#include "ov_lpt_models/common/builders.hpp"
@ -20,10 +20,10 @@ namespace subgraph {
class AddActualValues {
public:
ngraph::element::Type precision1;
ov::element::Type precision1;
std::vector<float> subtractValues1;
std::vector<float> mutliplyValues1;
ngraph::element::Type precision2;
ov::element::Type precision2;
std::vector<float> subtractValues2;
std::vector<float> mutliplyValues2;
};
@ -40,10 +40,10 @@ inline std::ostream& operator<<(std::ostream& out, const AddActualValues& values
class AddExpectedValues {
public:
ngraph::element::Type precision1;
ov::element::Type precision1;
std::vector<float> subtractValues1;
std::vector<float> mutliplyValues1;
ngraph::element::Type precision2;
ov::element::Type precision2;
std::vector<float> mutliplyValuesAfter;
};
@ -58,37 +58,37 @@ inline std::ostream& operator<<(std::ostream& out, const AddExpectedValues& valu
class AddFunction : public ElementwiseFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape1,
const ngraph::PartialShape& inputShape2,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape1,
const ov::PartialShape& inputShape2,
const bool broadcast,
const ov::pass::low_precision::LayerTransformation::Params& params,
const ngraph::element::Type& precision1,
const ov::element::Type& precision1,
const ngraph::builder::subgraph::DequantizationOperations& dequantization1,
const ngraph::element::Type& precision2,
const ov::element::Type& precision2,
const ngraph::builder::subgraph::DequantizationOperations& dequantization2,
const int constInput,
const std::vector<float>& constValues,
const std::string& additionalLayer,
const std::string& postops_configuration = "");
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const bool broadcast,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData1,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData2);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape1,
const ngraph::PartialShape& inputShape2,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::PartialShape& inputShape1,
const ov::PartialShape& inputShape2,
const bool broadcast,
const ov::pass::low_precision::LayerTransformation::Params& params,
const ngraph::element::Type& precision1,
const ov::element::Type& precision1,
const ngraph::builder::subgraph::DequantizationOperations& dequantization1,
const ngraph::element::Type& precision2,
const ov::element::Type& precision2,
const ngraph::builder::subgraph::DequantizationOperations& dequantization2,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter,
const int constInput,

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/fake_quantize_on_data.hpp"
@ -17,22 +16,22 @@ namespace subgraph {
class AlignConcatQuantizationParametersFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::element::Type inputPrecision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::element::Type inputPrecision,
const ov::Shape& inputShape,
const bool addFQ,
const std::string additionalLayer,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::element::Type inputPrecision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::element::Type inputPrecision,
const ov::Shape& inputShape,
const bool addFQ,
const std::string additionalLayer,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -6,7 +6,6 @@
#include <sstream>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -16,25 +15,25 @@ namespace subgraph {
class AssignAndReadValueFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const element::Type& inputPrecision,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const size_t opsetVersion,
const bool FQAfterReadValue,
const std::vector<float>& constantValue,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type originalFunctionPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type originalFunctionPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize,
const size_t opsetVersion);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const element::Type& inputPrecision,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const size_t opsetVersion,
const bool FQAfterReadValue,
const std::vector<float>& constantValue,

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/fake_quantize_on_data.hpp"
@ -17,27 +16,27 @@ namespace subgraph {
class AvgPoolFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const bool addFQ,
const std::vector<std::string>& additionalLayers,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type originalFunctionPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type originalFunctionPrecision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fakeQuantizeOnData);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const bool addFQ,
const std::vector<std::string>& additionalLayers,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationEnd);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <vector>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
@ -15,15 +14,15 @@ namespace subgraph {
class BatchToSpaceFunction {
public:
static std::shared_ptr<ngraph::Function> get(const ngraph::PartialShape& input_shape,
const ngraph::element::Type input_type,
static std::shared_ptr<ov::Model> get(const ov::PartialShape& input_shape,
const ov::element::Type input_type,
const FakeQuantizeOnData& fq_on_data,
const std::vector<size_t>& block_shape,
const std::vector<size_t>& crops_begin,
const std::vector<size_t>& crops_end);
static std::shared_ptr<ngraph::Function> get(const ngraph::PartialShape& input_shape,
const ngraph::element::Type input_type,
static std::shared_ptr<ov::Model> get(const ov::PartialShape& input_shape,
const ov::element::Type input_type,
const ngraph::builder::subgraph::DequantizationOperations& dequantization_before,
const std::vector<size_t>& block_shape,
const std::vector<size_t>& crops_begin,

View File

@ -6,7 +6,6 @@
#include <sstream>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -16,27 +15,27 @@ namespace subgraph {
class ClampFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> getWithNonDequantizationMultiply(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precision);
static std::shared_ptr<ov::Model> getWithNonDequantizationMultiply(
const ov::PartialShape& inputShape,
const ov::element::Type precision);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type originalFunctionPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type originalFunctionPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize,
const double clampLowConst,
const double clampHighConst);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};
} // namespace subgraph

View File

@ -4,7 +4,10 @@
#pragma once
#include <ngraph/ngraph.hpp>
#include <vector>
#include "openvino/core/shape.hpp"
#include "openvino/core/type/element_type.hpp"
namespace ngraph {
namespace builder {
@ -15,13 +18,13 @@ public:
Add();
Add(const float value);
Add(const std::vector<float>& values);
Add(const std::vector<float>& values, const ngraph::element::Type outPrecision);
Add(const std::vector<float>& values, const ngraph::element::Type outPrecision, const ngraph::Shape& constantShape);
Add(const std::vector<float>& values, const ov::element::Type outPrecision);
Add(const std::vector<float>& values, const ov::element::Type outPrecision, const ov::Shape& constantShape);
bool empty() const noexcept;
std::vector<float> values;
ngraph::element::Type outPrecision;
ngraph::Shape constantShape;
ov::element::Type outPrecision;
ov::Shape constantShape;
bool constantShapeIsDefined;
private:
bool isEmpty;

View File

@ -5,9 +5,8 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <ngraph/ops.hpp>
#include <ngraph/op/constant.hpp>
#include "openvino/op/constant.hpp"
#include "ov_ops/type_relaxed.hpp"
#include "low_precision/rt_info/intervals_alignment_attribute.hpp"
@ -26,7 +25,7 @@ namespace builder {
namespace subgraph {
template <typename Operation, typename OperationDesc>
std::shared_ptr<Node> makeElementwise(const std::shared_ptr<ngraph::Node> data, const OperationDesc& description) {
std::shared_ptr<Node> makeElementwise(const std::shared_ptr<ov::Node> data, const OperationDesc& description) {
std::vector<size_t> shape;
if (description.constantShapeIsDefined) {
shape = description.constantShape;
@ -76,28 +75,28 @@ std::shared_ptr<Node> makeTranspose(const Output<Node>& data, const Transpose& r
std::shared_ptr<ov::opset1::FakeQuantize> makeFakeQuantize(
const Output<Node>& output,
const ngraph::element::Type precision,
const ov::element::Type precision,
const FakeQuantizeOnData& fqOnData);
std::shared_ptr<ov::opset1::Convolution> makeConvolution(const Output<Node>& output, const Convolution& convolution);
std::shared_ptr<ov::opset1::FakeQuantize> makeFakeQuantizeTypeRelaxed(
const Output<ngraph::Node>& output,
const ngraph::element::Type precision,
const Output<ov::Node>& output,
const ov::element::Type precision,
const FakeQuantizeOnData& fqOnData);
std::shared_ptr<ov::opset1::FakeQuantize> makeFakeQuantize(
const Output<Node>& input,
const ngraph::element::Type constantPrecision,
const ov::element::Type constantPrecision,
const FakeQuantizeOnDataWithConstant& fqOnData,
const bool subgraphOnConstantPath = false);
std::shared_ptr<ov::opset1::FakeQuantize> makeFakeQuantizeTypeRelaxed(
const std::shared_ptr<ngraph::Node>& input,
const ngraph::element::Type constantPrecision,
const std::shared_ptr<ov::Node>& input,
const ov::element::Type constantPrecision,
const FakeQuantizeOnDataWithConstant& fqOnData);
void addAttributes(std::vector<std::shared_ptr<ngraph::Node>> nodes, std::vector<ov::Any> attributes);
void addAttributes(std::vector<std::shared_ptr<ov::Node>> nodes, std::vector<ov::Any> attributes);
std::shared_ptr<Node> makeConvolution(
const std::shared_ptr<Node>& parent,

View File

@ -8,7 +8,8 @@
#include <string>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "openvino/core/shape.hpp"
#include "openvino/core/type/element_type.hpp"
namespace ngraph {
namespace builder {
@ -19,13 +20,13 @@ public:
Constant();
Constant(const float value);
Constant(const std::vector<float>& values);
Constant(const std::vector<float>& values, const ngraph::element::Type outPrecision);
Constant(const std::vector<float>& values, const ngraph::element::Type outPrecision, const ngraph::Shape& shape);
Constant(const std::vector<float>& values, const ov::element::Type outPrecision);
Constant(const std::vector<float>& values, const ov::element::Type outPrecision, const ov::Shape& shape);
bool empty() const noexcept;
std::vector<float> values;
ngraph::element::Type outPrecision;
ngraph::Shape shape;
ov::element::Type outPrecision;
ov::Shape shape;
bool shapeIsDefined;
private:
bool isEmpty;

View File

@ -6,7 +6,6 @@
#include <memory>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "constant.hpp"
#include "dequantization_operations.hpp"

View File

@ -4,8 +4,8 @@
#pragma once
#include <ngraph/ngraph.hpp>
#include "fake_quantize_on_data.hpp"
#include "openvino/core/node.hpp"
namespace ngraph {
namespace builder {
@ -16,14 +16,14 @@ public:
class Convert {
public:
Convert();
Convert(const ngraph::element::Type outPrecision, const bool toRemove = true);
Convert(const ov::element::Type outPrecision, const bool toRemove = true);
bool empty() const noexcept;
bool equal(const DequantizationOperations::Convert& value) const noexcept;
bool operator==(const Convert& value) const noexcept {
return equal(value);
}
ngraph::element::Type outPrecision = element::undefined;
ov::element::Type outPrecision = element::undefined;
bool addDequantizationAttribute = true;
private:
bool isEmpty;
@ -34,14 +34,14 @@ public:
Subtract();
Subtract(const float value, const bool toRemove = true);
Subtract(const std::vector<float>& values);
Subtract(const std::vector<float>& values, const ngraph::element::Type outPrecision);
Subtract(const std::vector<float>& values, const ov::element::Type outPrecision);
Subtract(
const std::vector<float>& values,
const ngraph::element::Type outPrecision,
const ngraph::Shape& constantShape,
const ov::element::Type outPrecision,
const ov::Shape& constantShape,
const bool toRemove = false,
const size_t constantIndex = 1ul,
const ngraph::element::Type constantPrecision = ngraph::element::undefined,
const ov::element::Type constantPrecision = ov::element::undefined,
const bool addConvert = false,
const ov::Node::RTMap& attributes = {},
const ov::Node::RTMap& convertAttributes = {});
@ -53,14 +53,14 @@ public:
void erase() {
isEmpty = true;
}
Subtract& setConstantPrecision(const ngraph::element::Type& precision);
Subtract& setConstantPrecision(const ov::element::Type& precision);
std::vector<float> values;
ngraph::element::Type outPrecision = ngraph::element::undefined;
ngraph::Shape constantShape;
ov::element::Type outPrecision = ov::element::undefined;
ov::Shape constantShape;
bool constantShapeIsDefined = false;
size_t constantIndex = 1ul;
ngraph::element::Type constantPrecision = ngraph::element::undefined;
ov::element::Type constantPrecision = ov::element::undefined;
bool addConvert = false;
ov::Node::RTMap attributes;
ov::Node::RTMap convertAttributes;
@ -74,27 +74,27 @@ public:
Multiply();
Multiply(const float value);
Multiply(const std::vector<float>& values);
Multiply(const std::vector<float>& values, const ngraph::element::Type outPrecision);
Multiply(const std::vector<float>& values, const ov::element::Type outPrecision);
Multiply(
const std::vector<float>& values,
const ngraph::element::Type outPrecision,
const ngraph::Shape& constantShape,
const ov::element::Type outPrecision,
const ov::Shape& constantShape,
const bool toRemove = false,
const size_t constantIndex = 1ul,
const ngraph::element::Type constantPrecision = ngraph::element::undefined);
const ov::element::Type constantPrecision = ov::element::undefined);
bool empty() const noexcept;
bool equal(const DequantizationOperations::Multiply& value) const noexcept;
bool operator==(const Multiply& value) const noexcept {
return equal(value);
}
Multiply& setConstantPrecision(const ngraph::element::Type& precision);
Multiply& setConstantPrecision(const ov::element::Type& precision);
std::vector<float> values;
ngraph::element::Type outPrecision = ngraph::element::undefined;
ngraph::Shape constantShape;
ov::element::Type outPrecision = ov::element::undefined;
ov::Shape constantShape;
bool constantShapeIsDefined = false;
size_t constantIndex = 1ul;
ngraph::element::Type constantPrecision = ngraph::element::undefined;
ov::element::Type constantPrecision = ov::element::undefined;
private:
bool isEmpty;
@ -109,7 +109,7 @@ public:
bool operator==(const DequantizationOperations& value) const noexcept {
return equal(value);
}
void setPrecision(const ngraph::element::Type& type) noexcept;
void setPrecision(const ov::element::Type& type) noexcept;
Convert convert;
Subtract subtract;

View File

@ -7,7 +7,9 @@
#include <cstdint>
#include <memory>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "openvino/core/shape.hpp"
#include "openvino/core/type/element_type.hpp"
namespace ngraph {
namespace builder {
@ -19,12 +21,12 @@ public:
FakeQuantizeOnData(
const uint64_t quantizationLevel,
const ngraph::Shape& constantShape,
const ov::Shape& constantShape,
const std::vector<float>& inputLowValues,
const std::vector<float>& inputHighValues,
const std::vector<float>& outputLowValues,
const std::vector<float>& outputHighValues,
const ngraph::element::Type outputPrecision = ngraph::element::undefined,
const ov::element::Type outputPrecision = ov::element::undefined,
const std::vector<ov::Any>& attributes = {});
virtual ~FakeQuantizeOnData();
@ -33,12 +35,12 @@ public:
virtual bool empty() const;
uint64_t quantizationLevel;
ngraph::Shape constantShape;
ov::Shape constantShape;
std::vector<float> inputLowValues;
std::vector<float> inputHighValues;
std::vector<float> outputLowValues;
std::vector<float> outputHighValues;
ngraph::element::Type outputPrecision;
ov::element::Type outputPrecision;
std::vector<ov::Any> attributes;
};
@ -64,7 +66,7 @@ inline std::ostream& operator<<(std::ostream& out, const FakeQuantizeOnData& dat
"_input_high=" << data.inputHighValues <<
"_output_low=" << data.outputLowValues <<
"_output_high" << data.outputHighValues <<
"_precision=" << (data.outputPrecision == ngraph::element::undefined ? "" : data.outputPrecision.get_type_name());
"_precision=" << (data.outputPrecision == ov::element::undefined ? "" : data.outputPrecision.get_type_name());
}
class FakeQuantizeOnDataWithConstant {
@ -73,12 +75,12 @@ public:
FakeQuantizeOnDataWithConstant(
const uint64_t quantizationLevel,
const std::vector<ngraph::Shape>& constantShapes,
const std::vector<ov::Shape>& constantShapes,
const std::vector<float>& inputLowValues,
const std::vector<float>& inputHighValues,
const std::vector<float>& outputLowValues,
const std::vector<float>& outputHighValues,
const ngraph::element::Type outputPrecision = ngraph::element::undefined,
const ov::element::Type outputPrecision = ov::element::undefined,
const std::vector<ov::Any>& attributes = {},
const bool addConverts = false);
virtual ~FakeQuantizeOnDataWithConstant();
@ -86,12 +88,12 @@ public:
virtual bool empty() const;
uint64_t quantizationLevel;
std::vector<ngraph::Shape> constantShapes;
std::vector<ov::Shape> constantShapes;
std::vector<float> inputLowValues;
std::vector<float> inputHighValues;
std::vector<float> outputLowValues;
std::vector<float> outputHighValues;
ngraph::element::Type outputPrecision;
ov::element::Type outputPrecision;
std::vector<ov::Any> attributes;
bool addConverts;
};
@ -101,12 +103,12 @@ inline std::ostream& operator<<(std::ostream& out, const FakeQuantizeOnDataWithC
return out << "{}";
}
return out << "level=" << data.quantizationLevel <<
"_shape=" <<(data.constantShapes.empty() ? ngraph::Shape{} : data.constantShapes[0]) <<
"_shape=" <<(data.constantShapes.empty() ? ov::Shape{} : data.constantShapes[0]) <<
"_input_low=" << data.inputLowValues <<
"_input_high=" << data.inputHighValues <<
"_output_low=" << data.outputLowValues <<
"_output_high=" << data.outputHighValues <<
"_precision=" << (data.outputPrecision == ngraph::element::undefined ? "" : data.outputPrecision.get_type_name());
"_precision=" << (data.outputPrecision == ov::element::undefined ? "" : data.outputPrecision.get_type_name());
}
} // namespace subgraph

View File

@ -7,7 +7,6 @@
#include <cstdint>
#include <memory>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "fake_quantize_on_data.hpp"
namespace ngraph {
@ -20,12 +19,12 @@ public:
FakeQuantizeOnWeights(
const uint64_t quantizationLevel,
const ngraph::Shape& constantShape,
const ov::Shape& constantShape,
const std::vector<float>& inputLowValues,
const std::vector<float>& inputHighValues,
const std::vector<float>& outputLowValues,
const std::vector<float>& outputHighValues,
const ngraph::element::Type outputPrecision = ngraph::element::undefined);
const ov::element::Type outputPrecision = ov::element::undefined);
virtual ~FakeQuantizeOnWeights();

View File

@ -4,7 +4,10 @@
#pragma once
#include <ngraph/ngraph.hpp>
#include <vector>
#include "openvino/core/shape.hpp"
#include "openvino/core/type/element_type.hpp"
namespace ngraph {
namespace builder {
@ -15,13 +18,13 @@ public:
Multiply();
Multiply(const float value);
Multiply(const std::vector<float>& values);
Multiply(const std::vector<float>& values, const ngraph::element::Type outPrecision);
Multiply(const std::vector<float>& values, const ngraph::element::Type outPrecision, const ngraph::Shape& constantShape);
Multiply(const std::vector<float>& values, const ov::element::Type outPrecision);
Multiply(const std::vector<float>& values, const ov::element::Type outPrecision, const ov::Shape& constantShape);
bool empty() const noexcept;
std::vector<float> values;
ngraph::element::Type outPrecision;
ngraph::Shape constantShape;
ov::element::Type outPrecision;
ov::Shape constantShape;
bool constantShapeIsDefined;
private:
bool isEmpty;

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_models/subgraph_builders.hpp"
@ -16,9 +15,9 @@ namespace subgraph {
class ComposeFakeQuantizeFunction {
public:
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ngraph::builder::subgraph::FakeQuantizeOnData& fakeQuantizeOnData,
const ngraph::builder::subgraph::DequantizationOperations& dequantization1,
const ngraph::builder::subgraph::DequantizationOperations& dequantization2);

View File

@ -6,7 +6,6 @@
#include <algorithm>
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/fake_quantize_on_data.hpp"
#include "common/dequantization_operations.hpp"
@ -26,9 +25,9 @@ public:
const ov::element::Type precisionAfter = ov::element::undefined,
const DequantizationOperations& dequantizationAfter = {});
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const std::shared_ptr<ov::opset1::Constant>& input_constant1,
const FakeQuantizeOnData& fakeQuantize1,
const DequantizationOperations& dequantization1,
@ -36,87 +35,87 @@ public:
const FakeQuantizeOnData& fakeQuantize2,
const DequantizationOperations& dequantization2);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::Shape& inputShape,
const FakeQuantizeOnDataWithConstant& fakeQuantize1,
const FakeQuantizeOnDataWithConstant& fakeQuantize2);
static std::shared_ptr<ngraph::Function> getOriginalWithChildAndOutput(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginalWithChildAndOutput(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fakeQuantize1,
const FakeQuantizeOnData& fakeQuantize2);
static std::shared_ptr<ngraph::Function> getOriginalWithNeighbors(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginalWithNeighbors(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const FakeQuantizeOnData& fqOnData3,
const std::string& neighborType,
const std::string& additionalLayer);
static std::shared_ptr<ngraph::Function> getOriginalWithIntermediate(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginalWithIntermediate(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const bool transparentIntermediate,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2);
static std::shared_ptr<ngraph::Function> getOriginalWithIntermediateAvgPool(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginalWithIntermediateAvgPool(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2);
static std::shared_ptr<ngraph::Function> getOriginalWithSplitedIntermediate(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginalWithSplitedIntermediate(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const bool addConvolution);
static std::shared_ptr<ngraph::Function> getOriginalSelectionWithIntermediate(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getOriginalSelectionWithIntermediate(
const ov::element::Type precision,
const ov::Shape& inputShape,
const bool transparentIntermediate,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2);
static std::shared_ptr<ngraph::Function> getOriginalWithStridedSlice(
const ngraph::element::Type precision,
const ngraph::PartialShape inputShape,
static std::shared_ptr<ov::Model> getOriginalWithStridedSlice(
const ov::element::Type precision,
const ov::PartialShape inputShape,
const FakeQuantizeOnData& fq1,
const FakeQuantizeOnData& fq2,
const bool ssBeforeConcat,
const bool ssAfterConcat);
static std::shared_ptr<ngraph::Function> getOriginalWithDifferentPrecisionOnChildren(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginalWithDifferentPrecisionOnChildren(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const std::int64_t axis,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2);
static std::shared_ptr<ngraph::Function> getOriginalWithIntermediateWithConstant(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginalWithIntermediateWithConstant(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const bool transparentIntermediate,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2);
static std::shared_ptr<ngraph::Function> getOriginalWithReshapeAtTheEndTransformation(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getOriginalWithReshapeAtTheEndTransformation(
const ov::element::Type precision,
const ov::Shape& inputShape,
const FakeQuantizeOnDataWithConstant& fqOnData1,
const FakeQuantizeOnDataWithConstant& fqOnData2,
const FakeQuantizeOnDataWithConstant& fqOnData3);
static std::shared_ptr<ngraph::Function> getOriginalWithIntermediateReshape(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
const ngraph::Shape& reshapeOutputShape,
static std::shared_ptr<ov::Model> getOriginalWithIntermediateReshape(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ov::Shape& reshapeOutputShape,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2);
@ -129,16 +128,16 @@ public:
const DequantizationOperations& dequantizationAfter,
const std::int64_t concatAxis);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::Shape& inputShape,
const FakeQuantizeOnData& fakeQuantize1,
const FakeQuantizeOnData& fakeQuantize2,
const DequantizationOperations& dequantizationOperations);
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnDataWithConstant& fakeQuantize1,
const DequantizationOperations::Convert& convert1,
const DequantizationOperations& dequantization1,
@ -146,148 +145,148 @@ public:
const DequantizationOperations::Convert& convert2,
const DequantizationOperations& dequantization2,
const std::vector<ov::Any>& concatAttributes,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const DequantizationOperations& dequantizationAfter,
const std::int64_t& axis,
const bool addNotPrecisionPreservedOperation = false);
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type inputPrecision,
const ngraph::Shape& inputShape1,
static std::shared_ptr<ov::Model> get(
const ov::element::Type inputPrecision,
const ov::Shape& inputShape1,
const FakeQuantizeOnDataWithConstant& fakeQuantize1,
const DequantizationOperations::Convert& convert1,
const DequantizationOperations& dequantization1,
const bool addReshape1,
const ngraph::Shape& inputShape2,
const ov::Shape& inputShape2,
const FakeQuantizeOnDataWithConstant& fakeQuantize2,
const DequantizationOperations::Convert& convert2,
const DequantizationOperations& dequantization2,
const bool addReshape2,
const std::vector<ov::Any>& concatAttributes,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const DequantizationOperations& dequantizationAfter,
const std::int64_t& axis,
const bool addNotPrecisionPreservedOperation = false);
static std::shared_ptr<ngraph::Function> getReferenceWithNeighbors(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReferenceWithNeighbors(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const FakeQuantizeOnData& fqOnData3,
const ngraph::element::Type precisionBeforeOp,
const ov::element::Type precisionBeforeOp,
const DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const DequantizationOperations& dequantizationOperations1,
const DequantizationOperations& dequantizationOperations2,
const std::string& neighborType,
const std::string& additionalLayer);
// TODO: refactor: dequantizationBefore2 <=> dequantizationOperations2
static std::shared_ptr<ngraph::Function> getReferenceWithIntermediate(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReferenceWithIntermediate(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const bool transparentIntermediate,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const ngraph::element::Type precisionBeforeOp,
const ov::element::Type precisionBeforeOp,
const DequantizationOperations& dequantizationBefore1,
const DequantizationOperations& dequantizationOperations2,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const DequantizationOperations& dequantizationOperations1,
const DequantizationOperations& dequantizationBefore2);
static std::shared_ptr<ngraph::Function> getReferenceWithIntermediateAvgPool(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReferenceWithIntermediateAvgPool(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const ngraph::element::Type precisionBeforeOp,
const ov::element::Type precisionBeforeOp,
const DequantizationOperations& dequantizationBefore1,
const DequantizationOperations& dequantizationBefore2,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const DequantizationOperations& dequantizationOperations1,
const DequantizationOperations& dequantizationOperations2);
static std::shared_ptr<ngraph::Function> getReferenceWithSplitedIntermediate(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReferenceWithSplitedIntermediate(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const ngraph::element::Type precisionBeforeOp,
const ov::element::Type precisionBeforeOp,
const DequantizationOperations& dequantizationBefore1,
const DequantizationOperations& dequantizationBefore2,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const bool addConvolution,
const DequantizationOperations& dequantizationOperations1,
const DequantizationOperations& dequantizationOperations2);
static std::shared_ptr<ngraph::Function> getReferenceSelectionWithIntermediate(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getReferenceSelectionWithIntermediate(
const ov::element::Type precision,
const ov::Shape& inputShape,
const bool transparentIntermediate,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const ngraph::element::Type precisionBeforeOp,
const ov::element::Type precisionBeforeOp,
const DequantizationOperations& dequantizationBefore1,
const DequantizationOperations& dequantizationBefore2,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const DequantizationOperations& dequantizationOperations1,
const DequantizationOperations& dequantizationOperations2);
static std::shared_ptr<ngraph::Function> getReferenceWithStridedSlice(
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape inputShape,
static std::shared_ptr<ov::Model> getReferenceWithStridedSlice(
const ov::element::Type inputPrecision,
const ov::PartialShape inputShape,
const FakeQuantizeOnData& fq1,
const FakeQuantizeOnData& fq2,
const DequantizationOperations& deqBefore,
const ngraph::element::Type precisionBeforeConcat,
const ngraph::element::Type precisionAfterConcat,
const ov::element::Type precisionBeforeConcat,
const ov::element::Type precisionAfterConcat,
const bool ssBeforeConcat,
const bool ssAfterConcat,
const DequantizationOperations& deqAfter1,
const DequantizationOperations& deqAfter2);
static std::shared_ptr<ngraph::Function> getReferenceWithDifferentPrecisionOnChildren(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReferenceWithDifferentPrecisionOnChildren(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const bool multiChannel,
const std::int64_t axis,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const ngraph::element::Type precisionBeforeOp,
const ov::element::Type precisionBeforeOp,
const DequantizationOperations& dequantizationBefore1,
const DequantizationOperations& dequantizationBefore2,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const DequantizationOperations& dequantizationAfter1,
const DequantizationOperations& dequantizationAfter2);
static std::shared_ptr<ngraph::Function> getReferenceWithIntermediateWithConstant(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReferenceWithIntermediateWithConstant(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const bool transparentIntermediate,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const ngraph::element::Type precisionBeforeOp,
const ov::element::Type precisionBeforeOp,
const DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const DequantizationOperations& dequantizationAfter,
const ngraph::element::Type precisionAfterDequantization);
const ov::element::Type precisionAfterDequantization);
static std::shared_ptr<ngraph::Function> getReferenceWithReshapeAtTheEndTransformation(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getReferenceWithReshapeAtTheEndTransformation(
const ov::element::Type precision,
const ov::Shape& inputShape,
const FakeQuantizeOnDataWithConstant& fqOnData1,
const FakeQuantizeOnDataWithConstant& fqOnData2,
const FakeQuantizeOnDataWithConstant& fqOnData3,
const ngraph::element::Type precisionBeforeOp,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionBeforeOp,
const ov::element::Type precisionAfterOperation,
const DequantizationOperations& dequantizationOperations);
static std::shared_ptr<ngraph::Function> getReferenceWithIntermediateReshape(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
const ngraph::Shape& reshapeOutputShape,
static std::shared_ptr<ov::Model> getReferenceWithIntermediateReshape(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ov::Shape& reshapeOutputShape,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const DequantizationOperations& dequantizationAfter);

View File

@ -5,8 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <ngraph/opsets/opset1.hpp>
#include <low_precision/common/quantization_granularity_restriction.hpp>
@ -20,12 +18,12 @@ namespace subgraph {
class ConvolutionFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type netPrecision,
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type netPrecision,
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationOnActivations,
std::shared_ptr<ngraph::opset1::Constant> weights,
std::shared_ptr<ov::opset1::Constant> weights,
const ngraph::builder::subgraph::FakeQuantizeOnWeights fqOnWeights,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationOnWeights = DequantizationOperations(),
const bool fqOnWeightsTransposeOnData = false,
@ -34,42 +32,42 @@ public:
const bool fqOnWeightsTransposeOnOutputLow = false,
const bool fqOnWeightsTransposeOnOutputHigh = false);
static std::shared_ptr<ngraph::Function> getOriginalWithIncorrectWeights(
const ngraph::Shape& inputShape,
ngraph::element::Type precision,
static std::shared_ptr<ov::Model> getOriginalWithIncorrectWeights(
const ov::Shape& inputShape,
ov::element::Type precision,
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights,
ngraph::builder::subgraph::DequantizationOperations dequantization,
bool isCrorrect);
static std::shared_ptr<ngraph::Function> getOriginalWithIncorrectWeights(
const ngraph::PartialShape& inputShape,
ngraph::element::Type precision,
static std::shared_ptr<ov::Model> getOriginalWithIncorrectWeights(
const ov::PartialShape& inputShape,
ov::element::Type precision,
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights,
ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData,
bool isCorrect);
static std::shared_ptr<ngraph::Function> getReferenceWithIncorrectWeights(
const ngraph::Shape& inputShape,
ngraph::element::Type inputPrecision,
static std::shared_ptr<ov::Model> getReferenceWithIncorrectWeights(
const ov::Shape& inputShape,
ov::element::Type inputPrecision,
ngraph::builder::subgraph::DequantizationOperations dequantizationBefore,
ngraph::element::Type weightsPrecision,
ov::element::Type weightsPrecision,
std::vector<float> weightsValues,
ngraph::builder::subgraph::DequantizationOperations dequantizationAfter);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type netPrecision,
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type netPrecision,
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
std::shared_ptr<ngraph::opset1::Constant> weights,
std::shared_ptr<ov::opset1::Constant> weights,
const ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter,
const ngraph::element::Type precisionAfterDequantization);
const ov::element::Type precisionAfterDequantization);
static std::shared_ptr<ngraph::Function> get(
const ngraph::Shape& inputShape,
const ngraph::element::Type precision,
static std::shared_ptr<ov::Model> get(
const ov::Shape& inputShape,
const ov::element::Type precision,
const ngraph::builder::subgraph::FakeQuantizeOnData& fakeQuantizeOnData,
const std::vector<float>& weightsValues,
const ngraph::builder::subgraph::FakeQuantizeOnWeights& fakeQuantizeOnWeights,

View File

@ -4,9 +4,7 @@
#pragma once
#include <ngraph/ngraph.hpp>
#include <ngraph/opsets/opset1.hpp>
#include "openvino/op/constant.hpp"
#include "ov_lpt_models/common/fake_quantize_on_weights.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -21,32 +19,32 @@ public:
const Shape& shape,
const element::Type& netPrecision,
const builder::subgraph::DequantizationOperations& dequantizationOnWeights,
const std::shared_ptr<opset1::Constant>& value = nullptr);
const std::shared_ptr<ov::op::v0::Constant>& value = nullptr);
static std::shared_ptr<Node> getWeights(
const Shape& shape,
const element::Type& netPrecision,
const builder::subgraph::FakeQuantizeOnWeights& fqOnWeights,
const std::shared_ptr<opset1::Constant>& value = nullptr);
const std::shared_ptr<ov::op::v0::Constant>& value = nullptr);
static std::shared_ptr<Node> getWeights(
const Shape& shape,
const element::Type& netPrecision,
const builder::subgraph::FakeQuantizeOnWeights& fqOnWeights,
const builder::subgraph::DequantizationOperations& dequantizationOnWeights,
const std::shared_ptr<opset1::Constant>& value = nullptr);
static std::shared_ptr<Function> get(
const std::shared_ptr<ov::op::v0::Constant>& value = nullptr);
static std::shared_ptr<ov::Model> get(
const element::Type netPrecision,
const PartialShape& inputShape,
const Shape& outputShape,
const builder::subgraph::FakeQuantizeOnData& fqOnData,
const std::shared_ptr<Node>& weights);
static std::shared_ptr<Function> getOriginal(
static std::shared_ptr<ov::Model> getOriginal(
const element::Type precision,
const element::Type netPrecision,
const PartialShape& inputShape,
const Shape& outputShape,
const builder::subgraph::DequantizationOperations& dequantization,
const std::shared_ptr<Node>& weights);
static std::shared_ptr<Function> getReference(
static std::shared_ptr<ov::Model> getReference(
const element::Type precision,
const element::Type netPrecision,
const PartialShape& inputShape,

View File

@ -9,8 +9,7 @@
#include <string>
#include <map>
#include <ngraph/ngraph.hpp>
#include <ngraph/opsets/opset1.hpp>
#include "openvino/op/depth_to_space.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
namespace ngraph {
@ -19,26 +18,26 @@ namespace subgraph {
class DepthToSpaceFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
const ngraph::opset1::DepthToSpace::DepthToSpaceMode mode,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ov::op::v0::DepthToSpace::DepthToSpaceMode mode,
const size_t blockSize);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::opset1::DepthToSpace::DepthToSpaceMode mode,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::op::v0::DepthToSpace::DepthToSpaceMode mode,
const size_t blockSize,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
const ngraph::opset1::DepthToSpace::DepthToSpaceMode mode,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const ov::op::v0::DepthToSpace::DepthToSpaceMode mode,
const size_t blockSize,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <low_precision/layer_transformation.hpp>
#include "ov_lpt_models/common/builders.hpp"
@ -19,9 +18,9 @@ namespace subgraph {
class ElementwiseFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginalSubgraphWithConvolutions(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginalSubgraphWithConvolutions(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const bool broadcast,
const std::string& elementWiseType,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnDataBefore1,

View File

@ -5,7 +5,7 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <low_precision/layer_transformation.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -17,10 +17,10 @@ namespace subgraph {
class AddActualValues {
public:
ngraph::element::Type precision1;
ov::element::Type precision1;
std::vector<float> subtractValues1;
std::vector<float> mutliplyValues1;
ngraph::element::Type precision2;
ov::element::Type precision2;
std::vector<float> subtractValues2;
std::vector<float> mutliplyValues2;
};
@ -37,10 +37,10 @@ inline std::ostream& operator<<(std::ostream& out, const AddActualValues& values
class AddExpectedValues {
public:
ngraph::element::Type precision1;
ov::element::Type precision1;
std::vector<float> subtractValues1;
std::vector<float> mutliplyValues1;
ngraph::element::Type precision2;
ov::element::Type precision2;
std::vector<float> mutliplyValuesAfter;
};
@ -55,13 +55,13 @@ inline std::ostream& operator<<(std::ostream& out, const AddExpectedValues& valu
class ElementwiseWithMultiParentDequantizationFunction {
public:
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ov::pass::low_precision::LayerTransformation::Params& params,
const ngraph::element::Type& precision1,
const ov::element::Type& precision1,
const ngraph::builder::subgraph::DequantizationOperations& dequantization1,
const ngraph::element::Type& precision2,
const ov::element::Type& precision2,
const ngraph::builder::subgraph::DequantizationOperations& dequantization2);
};

View File

@ -6,7 +6,6 @@
#include <algorithm>
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/fake_quantize_on_data.hpp"
#include "ov_lpt_models/common/builders.hpp"
@ -18,25 +17,25 @@ namespace subgraph {
class FakeQuantizeFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
static std::shared_ptr<ov::Model> getOriginal(
const ov::pass::low_precision::LayerTransformation::Params& params,
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnDataWithConstant& fakeQuantizeOnData,
const bool addNotPrecisionPreservedOperation);
static std::shared_ptr<ngraph::Function> getOriginalWithMaxPool(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginalWithMaxPool(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fakeQuantizeOnData);
static std::shared_ptr<ngraph::Function> getReference(
static std::shared_ptr<ov::Model> getReference(
const ov::pass::low_precision::LayerTransformation::Params& params,
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const bool updatePrecisions,
const FakeQuantizeOnDataWithConstant& fakeQuantizeOnData,
const ngraph::element::Type fakeQuantizeOutputPrecision,
const ov::element::Type fakeQuantizeOutputPrecision,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const bool addNotPrecisionPreservedOperation);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <string>
#include "ov_lpt_models/common/constant.hpp"
@ -23,15 +22,15 @@ namespace subgraph {
class FakeQuantizeAndConvolutionFunction {
public:
// TODO: move to ConvolutionFunction
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fakeQuantizeOnData,
const FakeQuantizeOnWeights& fakeQuantizeOnWeights);
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnDataWithConstant& fakeQuantizeOnData,
const DequantizationOperations::Convert& convertOnData,
const DequantizationOperations& dequantizationOnData,
@ -42,9 +41,9 @@ public:
const DequantizationOperations& dequantizationAfter,
const std::string operation = "Convolution");
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnDataWithConstant& fakeQuantizeOnData,
const DequantizationOperations::Convert& convertOnData,
const DequantizationOperations& dequantizationOnData,

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <low_precision/layer_transformation.hpp>
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
@ -18,21 +17,21 @@ namespace subgraph {
class FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fqOnData,
const FakeQuantizeOnWeights fqOnWeights1,
FakeQuantizeOnWeights fqOnWeights2);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ov::pass::low_precision::LayerTransformation::Params& params,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData,
const ngraph::element::Type precisionBeforeOp,
const ov::element::Type precisionBeforeOp,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOp,
const ov::element::Type precisionAfterOp,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter1,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter2);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <low_precision/layer_transformation.hpp>
#include "ov_lpt_models/common/fake_quantize_on_weights.hpp"
@ -16,9 +15,9 @@ namespace subgraph {
class FakeQuantizeOnWeightsAndUnsupportedChildFunction {
public:
static std::shared_ptr<ngraph::Function> get(
const ngraph::Shape& inputShape,
const ngraph::element::Type inputPrecision,
static std::shared_ptr<ov::Model> get(
const ov::Shape& inputShape,
const ov::element::Type inputPrecision,
const std::shared_ptr<ov::op::v0::Constant> weights,
const ngraph::builder::subgraph::FakeQuantizeOnWeights fqOnWeights);
};

View File

@ -6,7 +6,6 @@
#include <algorithm>
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/fake_quantize_on_data.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
@ -28,19 +27,19 @@ public:
class ExpectedValues {
public:
bool operationBeforeLimitedOperationIsPrecisionTransparent;
ngraph::element::Type fakeQuantizeOnDataOutPrecision;
ov::element::Type fakeQuantizeOnDataOutPrecision;
builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData;
builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
};
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ActualValues& values);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ExpectedValues& values);
};

View File

@ -6,7 +6,6 @@
#include <algorithm>
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/fake_quantize_on_data.hpp"
@ -16,15 +15,15 @@ namespace subgraph {
class FoldFakeQuantizeFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::Shape& constShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::Shape& constShape,
const std::vector<float>& constValues,
const FakeQuantizeOnData& fakeQuantizeOnData);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::Shape& constShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::Shape& constShape,
const std::vector<float>& constValues);
};

View File

@ -6,7 +6,6 @@
#include <memory>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
@ -16,16 +15,16 @@ namespace subgraph {
class FuseConvertFunction {
public:
static std::shared_ptr<ngraph::Function> get(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type inputPrecision,
static std::shared_ptr<ov::Model> get(
const ov::PartialShape& inputShape,
const ov::element::Type inputPrecision,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const ngraph::builder::subgraph::FakeQuantizeOnData& fakeQuantize,
const bool constInput);
static std::shared_ptr<ngraph::Function> getWithFQ(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type inputPrecision,
static std::shared_ptr<ov::Model> getWithFQ(
const ov::PartialShape& inputShape,
const ov::element::Type inputPrecision,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const bool constInput);
};

View File

@ -6,7 +6,6 @@
#include <memory>
#include <ngraph/ngraph.hpp>
#include "common/add.hpp"
#include "common/fake_quantize_on_data.hpp"
@ -20,42 +19,42 @@ class FuseFakeQuantizeFunction {
public:
class Branch {
public:
ngraph::element::Type precisionBeforeDequantization;
ov::element::Type precisionBeforeDequantization;
ngraph::builder::subgraph::DequantizationOperations dequantization;
ngraph::element::Type precisionAfterDequantization;
ov::element::Type precisionAfterDequantization;
};
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeAdd,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeAdd,
const Add& add,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const DequantizationOperations& dequantization,
const ngraph::element::Type precisionAfterDequantization,
const ngraph::element::Type precisionFqOnData,
const ov::element::Type precisionAfterDequantization,
const ov::element::Type precisionFqOnData,
const FakeQuantizeOnDataWithConstant& fqOnData);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeAdd,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeAdd,
const Add& add,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const DequantizationOperations& dequantization,
const ngraph::element::Type precisionAfterDequantization,
const ngraph::element::Type precisionFqOnData,
const ov::element::Type precisionAfterDequantization,
const ov::element::Type precisionFqOnData,
const FakeQuantizeOnDataWithConstant& fqOnData);
static std::shared_ptr<ngraph::Function> get(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBefore,
static std::shared_ptr<ov::Model> get(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBefore,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const DequantizationOperations& dequantizationOperations2);
static std::shared_ptr<ngraph::Function> get(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::PartialShape& inputShape,
const std::vector<Branch>& branches,
const ngraph::element::Type precisionFqOnData,
const ov::element::Type precisionFqOnData,
const FakeQuantizeOnData& fqOnData);
};

View File

@ -6,8 +6,8 @@
#include <algorithm>
#include <memory>
#include <ngraph/ngraph.hpp>
#include "common/fake_quantize_on_data.hpp"
#include "openvino/core/partial_shape.hpp"
namespace ngraph {
namespace builder {
@ -15,9 +15,9 @@ namespace subgraph {
class FuseFakeQuantizeAndScaleShiftFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fakeQuantizeOnData);
};

View File

@ -6,7 +6,6 @@
#include <algorithm>
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/add.hpp"
#include "common/fake_quantize_on_data.hpp"
@ -18,8 +17,8 @@ namespace subgraph {
class FuseMultiplyToFakeQuantizeFunction {
public:
static std::shared_ptr<ngraph::Function> get(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::PartialShape& inputShape,
const FakeQuantizeOnDataWithConstant& fqOnData,
const DequantizationOperations& dequantization);
};

View File

@ -6,7 +6,6 @@
#include <algorithm>
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/add.hpp"
#include "common/fake_quantize_on_data.hpp"
@ -18,13 +17,13 @@ namespace subgraph {
class FuseSubtractToFakeQuantizeFunction {
public:
static std::shared_ptr<ngraph::Function> get(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::PartialShape& inputShape,
const FakeQuantizeOnDataWithConstant& fqOnData,
const DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> get(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::PartialShape& inputShape,
const FakeQuantizeOnDataWithConstant& fqOnData,
const DequantizationOperations& dequantization,
const FakeQuantizeOnDataWithConstant& fqOnData2,

View File

@ -6,7 +6,6 @@
#include <memory>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
@ -16,35 +15,35 @@ namespace subgraph {
class GatherFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const std::vector<size_t>& gatherIndicesShape,
const std::vector<int>& gatherIndicesValues,
const std::vector<int>& axis,
const int64_t batch_dims,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const int opset_version);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const std::vector<size_t>& gatherIndicesShape,
const std::vector<int>& gatherIndicesValues,
const std::vector<int>& axis,
const int64_t batch_dims,
const ngraph::element::Type precisionBeforeFq,
const ov::element::Type precisionBeforeFq,
const FakeQuantizeOnData& fqOnData,
const int opset_version);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const std::vector<size_t>& gatherIndicesShape,
const std::vector<int>& gatherIndicesValues,
const std::vector<int>& axis,
const int64_t batch_dims,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter,
const int opset_version);
};

View File

@ -6,7 +6,6 @@
#include <sstream>
#include <vector>
#include <ngraph/ngraph.hpp>
#include <low_precision/common/fake_quantize_dequantization.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
@ -17,22 +16,22 @@ namespace subgraph {
class GetDequantizationFunction {
public:
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type& precision,
static std::shared_ptr<ov::Model> get(
const ov::element::Type& precision,
const Shape& shape,
const FakeQuantizeOnData& fakeQuantize,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore);
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type& precision,
static std::shared_ptr<ov::Model> get(
const ov::element::Type& precision,
const Shape& shape,
const FakeQuantizeOnData& fakeQuantize,
const ov::pass::low_precision::FakeQuantizeDequantization& dequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
static std::shared_ptr<ov::Model> getOriginal(
bool isConvert, bool isSubtract, size_t subDataInput, size_t mulDataInput);
static std::shared_ptr<ngraph::Function> getReference(
static std::shared_ptr<ov::Model> getReference(
ov::pass::low_precision::FakeQuantizeDequantization dequantization);
};
} // namespace subgraph

View File

@ -5,8 +5,7 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <ngraph/opsets/opset1.hpp>
#include "openvino/op/constant.hpp"
#include "ov_lpt_models/common/fake_quantize_on_weights.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -17,20 +16,20 @@ namespace subgraph {
class GroupConvolutionFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
const ngraph::Shape& outputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ov::Shape& outputShape,
const size_t groupCount,
const int groupCalculationDimention,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
std::shared_ptr<ngraph::opset1::Constant> weightsConst,
std::shared_ptr<ov::op::v0::Constant> weightsConst,
const ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
const ngraph::Shape& outputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ov::Shape& outputShape,
const size_t groupCount,
const int groupCalculationDimention,
const FakeQuantizeOnData& fakeQuantizeOnData,
@ -38,19 +37,19 @@ public:
const bool addReshape = true,
const bool addPrecisionPreserved = false);
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
const ngraph::PartialShape& outputShape,
static std::shared_ptr<ov::Model> get(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ov::PartialShape& outputShape,
const size_t groupCount,
const int calculatedDimention,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
std::shared_ptr<ngraph::opset1::Constant> weightsConst,
std::shared_ptr<ov::op::v0::Constant> weightsConst,
const ngraph::builder::subgraph::FakeQuantizeOnWeights& fakeQuantizeOnWeights,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationOnWeights,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter,
const ngraph::element::Type precisionAfterDequantization,
const ov::element::Type precisionAfterDequantization,
const bool addReshape);
};

View File

@ -5,7 +5,9 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "openvino/op/interpolate.hpp"
#include "openvino/core/model.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
namespace ngraph {
@ -14,52 +16,52 @@ namespace subgraph {
class InterpolateFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::Shape& outputShape,
const ngraph::op::InterpolateAttrs& interpAttrs,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::Shape& outputShape,
const ov::op::v0::Interpolate::Attributes& interpAttrs,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
const ngraph::Shape& outputShape,
const ngraph::op::InterpolateAttrs& interpAttrs);
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ov::Shape& outputShape,
const ov::op::v0::Interpolate::Attributes& interpAttrs);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
const ngraph::Shape& outputShape,
const ngraph::op::InterpolateAttrs& interpAttrs,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const ov::Shape& outputShape,
const ov::op::v0::Interpolate::Attributes& interpAttrs,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
// v4::Interpolate
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::Shape& outputShape,
const ngraph::Shape& scalesShape,
const ngraph::op::v4::Interpolate::InterpolateAttrs& interp4Attrs,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::Shape& outputShape,
const ov::Shape& scalesShape,
const ov::op::v4::Interpolate::InterpolateAttrs& interp4Attrs,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
const ngraph::Shape& outputShape,
const ngraph::Shape& scalesShape,
const ngraph::op::v4::Interpolate::InterpolateAttrs& interp4Attrs);
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ov::Shape& outputShape,
const ov::Shape& scalesShape,
const ov::op::v4::Interpolate::InterpolateAttrs& interp4Attrs);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
const ngraph::Shape& outputShape,
const ngraph::Shape& scalesShape,
const ngraph::op::v4::Interpolate::InterpolateAttrs& interp4Attrs,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const ov::Shape& outputShape,
const ov::Shape& scalesShape,
const ov::op::v4::Interpolate::InterpolateAttrs& interp4Attrs,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/fake_quantize_on_data.hpp"
@ -17,10 +16,10 @@ namespace subgraph {
class MarkupAvgPoolPrecisionsFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::element::Type inputPrecision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::element::Type inputPrecision,
const ov::Shape& inputShape,
const bool addFQ,
const std::string additionalLayer,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
@ -29,19 +28,19 @@ public:
// -1 - no FakeQuantize
const int fakeQuantizeBranch);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type originalFunctionPrecision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type originalFunctionPrecision,
const ov::Shape& inputShape,
const FakeQuantizeOnData& fakeQuantizeOnData);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::element::Type inputPrecision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::element::Type inputPrecision,
const ov::Shape& inputShape,
const bool addFQ,
const std::string additionalLayer,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
#include "ov_lpt_models/common/fake_quantize_on_weights.hpp"
@ -17,65 +16,65 @@ namespace subgraph {
class MatMulFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape inputShape,
const float low,
const float high);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape inputShape1,
const ngraph::PartialShape inputShape2,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape inputShape1,
const ov::PartialShape inputShape2,
const bool transpose1,
const bool transpose2);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape1,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::Shape& inputShape1,
const FakeQuantizeOnData& fqOnData1,
const ngraph::Shape& inputShape2,
const ov::Shape& inputShape2,
const FakeQuantizeOnData& fqOnData2);
static std::shared_ptr<ngraph::Function> getOriginal(
static std::shared_ptr<ov::Model> getOriginal(
const element::Type netPrecision,
const ngraph::PartialShape& inputShape1,
const ngraph::element::Type precisionBeforeDequantization1,
const ov::PartialShape& inputShape1,
const ov::element::Type precisionBeforeDequantization1,
const DequantizationOperations& dequantization1,
const ngraph::PartialShape& inputShape2,
const ngraph::element::Type precisionBeforeDequantization2,
const ov::PartialShape& inputShape2,
const ov::element::Type precisionBeforeDequantization2,
const DequantizationOperations& dequantization2);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const DequantizationOperations& deqOnData,
const Constant& weights,
const FakeQuantizeOnWeights& fqOnWeights,
const DequantizationOperations& deqOnWeights);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape1,
const ngraph::element::Type precisionBeforeDequantization1,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::PartialShape& inputShape1,
const ov::element::Type precisionBeforeDequantization1,
const DequantizationOperations& dequantization1,
const ngraph::PartialShape& inputShape2,
const ngraph::element::Type precisionBeforeDequantization2,
const ov::PartialShape& inputShape2,
const ov::element::Type precisionBeforeDequantization2,
const DequantizationOperations& dequantization2,
const DequantizationOperations& resultDequantization);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const DequantizationOperations& dequantization,
const Constant& weights,
const DequantizationOperations& resultDequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnDataWithConstant& fqOnData,
const Constant& weights,
const FakeQuantizeOnDataWithConstant& fqOnWeights,

View File

@ -5,7 +5,8 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "openvino/core/partial_shape.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
namespace ngraph {
@ -14,10 +15,10 @@ namespace subgraph {
class MatMulWithOptimizedConstantFakeQuantizeFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape1,
const ngraph::PartialShape& inputShape2,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape1,
const ov::PartialShape& inputShape2,
const FakeQuantizeOnData& fqOnData,
const FakeQuantizeOnData& fqOnWeights);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "common/fake_quantize_on_data.hpp"
#include "low_precision/layer_transformation.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -16,16 +15,16 @@ namespace subgraph {
class MaxPoolFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type originalFunctionPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type originalFunctionPrecision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fakeQuantizeOnData);
static std::shared_ptr<ngraph::Function> get(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> get(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_models/subgraph_builders.hpp"
@ -16,16 +15,16 @@ namespace subgraph {
class MoveDequantizationAfterFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations dequantization);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations dequantizationAfter);
};

View File

@ -6,7 +6,6 @@
#include <algorithm>
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/fake_quantize_on_data.hpp"
#include "common/dequantization_operations.hpp"
@ -17,9 +16,9 @@ namespace subgraph {
class MoveFakeQuantize {
public:
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type inputPrecision,
const std::vector<ngraph::PartialShape>& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::element::Type inputPrecision,
const std::vector<ov::PartialShape>& inputShape,
const size_t concatInputsCount,
const std::vector<FakeQuantizeOnDataWithConstant>& fqBefore,
const DequantizationOperations::Convert& convertBefore,
@ -29,7 +28,7 @@ public:
const DequantizationOperations::Convert& convertAfter,
const DequantizationOperations& dequantizationAfter,
const std::vector<ov::Any>& concatAttributes,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const std::int64_t& axis,
const bool oneInputWithSplit);
};

View File

@ -6,7 +6,6 @@
#include <algorithm>
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/dequantization_operations.hpp"
#include "common/add.hpp"
@ -17,20 +16,20 @@ namespace subgraph {
class MulAddToScaleshiftOrPowerFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::Shape& inputShape,
bool isDequantization,
const ngraph::builder::subgraph::DequantizationOperations::Multiply& mulValues,
const ngraph::builder::subgraph::Add& addValues);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::Shape& inputShape,
bool isDequantization,
const ngraph::builder::subgraph::DequantizationOperations::Multiply& weightsValues,
const ngraph::builder::subgraph::Add& biasesValues,
const ngraph::element::Type precisionAfterOperation);
const ov::element::Type precisionAfterOperation);
};
} // namespace subgraph

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "elementwise.hpp"
#include "ov_lpt_models/common/constant.hpp"
@ -19,7 +18,7 @@ class MultiplyBranch {
public:
MultiplyBranch(const PartialShape& inputShape,
const ngraph::builder::subgraph::Constant& constant,
const ngraph::element::Type& input_precision,
const ov::element::Type& input_precision,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const ngraph::builder::subgraph::FakeQuantizeOnData& fake_quantize)
: inputShape(inputShape),
@ -30,7 +29,7 @@ public:
PartialShape inputShape;
ngraph::builder::subgraph::Constant constant;
ngraph::element::Type input_precision;
ov::element::Type input_precision;
ngraph::builder::subgraph::DequantizationOperations dequantization;
ngraph::builder::subgraph::FakeQuantizeOnData fake_quantize;
};
@ -49,7 +48,7 @@ public:
class MultiplyFunction : public ElementwiseFunction {
public:
static std::shared_ptr<ngraph::Function> get(const element::Type model_precision, const MultiplyValues& actualValues);
static std::shared_ptr<ov::Model> get(const element::Type model_precision, const MultiplyValues& actualValues);
};
} // namespace subgraph

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "elementwise.hpp"
#include "ov_lpt_models/common/constant.hpp"
@ -19,7 +18,7 @@ class MultiplyPartialBranch {
public:
PartialShape inputShape;
ngraph::builder::subgraph::Constant constant;
ngraph::element::Type precisionBeforeDequantization;
ov::element::Type precisionBeforeDequantization;
ngraph::builder::subgraph::DequantizationOperations dequantization;
};
@ -40,13 +39,13 @@ inline std::ostream& operator<<(std::ostream& out, const MultiplyPartialValues&
class MultiplyPartialFunction : public ElementwiseFunction {
public:
static std::shared_ptr<ngraph::Function> get(
static std::shared_ptr<ov::Model> get(
const element::Type precision,
const MultiplyPartialValues& actualValues);
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const bool broadcast1,
const ngraph::builder::subgraph::FakeQuantizeOnData& fq1,
const bool broadcast2,

View File

@ -5,9 +5,7 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <ngraph/op/constant.hpp>
#include <ngraph/opsets/opset1.hpp>
#include "openvino/op/constant.hpp"
#include "ov_lpt_models/common/constant.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
@ -19,24 +17,24 @@ namespace subgraph {
class MultiplyToGroupConvolutionFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type& precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::element::Type& precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const bool haveMultiplyWithNoConstBeforeDequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fqOnData,
const Constant& constant,
const bool parentHasOneConsumer = true);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type& precision,
const std::shared_ptr<ngraph::opset1::Constant>& weights,
const std::shared_ptr<ngraph::opset1::Constant>& biases,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const ov::element::Type& precision,
const std::shared_ptr<ov::op::v0::Constant>& weights,
const std::shared_ptr<ov::op::v0::Constant>& biases,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
};

View File

@ -5,7 +5,8 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "openvino/core/partial_shape.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
namespace ngraph {
@ -14,9 +15,9 @@ namespace subgraph {
class MultiplyWithOneParentFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fakeQuantize);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
namespace ngraph {
@ -14,29 +13,29 @@ namespace subgraph {
class MVNFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
static std::shared_ptr<ov::Model> getOriginal(
const element::Type precision,
const ngraph::PartialShape& inputShape,
const ov::PartialShape& inputShape,
const AxisSet& reductionAxes,
const bool& normalizeVariance,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const int opset_version);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const AxisSet& reductionAxes,
const bool& normalizeVariance);
static std::shared_ptr<ngraph::Function> getReference(
static std::shared_ptr<ov::Model> getReference(
const element::Type precision,
const ngraph::PartialShape& inputShape,
const ov::PartialShape& inputShape,
const AxisSet& reductionAxes,
const bool& normalizeVariance,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter,
const int opset_version);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
namespace ngraph {
@ -14,9 +13,9 @@ namespace subgraph {
class NormalizeDequantizationFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations dequantization);
};

View File

@ -9,7 +9,6 @@
#include <string>
#include <map>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -19,30 +18,30 @@ namespace subgraph {
class NormalizeL2Function {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const std::pair<ngraph::PartialShape, ngraph::Shape>& shapes,
const ngraph::element::Type precisionOnActivation,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const std::pair<ov::PartialShape, ov::Shape>& shapes,
const ov::element::Type precisionOnActivation,
const std::vector<uint64_t>& axes,
const bool fuseMultiply,
const bool shift);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& shape,
const ngraph::op::EpsMode& epsMode,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::element::Type inputPrecision,
const ov::PartialShape& shape,
const ov::op::EpsMode& epsMode,
const std::vector<size_t>& axes,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& shape,
const ngraph::op::EpsMode& epsMode,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::element::Type inputPrecision,
const ov::PartialShape& shape,
const ov::op::EpsMode& epsMode,
const std::vector<size_t>& axes,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -6,7 +6,6 @@
#include <sstream>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -27,7 +26,7 @@ static std::shared_ptr<ov::Model> get(
const element::Type precisionAfterOperation,
const builder::subgraph::DequantizationOperations& dequantizationAfter);
static std::shared_ptr<Function> get(
static std::shared_ptr<ov::Model> get(
const PartialShape& inputShape,
const element::Type inputPrecision,
const builder::subgraph::FakeQuantizeOnData& fakeQuantizeOnData,

View File

@ -6,7 +6,6 @@
#include <algorithm>
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/fake_quantize_on_data.hpp"
#include "common/dequantization_operations.hpp"
@ -17,9 +16,9 @@ namespace subgraph {
class PrecisionPropagationFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginalWithNeighbors(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getOriginalWithNeighbors(
const ov::element::Type precision,
const ov::Shape& inputShape,
const FakeQuantizeOnData& fqOnData1,
const DequantizationOperations::Convert& convert1,
const DequantizationOperations& dequantization1,
@ -30,15 +29,15 @@ public:
const DequantizationOperations::Convert& convert3,
const DequantizationOperations& dequantization3);
static std::shared_ptr<ngraph::Function> getReferenceWithNeighbors(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getReferenceWithNeighbors(
const ov::element::Type precision,
const ov::Shape& inputShape,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const FakeQuantizeOnData& fqOnData3,
const ngraph::element::Type precisionBeforeOp,
const ov::element::Type precisionBeforeOp,
const DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const DequantizationOperations& dequantizationOperations1,
const DequantizationOperations& dequantizationOperations2);

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
namespace ngraph {
@ -14,21 +13,21 @@ namespace subgraph {
class PReluFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeFq,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeFq,
const FakeQuantizeOnData& fqOnData);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -6,7 +6,6 @@
#include <algorithm>
#include <memory>
#include <ngraph/ngraph.hpp>
#include "low_precision/layer_transformation.hpp"
#include "common/fake_quantize_on_data.hpp"
#include "common/dequantization_operations.hpp"
@ -19,10 +18,10 @@ class RecurrentCellFunction {
public:
enum class RNNType { LSTMSequence, GRUSequence };
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type inputPrecision,
const std::vector<ngraph::PartialShape>& inputActivationsShapes,
const std::vector<ngraph::Shape>& inputWeightsShapes,
static std::shared_ptr<ov::Model> get(
const ov::element::Type inputPrecision,
const std::vector<ov::PartialShape>& inputActivationsShapes,
const std::vector<ov::Shape>& inputWeightsShapes,
const RNNType type,
const std::vector<FakeQuantizeOnDataWithConstant>& fqOnDatas,
const std::vector<DequantizationOperations::Convert>& converts,
@ -30,7 +29,7 @@ public:
};
std::shared_ptr<Node> makeQuantizationAndDequantization(const std::shared_ptr<Node> input,
const ngraph::element::Type inputPrecision,
const ov::element::Type inputPrecision,
const std::string friendly_name,
const FakeQuantizeOnDataWithConstant& fqOnData,
const DequantizationOperations::Convert& convert,

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <low_precision/layer_transformation.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -19,9 +18,9 @@ namespace subgraph {
class ReduceFunction {
public:
template <typename ReduceType>
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const std::vector<int64_t>& constantValues,
const bool keepDims) {
@ -29,8 +28,8 @@ public:
const auto dequantization = makeDequantization(input, dequantizationBefore);
const auto constant = std::make_shared<ov::op::v0::Constant>(
ngraph::element::i32,
ngraph::Shape{ constantValues.size() },
ov::element::i32,
ov::Shape{ constantValues.size() },
constantValues);
const auto reducePrecision = dequantization->get_output_element_type(0);
@ -43,18 +42,18 @@ public:
reduce->set_friendly_name("Output");
const auto result = std::make_shared<ov::op::v0::Result>(reduce);
const auto function = std::make_shared<ngraph::Function>(
ngraph::ResultVector{ result },
ngraph::ParameterVector{ input },
const auto function = std::make_shared<ov::Model>(
ov::ResultVector{ result },
ov::ParameterVector{ input },
"ReduceTransformation");
return function;
}
template <typename ReduceType>
static std::shared_ptr<ngraph::Function> get(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> get(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData,
const ngraph::builder::subgraph::DequantizationOperations::Convert& convert,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
@ -62,7 +61,7 @@ public:
const bool keepDims,
ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter) {
const auto input = std::make_shared<ov::op::v0::Parameter>(precision, inputShape);
std::shared_ptr<ngraph::Node> parent = input;
std::shared_ptr<ov::Node> parent = input;
if (!fqOnData.empty()) {
parent = makeFakeQuantize(parent, precision, fqOnData);
@ -77,8 +76,8 @@ public:
}
const auto constant = std::make_shared<ov::op::v0::Constant>(
ngraph::element::i32,
ngraph::Shape{ constantValues.size() },
ov::element::i32,
ov::Shape{ constantValues.size() },
constantValues);
parent = std::make_shared<ReduceType>(parent, constant, keepDims);
@ -89,29 +88,29 @@ public:
}
const auto result = std::make_shared<ov::op::v0::Result>(parent);
const auto function = std::make_shared<ngraph::Function>(
ngraph::ResultVector{ result },
ngraph::ParameterVector{ input },
const auto function = std::make_shared<ov::Model>(
ov::ResultVector{ result },
ov::ParameterVector{ input },
"ReduceTransformation");
return function;
}
template <typename ReduceType>
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const std::vector<int64_t>& constantValues,
const bool keepDims,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter) {
const auto input = std::make_shared<ov::op::v0::Parameter>(precision, inputShape);
const auto dequantization = makeDequantization(input, dequantizationBefore);
const auto constant = std::make_shared<ov::op::v0::Constant>(
ngraph::element::i32,
ngraph::Shape{ constantValues.size() },
ov::element::i32,
ov::Shape{ constantValues.size() },
constantValues);
const std::shared_ptr<Node> reduce = std::make_shared<ov::op::TypeRelaxed<ReduceType>>(
@ -124,9 +123,9 @@ public:
lastOperation->set_friendly_name("Output");
const auto result = std::make_shared<ov::op::v0::Result>(lastOperation);
const auto function = std::make_shared<ngraph::Function>(
ngraph::ResultVector{ result },
ngraph::ParameterVector{ input },
const auto function = std::make_shared<ov::Model>(
ov::ResultVector{ result },
ov::ParameterVector{ input },
"ReduceTransformation");
return function;

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
namespace ngraph {
@ -14,21 +13,21 @@ namespace subgraph {
class ReluFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeFq,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeFq,
const FakeQuantizeOnData& fqOnData);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -6,7 +6,6 @@
#include <memory>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
@ -16,24 +15,24 @@ namespace subgraph {
class ReshapeFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const std::vector<int>& reshapeConstValues,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const std::vector<int>& reshapeConstValues,
const ngraph::element::Type precisionBeforeFq,
const ov::element::Type precisionBeforeFq,
const FakeQuantizeOnData& fqOnData);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const std::vector<int>& reshapeConstValues,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_models/subgraph_builders.hpp"
@ -16,14 +15,14 @@ namespace subgraph {
class RoundWithToleranceFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations dequantization);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations dequantization);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <low_precision/layer_transformation.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -17,27 +16,27 @@ namespace subgraph {
class ShuffleChannelsFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations& deqBefore,
const std::int64_t axis,
const std::int64_t group);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData,
const std::int64_t axis,
const std::int64_t group);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations& deqBefore,
const std::int64_t axis,
const std::int64_t group,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& deqAfter);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <vector>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
@ -15,15 +14,15 @@ namespace subgraph {
class SpaceToBatchFunction {
public:
static std::shared_ptr<ngraph::Function> get(const ngraph::PartialShape& input_shape,
const ngraph::element::Type input_type,
static std::shared_ptr<ov::Model> get(const ov::PartialShape& input_shape,
const ov::element::Type input_type,
const FakeQuantizeOnData& fq_on_data,
const std::vector<size_t>& block_shape,
const std::vector<size_t>& pads_begin,
const std::vector<size_t>& pads_end);
static std::shared_ptr<ngraph::Function> get(const ngraph::PartialShape& input_shape,
const ngraph::element::Type input_type,
static std::shared_ptr<ov::Model> get(const ov::PartialShape& input_shape,
const ov::element::Type input_type,
const ngraph::builder::subgraph::DequantizationOperations& dequantization_before,
const std::vector<size_t>& block_shape,
const std::vector<size_t>& pads_begin,

View File

@ -7,7 +7,6 @@
#include <memory>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -19,27 +18,27 @@ namespace subgraph {
class SplitFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
static std::shared_ptr<ov::Model> getOriginal(
const element::Type& precision,
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const int64_t splitedAxis,
const size_t numSplits);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type originalFunctionPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type originalFunctionPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize,
const int64_t splitedAxis,
const size_t numSplit);
static std::shared_ptr<ngraph::Function> getReference(
static std::shared_ptr<ov::Model> getReference(
const element::Type& precision,
const ngraph::PartialShape& inputShape,
const ngraph::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const ov::element::Type inputPrecision,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const std::vector<ngraph::builder::subgraph::DequantizationOperations>& dequantizationAfter,
const int64_t splitedAxis,
const size_t numSplits);

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
namespace ngraph {
@ -14,24 +13,24 @@ namespace subgraph {
class SqueezeFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const std::vector<float>& axes,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type originalFunctionPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type originalFunctionPrecision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fakeQuantizeOnData,
const std::vector<float>& axes);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const std::vector<float>& axes,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include <low_precision/layer_transformation.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -17,9 +16,9 @@ namespace subgraph {
class StridedSliceFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const std::vector<int64_t>& begin,
const std::vector<int64_t>& end,
@ -30,9 +29,9 @@ public:
const std::vector<int64_t>& shrinkAxisMask,
const std::vector<int64_t>& elipsisMask);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::FakeQuantizeOnData& fakeQuantize,
const std::vector<int64_t>& begin,
const std::vector<int64_t>& end,
@ -43,9 +42,9 @@ public:
const std::vector<int64_t>& shrinkAxisMask,
const std::vector<int64_t>& elipsisMask);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const std::vector<int64_t>& begin,
const std::vector<int64_t>& end,
const std::vector<int64_t>& strides,
@ -55,7 +54,7 @@ public:
const std::vector<int64_t>& shrinkAxisMask,
const std::vector<int64_t>& elipsisMask,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_models/subgraph_builders.hpp"
@ -17,9 +16,9 @@ namespace subgraph {
class SubtractFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape);
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape);
};
} // namespace subgraph

View File

@ -6,7 +6,6 @@
#include <memory>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/add.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -19,22 +18,22 @@ namespace subgraph {
class SubtractMultiplyToMultiplyAddFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const ngraph::element::Type precisionAfterDequantization);
const ov::element::Type precisionAfterDequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precision,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::element::Type precision,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const ngraph::element::Type precisionAfterDequantization,
const ov::element::Type precisionAfterDequantization,
const ngraph::builder::subgraph::Multiply& multiply,
const ngraph::builder::subgraph::Add& add);
};

View File

@ -6,7 +6,8 @@
#include <string>
#include <memory>
#include <ngraph/ngraph.hpp>
#include "openvino/core/model.hpp"
namespace ngraph {
namespace builder {
@ -14,7 +15,7 @@ namespace subgraph {
class TransformationsAfterSplitFunction {
public:
static std::shared_ptr<Function> get(const std::string transformationName);
static std::shared_ptr<ov::Model> get(const std::string transformationName);
static std::shared_ptr<Node> getLayerByTransformationName(
const std::string transformationName,

View File

@ -6,7 +6,6 @@
#include <memory>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
@ -16,24 +15,24 @@ namespace subgraph {
class TransposeFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const std::vector<int>& transposeConstValues,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const std::vector<int>& transposeConstValues,
const ngraph::element::Type precisionBeforeFq,
const ov::element::Type precisionBeforeFq,
const FakeQuantizeOnData& fqOnData);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const std::vector<int>& transposeConstValues,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_models/subgraph_builders.hpp"
@ -17,9 +16,9 @@ namespace subgraph {
class TransposeAfterMatMulFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape);
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape);
};
} // namespace subgraph

View File

@ -5,7 +5,6 @@
#pragma once
#include <memory>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/dequantization_operations.hpp"
namespace ngraph {
@ -14,24 +13,24 @@ namespace subgraph {
class UnsqueezeFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const std::vector<float>& axes,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type originalFunctionPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type originalFunctionPrecision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fakeQuantizeOnData,
const std::vector<float>& axes);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const std::vector<float>& axes,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter);
};

View File

@ -7,7 +7,6 @@
#include <memory>
#include <vector>
#include <ngraph/ngraph.hpp>
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
@ -19,25 +18,25 @@ namespace subgraph {
class VariadicSplitFunction {
public:
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
static std::shared_ptr<ov::Model> getOriginal(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const int64_t splitedAxis,
const std::vector<size_t>& splitLengths);
static std::shared_ptr<ngraph::Function> getOriginal(
const ngraph::element::Type originalFunctionPrecision,
const ngraph::PartialShape& inputShape,
static std::shared_ptr<ov::Model> getOriginal(
const ov::element::Type originalFunctionPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize,
const int64_t splitedAxis,
const std::vector<size_t>& splitLengths);
static std::shared_ptr<ngraph::Function> getReference(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type inputPrecision,
static std::shared_ptr<ov::Model> getReference(
const ov::PartialShape& inputShape,
const ov::element::Type inputPrecision,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const std::vector<ngraph::builder::subgraph::DequantizationOperations>& dequantizationAfter,
const int64_t splitedAxis,
const std::vector<size_t>& splitLengths);

View File

@ -7,7 +7,7 @@
#include "low_precision/network_helper.hpp"
#include "low_precision/layer_transformation.hpp"
#include "ngraph/opsets/opset1.hpp"
#include "openvino/opsets/opset1.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include "ov_models/subgraph_builders.hpp"
@ -24,11 +24,11 @@ std::shared_ptr<Node> configure_postops(const std::shared_ptr<Node>& parent,
const std::string& postops_configuration) {
std::shared_ptr<Node> res = parent;
if (postops_configuration.empty() || postops_configuration == "bias") {
auto bias = opset1::Constant::create(precision, { 1, 1, 1, 1 }, {1.f});
res = std::make_shared<opset1::Add>(res, bias);
auto bias = ov::opset1::Constant::create(precision, { 1, 1, 1, 1 }, {1.f});
res = std::make_shared<ov::opset1::Add>(res, bias);
} else if (postops_configuration == "bias_on_zero_input") {
auto bias = opset1::Constant::create(precision, { 1, 1, 1, 1 }, {1.f});
res = std::make_shared<opset1::Add>(bias, res);
auto bias = ov::opset1::Constant::create(precision, { 1, 1, 1, 1 }, {1.f});
res = std::make_shared<ov::opset1::Add>(bias, res);
} else {
return parent;
}
@ -40,31 +40,31 @@ std::shared_ptr<Node> configure_postops(const std::shared_ptr<Node>& parent,
}
} // namespace
std::shared_ptr<ngraph::Function> AddFunction::getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape1,
const ngraph::PartialShape& inputShape2,
std::shared_ptr<ov::Model> AddFunction::getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape1,
const ov::PartialShape& inputShape2,
const bool broadcast,
const ov::pass::low_precision::LayerTransformation::Params& params,
const ngraph::element::Type& precision1,
const ov::element::Type& precision1,
const ngraph::builder::subgraph::DequantizationOperations& dequantization1,
const ngraph::element::Type& precision2,
const ov::element::Type& precision2,
const ngraph::builder::subgraph::DequantizationOperations& dequantization2,
const int constInput,
const std::vector<float>& constValues,
const std::string& additionalLayer,
const std::string& postops_configuration) {
std::shared_ptr<ngraph::Node> input1;
std::shared_ptr<ngraph::Node> parent1;
std::shared_ptr<ov::Node> input1;
std::shared_ptr<ov::Node> parent1;
if (constInput == 0) {
parent1 = std::make_shared<ngraph::opset1::Constant>(
parent1 = std::make_shared<ov::opset1::Constant>(
precision,
inputShape1.to_shape(),
constValues);
} else {
input1 = std::make_shared<ngraph::opset1::Parameter>(
input1 = std::make_shared<ov::opset1::Parameter>(
additionalLayer != "" ? precision : (precision1.is_real() ? precision : precision1),
broadcast ? ngraph::PartialShape({inputShape1[0], inputShape1[1], 1, 1}) : inputShape1);
broadcast ? ov::PartialShape({inputShape1[0], inputShape1[1], 1, 1}) : inputShape1);
if (additionalLayer != "") {
parent1 = ngraph::builder::subgraph::makeFakeQuantizeTypeRelaxed(
input1,
@ -83,57 +83,57 @@ std::shared_ptr<ngraph::Function> AddFunction::getOriginal(
const auto dequantizationOp1 = dequantization1.empty() ? parent1 : makeDequantization(parent1, dequantizationStructure1);
std::shared_ptr<ngraph::Node> input2;
std::shared_ptr<ov::Node> input2;
if (constInput == 1) {
input2 = std::make_shared<ngraph::opset1::Constant>(
input2 = std::make_shared<ov::opset1::Constant>(
precision,
inputShape2.to_shape(),
constValues);
} else {
input2 = std::make_shared<ngraph::opset1::Parameter>(
input2 = std::make_shared<ov::opset1::Parameter>(
precision2.is_real() ? precision : precision2, inputShape2);
}
auto parent = input2;
if (additionalLayer == "convolution") {
parent = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Convolution>>(
parent = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Convolution>>(
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{ precision },
ov::op::TemporaryReplaceOutputType(parent, element::f32).get(),
ov::op::TemporaryReplaceOutputType(
std::make_shared<ngraph::opset1::Constant>(element::i8, Shape{ 1, 4, 1, 1 }, std::vector<float>{0.8f, 0.8f, 0.8f, 0.8f}),
std::make_shared<ov::opset1::Constant>(element::i8, Shape{ 1, 4, 1, 1 }, std::vector<float>{0.8f, 0.8f, 0.8f, 0.8f}),
element::f32).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
}
std::shared_ptr<Node> additional_output = nullptr;
if (additionalLayer == "convolution_multiconsumers") {
parent = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Convolution>>(
parent = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Convolution>>(
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{ precision },
ov::op::TemporaryReplaceOutputType(parent, element::f32).get(),
ov::op::TemporaryReplaceOutputType(
std::make_shared<ngraph::opset1::Constant>(element::i8, Shape{ 1, 4, 1, 1 }, std::vector<float>{0.8f, 0.8f, 0.8f, 0.8f}),
std::make_shared<ov::opset1::Constant>(element::i8, Shape{ 1, 4, 1, 1 }, std::vector<float>{0.8f, 0.8f, 0.8f, 0.8f}),
element::f32).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
additional_output = parent;
}
if (additionalLayer == "group_convolution") {
parent = std::make_shared< ov::op::TypeRelaxed<ngraph::opset1::GroupConvolution>>(
parent = std::make_shared< ov::op::TypeRelaxed<ov::opset1::GroupConvolution>>(
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{ precision },
ov::op::TemporaryReplaceOutputType(parent, element::f32).get(),
ov::op::TemporaryReplaceOutputType(
std::make_shared<ngraph::opset1::Constant>(element::i8, Shape{ 4, 1, 1, 1, 1 }, std::vector<float>{0.8f, 0.8f, 0.8f, 0.8f}),
std::make_shared<ov::opset1::Constant>(element::i8, Shape{ 4, 1, 1, 1, 1 }, std::vector<float>{0.8f, 0.8f, 0.8f, 0.8f}),
element::f32).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
}
if (additionalLayer != "") {
parent = configure_postops(parent, precision, postops_configuration);
@ -143,38 +143,38 @@ std::shared_ptr<ngraph::Function> AddFunction::getOriginal(
dequantizationStructure2.multiply.outPrecision = precision;
const auto dequantizationOp2 = dequantization2.empty() ? parent : makeDequantization(parent, dequantizationStructure2);
const auto add = std::make_shared<ngraph::opset1::Add>(dequantizationOp1, dequantizationOp2);
const auto add = std::make_shared<ov::opset1::Add>(dequantizationOp1, dequantizationOp2);
add->set_friendly_name("output");
auto& rtInfo = add->get_rt_info();
rtInfo["Variant::std::string"] = "add";
std::shared_ptr<Node> output = add;
if (additional_output != nullptr) {
output = std::make_shared<opset1::Multiply>(add, additional_output);
output = std::make_shared<ov::opset1::Multiply>(add, additional_output);
output->set_friendly_name("output_multiply");
}
ngraph::ResultVector results {std::make_shared<ngraph::opset1::Result>(output)};
ngraph::ParameterVector parameters;
ov::ResultVector results {std::make_shared<ov::opset1::Result>(output)};
ov::ParameterVector parameters;
if (constInput == -1) {
parameters = { ov::as_type_ptr<ngraph::opset1::Parameter>(input1), ov::as_type_ptr<ngraph::opset1::Parameter>(input2) };
parameters = { ov::as_type_ptr<ov::opset1::Parameter>(input1), ov::as_type_ptr<ov::opset1::Parameter>(input2) };
} else if (constInput == 0) {
parameters = { ov::as_type_ptr<ngraph::opset1::Parameter>(input2) };
parameters = { ov::as_type_ptr<ov::opset1::Parameter>(input2) };
} else if (constInput == 1) {
parameters = { ov::as_type_ptr<ngraph::opset1::Parameter>(input1) };
parameters = { ov::as_type_ptr<ov::opset1::Parameter>(input1) };
} else {
throw std::runtime_error("Unexpected constant input index");
}
return std::make_shared<ngraph::Function>(results, parameters, "AddTransformation");
return std::make_shared<ov::Model>(results, parameters, "AddTransformation");
}
std::shared_ptr<ngraph::Function> AddFunction::getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> AddFunction::getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const bool broadcast,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData1,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData2) {
ngraph::PartialShape inputShape2 = inputShape;
ov::PartialShape inputShape2 = inputShape;
if (broadcast) {
inputShape2[2] = 1;
@ -184,37 +184,37 @@ std::shared_ptr<ngraph::Function> AddFunction::getOriginal(
auto fq1 = fqOnData1;
auto fq2 = fqOnData2;
const auto input1 = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto input1 = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
const auto fakeQuantize1 = fq1.empty() ?
nullptr :
ngraph::builder::makeFakeQuantize(
input1, precision, fq1.quantizationLevel, fq1.constantShape,
fq1.inputLowValues, fq1.inputHighValues, fq1.outputLowValues, fq1.outputHighValues);
const auto input2 = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape2);
const auto input2 = std::make_shared<ov::opset1::Parameter>(precision, inputShape2);
const auto fakeQuantize2 = fq2.empty() ?
nullptr :
ngraph::builder::makeFakeQuantize(
input2, precision, fq2.quantizationLevel, fq2.constantShape,
fq2.inputLowValues, fq2.inputHighValues, fq2.outputLowValues, fq2.outputHighValues);
const auto add = std::make_shared<ngraph::opset1::Add>(
const auto add = std::make_shared<ov::opset1::Add>(
fq1.empty() ? input1 : fakeQuantize1,
fq2.empty() ? input2 : fakeQuantize2);
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(add) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input1, input2 }, "AddTransformation");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(add) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input1, input2 }, "AddTransformation");
}
std::shared_ptr<ngraph::Function> AddFunction::getReference(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape1,
const ngraph::PartialShape& inputShape2,
std::shared_ptr<ov::Model> AddFunction::getReference(
const ov::element::Type precision,
const ov::PartialShape& inputShape1,
const ov::PartialShape& inputShape2,
const bool broadcast,
const ov::pass::low_precision::LayerTransformation::Params& params,
const ngraph::element::Type& precision1,
const ov::element::Type& precision1,
const ngraph::builder::subgraph::DequantizationOperations& dequantization1,
const ngraph::element::Type& precision2,
const ov::element::Type& precision2,
const ngraph::builder::subgraph::DequantizationOperations& dequantization2,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter,
const int constInputIndex,
@ -222,17 +222,17 @@ std::shared_ptr<ngraph::Function> AddFunction::getReference(
const std::string& additionalLayer,
const std::string& operationType,
const std::string& postops_configuration) {
std::shared_ptr<ngraph::Node> input1;
std::shared_ptr<ngraph::Node> parent1;
std::shared_ptr<ov::Node> input1;
std::shared_ptr<ov::Node> parent1;
if (constInputIndex == 0) {
parent1 = std::make_shared<ngraph::opset1::Constant>(
parent1 = std::make_shared<ov::opset1::Constant>(
dequantizationAfter.empty() ? precision : element::f32,
inputShape1.to_shape(),
constValues);
} else {
input1 = std::make_shared<ngraph::opset1::Parameter>(
input1 = std::make_shared<ov::opset1::Parameter>(
additionalLayer != "" ? precision : (precision1.is_real() ? precision : precision1),
broadcast ? ngraph::PartialShape({inputShape1[0], inputShape1[1], 1, 1}) : inputShape1);
broadcast ? ov::PartialShape({inputShape1[0], inputShape1[1], 1, 1}) : inputShape1);
if (additionalLayer != "") {
parent1 = ngraph::builder::subgraph::makeFakeQuantizeTypeRelaxed(
input1,
@ -245,59 +245,59 @@ std::shared_ptr<ngraph::Function> AddFunction::getReference(
auto dequantizationStructure1 = dequantization1;
dequantizationStructure1.multiply.outPrecision = dequantizationAfter.empty() ? precision : element::f32;
const auto dequantizationOp1 = ov::is_type<ngraph::opset1::Constant>(parent1) ? parent1 : makeDequantization(parent1, dequantizationStructure1);
const auto dequantizationOp1 = ov::is_type<ov::opset1::Constant>(parent1) ? parent1 : makeDequantization(parent1, dequantizationStructure1);
std::shared_ptr<ngraph::Node> input2;
std::shared_ptr<ov::Node> input2;
if (constInputIndex == 1) {
input2 = std::make_shared<ngraph::opset1::Constant>(
input2 = std::make_shared<ov::opset1::Constant>(
dequantizationAfter.empty() ? precision : element::f32,
inputShape2.to_shape(),
constValues);
} else {
input2 = std::make_shared<ngraph::opset1::Parameter>(
input2 = std::make_shared<ov::opset1::Parameter>(
precision2.is_real() ? precision : precision2, inputShape2);
}
auto parent = input2;
if (additionalLayer == "convolution") {
parent = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Convolution>>(
parent = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Convolution>>(
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{ precision },
ov::op::TemporaryReplaceOutputType(parent, element::f32).get(),
ov::op::TemporaryReplaceOutputType(
std::make_shared<ngraph::opset1::Constant>(element::i8, Shape{ 1, 4, 1, 1 }, std::vector<float>{0.8f, 0.8f, 0.8f, 0.8f}),
std::make_shared<ov::opset1::Constant>(element::i8, Shape{ 1, 4, 1, 1 }, std::vector<float>{0.8f, 0.8f, 0.8f, 0.8f}),
element::f32).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
}
std::shared_ptr<Node> additional_output = nullptr;
if (additionalLayer == "convolution_multiconsumers") {
parent = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Convolution>>(
parent = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Convolution>>(
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{ precision },
ov::op::TemporaryReplaceOutputType(parent, element::f32).get(),
ov::op::TemporaryReplaceOutputType(
std::make_shared<ngraph::opset1::Constant>(element::i8, Shape{ 1, 4, 1, 1 }, std::vector<float>{0.8f, 0.8f, 0.8f, 0.8f}),
std::make_shared<ov::opset1::Constant>(element::i8, Shape{ 1, 4, 1, 1 }, std::vector<float>{0.8f, 0.8f, 0.8f, 0.8f}),
element::f32).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
additional_output = parent;
}
if (additionalLayer == "group_convolution") {
parent = std::make_shared< ov::op::TypeRelaxed<ngraph::opset1::GroupConvolution>>(
parent = std::make_shared< ov::op::TypeRelaxed<ov::opset1::GroupConvolution>>(
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{ precision },
ov::op::TemporaryReplaceOutputType(parent, element::f32).get(),
ov::op::TemporaryReplaceOutputType(
std::make_shared<ngraph::opset1::Constant>(element::i8, Shape{ 4, 1, 1, 1, 1 }, std::vector<float>{0.8f, 0.8f, 0.8f, 0.8f}),
std::make_shared<ov::opset1::Constant>(element::i8, Shape{ 4, 1, 1, 1, 1 }, std::vector<float>{0.8f, 0.8f, 0.8f, 0.8f}),
element::f32).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
}
if (additionalLayer != "") {
parent = configure_postops(parent, precision, postops_configuration);
@ -305,15 +305,15 @@ std::shared_ptr<ngraph::Function> AddFunction::getReference(
auto dequantizationStructure2 = dequantization2;
dequantizationStructure2.multiply.outPrecision = dequantizationAfter.empty() ? precision : element::f32;
const auto dequantizationOp2 = ov::is_type<ngraph::opset1::Constant>(parent) ? parent : makeDequantization(parent, dequantizationStructure2);
const auto dequantizationOp2 = ov::is_type<ov::opset1::Constant>(parent) ? parent : makeDequantization(parent, dequantizationStructure2);
const std::shared_ptr<Node> add = operationType == "Add" ?
std::dynamic_pointer_cast<Node>(std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Add>>(
std::dynamic_pointer_cast<Node>(std::make_shared<ov::op::TypeRelaxed<ov::opset1::Add>>(
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{ element::f32 },
ov::op::TemporaryReplaceOutputType(dequantizationOp1, element::f32).get(),
ov::op::TemporaryReplaceOutputType(dequantizationOp2, element::f32).get())) :
std::make_shared<ov::op::TypeRelaxed<opset1::Subtract>>(
std::make_shared<ov::op::TypeRelaxed<ov::opset1::Subtract>>(
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{ element::f32 },
ov::op::TemporaryReplaceOutputType(dequantizationOp1, element::f32).get(),
@ -330,23 +330,23 @@ std::shared_ptr<ngraph::Function> AddFunction::getReference(
dequantizationOpAfter->set_friendly_name("output");
std::shared_ptr<Node> output = dequantizationOpAfter;
if (additional_output != nullptr) {
output = std::make_shared<opset1::Multiply>(dequantizationOpAfter, additional_output);
output = std::make_shared<ov::opset1::Multiply>(dequantizationOpAfter, additional_output);
output->set_friendly_name("output_multiply");
}
ngraph::ResultVector results {std::make_shared<ngraph::opset1::Result>(output)};
ov::ResultVector results {std::make_shared<ov::opset1::Result>(output)};
ngraph::ParameterVector parameters;
ov::ParameterVector parameters;
if (constInputIndex == -1) {
parameters = { ov::as_type_ptr<ngraph::opset1::Parameter>(input1), ov::as_type_ptr<ngraph::opset1::Parameter>(input2) };
parameters = { ov::as_type_ptr<ov::opset1::Parameter>(input1), ov::as_type_ptr<ov::opset1::Parameter>(input2) };
} else if (constInputIndex == 0) {
parameters = { ov::as_type_ptr<ngraph::opset1::Parameter>(input2) };
parameters = { ov::as_type_ptr<ov::opset1::Parameter>(input2) };
} else if (constInputIndex == 1) {
parameters = { ov::as_type_ptr<ngraph::opset1::Parameter>(input1) };
parameters = { ov::as_type_ptr<ov::opset1::Parameter>(input1) };
} else {
throw std::runtime_error("Unexpected constant input index");
}
return std::make_shared<ngraph::Function>(results, parameters, "AddTransformation");
return std::make_shared<ov::Model>(results, parameters, "AddTransformation");
}
} // namespace subgraph

View File

@ -4,7 +4,7 @@
#include "ov_lpt_models/align_concat_quantization_parameters.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include <ov_ops/type_relaxed.hpp>
#include "low_precision/network_helper.hpp"
@ -15,20 +15,20 @@ namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::getOriginal(
const ngraph::element::Type precision,
const ngraph::element::Type inputPrecision,
const ngraph::Shape& inputShape,
std::shared_ptr<ov::Model> AlignConcatQuantizationParametersFunction::getOriginal(
const ov::element::Type precision,
const ov::element::Type inputPrecision,
const ov::Shape& inputShape,
const bool addFQ,
const std::string additionalLayer,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore) {
const auto input1 = std::make_shared<ngraph::opset1::Parameter>(inputPrecision, ngraph::Shape(inputShape));
std::shared_ptr<ngraph::Node> parent1 = input1;
const auto input1 = std::make_shared<ov::opset1::Parameter>(inputPrecision, ov::Shape(inputShape));
std::shared_ptr<ov::Node> parent1 = input1;
{
parent1 = ngraph::builder::makeFakeQuantize(input1, precision, 256, {}, { -1.28 }, { 1.27 }, { -1.28 }, { 1.27 });
parent1->set_friendly_name("fakeQuantizeOnActivations1");
parent1 = std::make_shared<ngraph::opset1::AvgPool>(
parent1 = std::make_shared<ov::opset1::AvgPool>(
parent1,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -39,7 +39,7 @@ std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::get
parent1->set_friendly_name("avgPool1");
if (additionalLayer == "maxpool") {
parent1 = std::make_shared<ngraph::opset1::MaxPool>(
parent1 = std::make_shared<ov::opset1::MaxPool>(
parent1,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -55,13 +55,13 @@ std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::get
}
}
const auto input2 = std::make_shared<ngraph::opset1::Parameter>(inputPrecision, ngraph::Shape(inputShape));
std::shared_ptr<ngraph::Node> parent2 = input2;
const auto input2 = std::make_shared<ov::opset1::Parameter>(inputPrecision, ov::Shape(inputShape));
std::shared_ptr<ov::Node> parent2 = input2;
{
parent2 = ngraph::builder::makeFakeQuantize(input1, precision, 256, {}, { -1.28f / 2.f }, { 1.27f / 2.f }, { -1.28f / 2.f }, { 1.27f / 2.f });
parent2->set_friendly_name("fakeQuantizeOnActivations2");
parent2 = std::make_shared<ngraph::opset1::AvgPool>(
parent2 = std::make_shared<ov::opset1::AvgPool>(
parent2,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -72,7 +72,7 @@ std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::get
parent2->set_friendly_name("avgPool2");
if (additionalLayer == "maxpool") {
parent2 = std::make_shared<ngraph::opset1::MaxPool>(
parent2 = std::make_shared<ov::opset1::MaxPool>(
parent2,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -87,7 +87,7 @@ std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::get
parent2->set_friendly_name("lastFakeQuantize2");
}
}
auto parent = std::dynamic_pointer_cast<ngraph::Node>(std::make_shared<opset1::Concat>(ngraph::OutputVector{ parent1, parent2 }, 1));
auto parent = std::dynamic_pointer_cast<ov::Node>(std::make_shared<ov::opset1::Concat>(ov::OutputVector{ parent1, parent2 }, 1));
parent->set_friendly_name("concat");
{
@ -95,7 +95,7 @@ std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::get
const size_t inputChannels = 6ul;
const auto shape = Shape{ outputChannels, inputChannels, 1, 1 };
const auto fakeQuantizeOnWeights = ngraph::builder::makeFakeQuantize(
std::make_shared<opset1::Constant>(element::f32, shape, std::vector<float>(1.f, ngraph::shape_size(shape))),
std::make_shared<ov::opset1::Constant>(element::f32, shape, std::vector<float>(1.f, ov::shape_size(shape))),
precision,
255,
{outputChannels, 1, 1, 1},
@ -105,41 +105,41 @@ std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::get
std::vector<float>(outputChannels, 1.27f));
fakeQuantizeOnWeights->set_friendly_name("fakeQuantizeOnWeights");
parent = std::make_shared<ngraph::opset1::Convolution>(
parent = std::make_shared<ov::opset1::Convolution>(
ov::op::TemporaryReplaceOutputType(parent, precision).get(),
ov::op::TemporaryReplaceOutputType(fakeQuantizeOnWeights, precision).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
parent->set_friendly_name("convolution");
}
parent->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(parent) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input1, input2 }, "AlignConcatQuantizationParameters");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(parent) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input1, input2 }, "AlignConcatQuantizationParameters");
}
std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::getReference(
const ngraph::element::Type precision,
const ngraph::element::Type inputPrecision,
const ngraph::Shape& inputShape,
std::shared_ptr<ov::Model> AlignConcatQuantizationParametersFunction::getReference(
const ov::element::Type precision,
const ov::element::Type inputPrecision,
const ov::Shape& inputShape,
const bool addFQ,
const std::string additionalLayer,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter) {
const auto input1 = std::make_shared<ngraph::opset1::Parameter>(inputPrecision, ngraph::Shape(inputShape));
std::shared_ptr<ngraph::Node> parent1 = input1;
const auto input1 = std::make_shared<ov::opset1::Parameter>(inputPrecision, ov::Shape(inputShape));
std::shared_ptr<ov::Node> parent1 = input1;
{
FakeQuantizeOnData onData = { 256, {}, { -1.28f }, { 1.27f }, { 0.f }, { 255.f }, ngraph::element::u8};
FakeQuantizeOnData onData = { 256, {}, { -1.28f }, { 1.27f }, { 0.f }, { 255.f }, ov::element::u8};
parent1 = makeFakeQuantizeTypeRelaxed(input1, element::f32, onData);
ov::pass::low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(parent1, element::u8);
parent1->set_friendly_name("fakeQuantizeOnActivations1");
parent1 = std::make_shared<ngraph::opset1::AvgPool>(
parent1 = std::make_shared<ov::opset1::AvgPool>(
parent1,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -150,7 +150,7 @@ std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::get
parent1->set_friendly_name("avgPool1");
if (additionalLayer == "maxpool") {
parent1 = std::make_shared<ngraph::opset1::MaxPool>(
parent1 = std::make_shared<ov::opset1::MaxPool>(
parent1,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -166,15 +166,15 @@ std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::get
}
}
const auto input2 = std::make_shared<ngraph::opset1::Parameter>(inputPrecision, ngraph::Shape(inputShape));
std::shared_ptr<ngraph::Node> parent2 = input2;
const auto input2 = std::make_shared<ov::opset1::Parameter>(inputPrecision, ov::Shape(inputShape));
std::shared_ptr<ov::Node> parent2 = input2;
{
FakeQuantizeOnData onData = { 256, {}, { -0.64f }, { 0.635f }, { 64.f }, { 192.f }, element::u8};
parent2 = makeFakeQuantizeTypeRelaxed(input2, element::f32, onData);
ov::pass::low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(parent2, element::u8);
parent2->set_friendly_name("fakeQuantizeOnActivations2");
parent2 = std::make_shared<ngraph::opset1::AvgPool>(
parent2 = std::make_shared<ov::opset1::AvgPool>(
parent2,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -185,7 +185,7 @@ std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::get
parent2->set_friendly_name("avgPool2");
if (additionalLayer == "maxpool") {
parent2 = std::make_shared<ngraph::opset1::MaxPool>(
parent2 = std::make_shared<ov::opset1::MaxPool>(
parent2,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -200,7 +200,7 @@ std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::get
parent2->set_friendly_name("lastFakeQuantize2");
}
}
auto parent = std::dynamic_pointer_cast<ngraph::Node>(std::make_shared<opset1::Concat>(ngraph::OutputVector{ parent1, parent2 }, 1));
auto parent = std::dynamic_pointer_cast<ov::Node>(std::make_shared<ov::opset1::Concat>(ov::OutputVector{ parent1, parent2 }, 1));
parent->set_friendly_name("concat");
if (!dequantizationBefore.empty()) {
@ -211,18 +211,18 @@ std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::get
const size_t outputChannels = 9ul;
const size_t inputChannels = 6ul;
const auto shape = Shape{ outputChannels, inputChannels, 1, 1 };
const auto onWeights = std::make_shared<opset1::Constant>(
const auto onWeights = std::make_shared<ov::opset1::Constant>(
element::i8,
shape,
std::vector<size_t>(outputChannels * inputChannels, 127));
parent = std::make_shared<ngraph::opset1::Convolution>(
parent = std::make_shared<ov::opset1::Convolution>(
ov::op::TemporaryReplaceOutputType(parent, precision).get(),
ov::op::TemporaryReplaceOutputType(onWeights, precision).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
parent->set_friendly_name("convolution");
}
@ -233,8 +233,8 @@ std::shared_ptr<ngraph::Function> AlignConcatQuantizationParametersFunction::get
parent->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(parent) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input1, input2 }, "AlignConcatQuantizationParameters");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(parent) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input1, input2 }, "AlignConcatQuantizationParameters");
}
} // namespace subgraph

View File

@ -4,12 +4,11 @@
#include <memory>
#include <vector>
#include <ngraph/ngraph.hpp>
#include <ngraph/opsets/opset1.hpp>
#include <ngraph/opsets/opset3.hpp>
#include <ngraph/opsets/opset6.hpp>
#include <openvino/opsets/opset1.hpp>
#include <openvino/opsets/opset3.hpp>
#include <openvino/opsets/opset6.hpp>
#include "ov_models/subgraph_builders.hpp"
#include "openvino/op/util/variable.hpp"
#include <openvino/op/util/assign_base.hpp>
@ -22,22 +21,22 @@ namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<ngraph::Function> AssignAndReadValueFunction::getOriginal(
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> AssignAndReadValueFunction::getOriginal(
const ov::PartialShape& inputShape,
const element::Type& inputPrecision,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const size_t opsetVersion,
const bool FQAfterReadValue,
const std::vector<float>& constantValue,
const ngraph::builder::subgraph::DequantizationOperations& dequantization) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(inputPrecision, inputShape);
const auto defaultConstant = std::make_shared<opset1::Constant>(inputPrecision, inputShape.get_shape(), constantValue);
const auto input = std::make_shared<ov::opset1::Parameter>(inputPrecision, inputShape);
const auto defaultConstant = std::make_shared<ov::opset1::Constant>(inputPrecision, inputShape.get_shape(), constantValue);
const auto variable = std::make_shared<Variable>(VariableInfo{inputShape.get_shape(), inputPrecision, "id"});
std::shared_ptr<Node> readValue;
if (opsetVersion == 6) {
readValue = std::make_shared<opset6::ReadValue>(defaultConstant, variable);
readValue = std::make_shared<ov::opset6::ReadValue>(defaultConstant, variable);
} else if (opsetVersion == 3) {
readValue = std::make_shared<opset3::ReadValue>(defaultConstant, "id");
readValue = std::make_shared<ov::opset3::ReadValue>(defaultConstant, "id");
} else {
throw std::runtime_error("Unknown opset version");
}
@ -48,7 +47,7 @@ std::shared_ptr<ngraph::Function> AssignAndReadValueFunction::getOriginal(
element::f32,
FakeQuantizeOnData{256ul, Shape{}, {0}, {2.55f}, {0}, {2.55f}});
}
const auto add = std::make_shared<opset1::Add>(lastNode, input);
const auto add = std::make_shared<ov::opset1::Add>(lastNode, input);
const auto FQAfterAdd = builder::subgraph::makeFakeQuantizeTypeRelaxed(
add,
element::f32,
@ -58,31 +57,31 @@ std::shared_ptr<ngraph::Function> AssignAndReadValueFunction::getOriginal(
const auto dequantizationOp = makeDequantization(FQAfterAdd, deqStructure);
std::shared_ptr<Node> assign;
if (opsetVersion == 6) {
assign = std::make_shared<opset6::Assign>(dequantizationOp, variable);
assign = std::make_shared<ov::opset6::Assign>(dequantizationOp, variable);
} else {
assign = std::make_shared<opset3::Assign>(dequantizationOp, "id");
assign = std::make_shared<ov::opset3::Assign>(dequantizationOp, "id");
}
assign->add_control_dependency(readValue);
add->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(add) };
ngraph::SinkVector sinks{ as_type_ptr<ov::op::Sink>(assign) };
return std::make_shared<ngraph::Function>(results, sinks, ngraph::ParameterVector{ input }, "AssignAndReadValueFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(add) };
ov::SinkVector sinks{ as_type_ptr<ov::op::Sink>(assign) };
return std::make_shared<ov::Model>(results, sinks, ov::ParameterVector{ input }, "AssignAndReadValueFunction");
}
std::shared_ptr<ngraph::Function> AssignAndReadValueFunction::getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> AssignAndReadValueFunction::getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize,
const size_t opsetVersion) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto defaultConstant = std::make_shared<opset1::Constant>(precision, inputShape.get_shape(), std::vector<float>{0});
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
const auto defaultConstant = std::make_shared<ov::opset1::Constant>(precision, inputShape.get_shape(), std::vector<float>{0});
const auto variable = std::make_shared<Variable>(VariableInfo{inputShape.get_shape(), precision, "id"});
std::shared_ptr<Node> readValue;
if (opsetVersion == 6) {
readValue = std::make_shared<opset6::ReadValue>(defaultConstant, variable);
readValue = std::make_shared<ov::opset6::ReadValue>(defaultConstant, variable);
} else if (opsetVersion == 3) {
readValue = std::make_shared<opset3::ReadValue>(defaultConstant, "id");
readValue = std::make_shared<ov::opset3::ReadValue>(defaultConstant, "id");
} else {
throw std::runtime_error("Unknown opset version");
}
@ -91,7 +90,7 @@ std::shared_ptr<ngraph::Function> AssignAndReadValueFunction::getOriginal(
lastNode,
element::f32,
FakeQuantizeOnData{256ul, Shape{}, {0}, {2.55f}, {0}, {2.55f}});
const auto add = std::make_shared<opset1::Add>(lastNode, input);
const auto add = std::make_shared<ov::opset1::Add>(lastNode, input);
const auto FQAfterAdd = fakeQuantize.empty() ? nullptr :
ngraph::builder::makeFakeQuantize(
add,
@ -104,39 +103,39 @@ std::shared_ptr<ngraph::Function> AssignAndReadValueFunction::getOriginal(
fakeQuantize.outputHighValues);
std::shared_ptr<Node> assign;
if (opsetVersion == 6) {
assign = std::make_shared<opset6::Assign>(FQAfterAdd, variable);
assign = std::make_shared<ov::opset6::Assign>(FQAfterAdd, variable);
} else {
assign = std::make_shared<opset3::Assign>(FQAfterAdd, "id");
assign = std::make_shared<ov::opset3::Assign>(FQAfterAdd, "id");
}
assign->add_control_dependency(readValue);
add->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(add) };
ngraph::SinkVector sinks{ as_type_ptr<ov::op::Sink>(assign) };
return std::make_shared<ngraph::Function>(results, sinks, ngraph::ParameterVector{ input }, "AssignAndReadValueFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(add) };
ov::SinkVector sinks{ as_type_ptr<ov::op::Sink>(assign) };
return std::make_shared<ov::Model>(results, sinks, ov::ParameterVector{ input }, "AssignAndReadValueFunction");
}
std::shared_ptr<ngraph::Function> AssignAndReadValueFunction::getReference(
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> AssignAndReadValueFunction::getReference(
const ov::PartialShape& inputShape,
const element::Type& inputPrecision,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const size_t opsetVersion,
const bool FQAfterReadValue,
const std::vector<float>& constantValue,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(inputPrecision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(inputPrecision, inputShape);
auto constantPrecision = precisionBeforeDequantization;
if (constantValue != std::vector<float>{0}) {
constantPrecision = inputPrecision;
}
const auto defaultConstant = std::make_shared<opset1::Constant>(constantPrecision, inputShape.get_shape(), constantValue);
const auto defaultConstant = std::make_shared<ov::opset1::Constant>(constantPrecision, inputShape.get_shape(), constantValue);
const auto variable = std::make_shared<Variable>(VariableInfo{inputShape.get_shape(), constantPrecision, "id"});
std::shared_ptr<Node> readValue;
if (opsetVersion == 6) {
readValue = std::make_shared<opset6::ReadValue>(defaultConstant, variable);
readValue = std::make_shared<ov::opset6::ReadValue>(defaultConstant, variable);
} else if (opsetVersion == 3) {
readValue = std::make_shared<opset3::ReadValue>(defaultConstant, "id");
readValue = std::make_shared<ov::opset3::ReadValue>(defaultConstant, "id");
} else {
throw std::runtime_error("Unknown opset version");
}
@ -159,7 +158,7 @@ std::shared_ptr<ngraph::Function> AssignAndReadValueFunction::getReference(
element::f32,
FakeQuantizeOnData{256ul, Shape{}, {0}, {2.55f / dequantizationAfter.multiply.values[0]}, {0}, {2.55f}, inputPrecision});
}
const auto add = std::make_shared<opset1::Add>(lastNode, input);
const auto add = std::make_shared<ov::opset1::Add>(lastNode, input);
const auto FQAfterAdd = builder::subgraph::makeFakeQuantizeTypeRelaxed(
add,
element::f32,
@ -170,16 +169,16 @@ std::shared_ptr<ngraph::Function> AssignAndReadValueFunction::getReference(
const auto dequantizationBeforeStructure = makeDequantization(FQAfterAdd, deqStructureBefore);
std::shared_ptr<Node> assign;
if (opsetVersion == 6) {
assign = std::make_shared<opset6::Assign>(dequantizationBeforeStructure, variable);
assign = std::make_shared<ov::opset6::Assign>(dequantizationBeforeStructure, variable);
} else {
assign = std::make_shared<opset3::Assign>(dequantizationBeforeStructure, "id");
assign = std::make_shared<ov::opset3::Assign>(dequantizationBeforeStructure, "id");
}
assign->add_control_dependency(readValue);
add->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(add) };
ngraph::SinkVector sinks{ as_type_ptr<ov::op::Sink>(assign) };
return std::make_shared<ngraph::Function>(results, sinks, ngraph::ParameterVector{ input }, "AssignAndReadValueFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(add) };
ov::SinkVector sinks{ as_type_ptr<ov::op::Sink>(assign) };
return std::make_shared<ov::Model>(results, sinks, ov::ParameterVector{ input }, "AssignAndReadValueFunction");
}
} // namespace subgraph

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include <ov_ops/type_relaxed.hpp>
#include "low_precision/network_helper.hpp"
@ -15,21 +15,21 @@ namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<ngraph::Function> AvgPoolFunction::getOriginal(
const ngraph::element::Type precision,
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> AvgPoolFunction::getOriginal(
const ov::element::Type precision,
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const bool addFQ,
const std::vector<std::string>& additionalLayers,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(inputPrecision, inputShape);
std::shared_ptr<ngraph::Node> parent = input;
const auto input = std::make_shared<ov::opset1::Parameter>(inputPrecision, inputShape);
std::shared_ptr<ov::Node> parent = input;
auto deqBeforeStructure = dequantizationBefore;
deqBeforeStructure.multiply.outPrecision = precision;
const auto dequantization = makeDequantization(input, deqBeforeStructure);
const std::shared_ptr<ngraph::Node> avgPool = std::make_shared<ngraph::opset1::AvgPool>(
const std::shared_ptr<ov::Node> avgPool = std::make_shared<ov::opset1::AvgPool>(
dequantization,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -41,7 +41,7 @@ std::shared_ptr<ngraph::Function> AvgPoolFunction::getOriginal(
std::shared_ptr<Node> lastLayer = avgPool;
for (const std::string& additionalLayer : additionalLayers) {
if (additionalLayer == "maxpool") {
lastLayer = std::make_shared<ngraph::opset1::MaxPool>(
lastLayer = std::make_shared<ov::opset1::MaxPool>(
lastLayer,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -49,7 +49,7 @@ std::shared_ptr<ngraph::Function> AvgPoolFunction::getOriginal(
Shape{ 2, 2 },
op::RoundingType::FLOOR);
} else if (additionalLayer == "softmax") {
lastLayer = std::make_shared<opset1::Softmax>(lastLayer);
lastLayer = std::make_shared<ov::opset1::Softmax>(lastLayer);
} else if (additionalLayer == "convolution") {
lastLayer = makeConvolution(lastLayer, precision, false);
} else if (additionalLayer == "unsupported_convolution") {
@ -64,21 +64,21 @@ std::shared_ptr<ngraph::Function> AvgPoolFunction::getOriginal(
lastLayer->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(lastLayer) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "AvgPoolTransformation");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(lastLayer) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "AvgPoolTransformation");
}
std::shared_ptr<ngraph::Function> AvgPoolFunction::getOriginal(
const ngraph::element::Type originalFunctionPrecision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> AvgPoolFunction::getOriginal(
const ov::element::Type originalFunctionPrecision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fakeQuantizeOnData) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(originalFunctionPrecision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(originalFunctionPrecision, inputShape);
const auto fakeQuantize = ngraph::builder::makeFakeQuantize(
input, originalFunctionPrecision, fakeQuantizeOnData.quantizationLevel, fakeQuantizeOnData.constantShape,
fakeQuantizeOnData.inputLowValues, fakeQuantizeOnData.inputHighValues, fakeQuantizeOnData.outputLowValues, fakeQuantizeOnData.outputHighValues);
const std::shared_ptr<ngraph::Node> avgPool = std::make_shared<ngraph::opset1::AvgPool>(
const std::shared_ptr<ov::Node> avgPool = std::make_shared<ov::opset1::AvgPool>(
fakeQuantize,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -87,26 +87,26 @@ std::shared_ptr<ngraph::Function> AvgPoolFunction::getOriginal(
true,
op::RoundingType::FLOOR);
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(avgPool) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "AvgPoolTransformation");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(avgPool) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "AvgPoolTransformation");
}
std::shared_ptr<ngraph::Function> AvgPoolFunction::getReference(
const ngraph::element::Type precision,
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> AvgPoolFunction::getReference(
const ov::element::Type precision,
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const bool addFQ,
const std::vector<std::string>& additionalLayers,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationEnd) {
auto input = std::make_shared<ngraph::opset1::Parameter>(inputPrecision, inputShape);
auto input = std::make_shared<ov::opset1::Parameter>(inputPrecision, inputShape);
const auto deqBefore = makeDequantization(input, dequantizationBefore);
auto outPrecision = precisionAfterOperation;
const std::shared_ptr<ngraph::Node> avgPool = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::AvgPool>>(
opset1::AvgPool(
const std::shared_ptr<ov::Node> avgPool = std::make_shared<ov::op::TypeRelaxed<ov::opset1::AvgPool>>(
ov::opset1::AvgPool(
deqBefore,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -124,7 +124,7 @@ std::shared_ptr<ngraph::Function> AvgPoolFunction::getReference(
for (const std::string& additionalLayer : additionalLayers) {
if (additionalLayer == "maxpool") {
lastLayer = std::make_shared<ngraph::opset1::MaxPool>(
lastLayer = std::make_shared<ov::opset1::MaxPool>(
lastLayer,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -132,7 +132,7 @@ std::shared_ptr<ngraph::Function> AvgPoolFunction::getReference(
Shape{ 2, 2 },
op::RoundingType::FLOOR);
} else if (additionalLayer == "softmax") {
lastLayer = std::make_shared<opset1::Softmax>(lastLayer);
lastLayer = std::make_shared<ov::opset1::Softmax>(lastLayer);
} else if (additionalLayer == "convolution") {
lastLayer = makeConvolution(lastLayer, element::f32, dequantizationAfter.empty());
} else if (additionalLayer == "unsupported_convolution") {
@ -151,8 +151,8 @@ std::shared_ptr<ngraph::Function> AvgPoolFunction::getReference(
lastLayer->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(lastLayer) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "AvgPoolTransformation");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(lastLayer) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "AvgPoolTransformation");
}
} // namespace subgraph

View File

@ -4,58 +4,58 @@
#include "ov_lpt_models/batch_to_space.hpp"
#include <ngraph/opsets/opset2.hpp>
#include <openvino/opsets/opset2.hpp>
#include "ov_lpt_models/common/builders.hpp"
namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<ngraph::Function> BatchToSpaceFunction::get(const ngraph::PartialShape& input_shape,
const ngraph::element::Type input_type,
std::shared_ptr<ov::Model> BatchToSpaceFunction::get(const ov::PartialShape& input_shape,
const ov::element::Type input_type,
const FakeQuantizeOnData& fq_on_data,
const std::vector<size_t>& block_shape,
const std::vector<size_t>& crops_begin,
const std::vector<size_t>& crops_end) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(input_type, input_shape);
const auto input = std::make_shared<ov::opset1::Parameter>(input_type, input_shape);
std::shared_ptr<Node> parent = fq_on_data.empty() ?
std::dynamic_pointer_cast<ngraph::Node>(input) :
std::dynamic_pointer_cast<ov::Node>(input) :
makeFakeQuantize(input, input_type, fq_on_data);
parent = std::make_shared<ngraph::opset2::BatchToSpace>(
parent = std::make_shared<ov::opset2::BatchToSpace>(
parent,
std::make_shared<ngraph::opset1::Constant>(ngraph::element::i64, ngraph::Shape{ block_shape.size() }, block_shape),
std::make_shared<ngraph::opset1::Constant>(ngraph::element::i64, ngraph::Shape{ crops_begin.size() }, crops_begin),
std::make_shared<ngraph::opset1::Constant>(ngraph::element::i64, ngraph::Shape{ crops_end.size() }, crops_end));
std::make_shared<ov::opset1::Constant>(ov::element::i64, ov::Shape{ block_shape.size() }, block_shape),
std::make_shared<ov::opset1::Constant>(ov::element::i64, ov::Shape{ crops_begin.size() }, crops_begin),
std::make_shared<ov::opset1::Constant>(ov::element::i64, ov::Shape{ crops_end.size() }, crops_end));
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(parent)};
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "BatchToSpaceFunction");
ov::ResultVector results{std::make_shared<ov::opset1::Result>(parent)};
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "BatchToSpaceFunction");
}
std::shared_ptr<ngraph::Function> BatchToSpaceFunction::get(const ngraph::PartialShape& input_shape,
const ngraph::element::Type input_type,
std::shared_ptr<ov::Model> BatchToSpaceFunction::get(const ov::PartialShape& input_shape,
const ov::element::Type input_type,
const ngraph::builder::subgraph::DequantizationOperations& dequantization_before,
const std::vector<size_t>& block_shape,
const std::vector<size_t>& crops_begin,
const std::vector<size_t>& crops_end,
const ngraph::builder::subgraph::DequantizationOperations& dequantization_after) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(input_type, input_shape);
const auto input = std::make_shared<ov::opset1::Parameter>(input_type, input_shape);
std::shared_ptr<Node> parent = dequantization_before.empty() ?
std::dynamic_pointer_cast<ngraph::Node>(input) :
std::dynamic_pointer_cast<ov::Node>(input) :
makeDequantization(input, dequantization_before);
parent = std::make_shared<ngraph::opset2::BatchToSpace>(
parent = std::make_shared<ov::opset2::BatchToSpace>(
parent,
std::make_shared<ngraph::opset1::Constant>(ngraph::element::i64, ngraph::Shape{ block_shape.size() }, block_shape),
std::make_shared<ngraph::opset1::Constant>(ngraph::element::i64, ngraph::Shape{ crops_begin.size() }, crops_begin),
std::make_shared<ngraph::opset1::Constant>(ngraph::element::i64, ngraph::Shape{ crops_end.size() }, crops_end));
std::make_shared<ov::opset1::Constant>(ov::element::i64, ov::Shape{ block_shape.size() }, block_shape),
std::make_shared<ov::opset1::Constant>(ov::element::i64, ov::Shape{ crops_begin.size() }, crops_begin),
std::make_shared<ov::opset1::Constant>(ov::element::i64, ov::Shape{ crops_end.size() }, crops_end));
parent = makeDequantization(parent, dequantization_after);
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(parent)};
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "BatchToSpaceFunction");
ov::ResultVector results{std::make_shared<ov::opset1::Result>(parent)};
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "BatchToSpaceFunction");
}
} // namespace subgraph

View File

@ -4,10 +4,9 @@
#include <memory>
#include <vector>
#include <ngraph/ngraph.hpp>
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include "ov_models/subgraph_builders.hpp"
#include "ov_lpt_models/common/builders.hpp"
#include "ov_lpt_models/clamp.hpp"
@ -17,27 +16,27 @@ namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<ngraph::Function> ClampFunction::getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
std::shared_ptr<ov::Model> ClampFunction::getOriginal(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precisionBeforeDequantization, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precisionBeforeDequantization, inputShape);
const std::shared_ptr<Node> dequantizationOp = makeDequantization(input, dequantization);
const std::shared_ptr<Node> clamp = std::make_shared<ngraph::opset1::Clamp>(dequantizationOp, 0, 10);
const std::shared_ptr<Node> clamp = std::make_shared<ov::opset1::Clamp>(dequantizationOp, 0, 10);
clamp->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(clamp) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "ClampFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(clamp) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "ClampFunction");
}
std::shared_ptr<ngraph::Function> ClampFunction::getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> ClampFunction::getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize,
const double clampLowConst,
const double clampHighConst) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
const std::shared_ptr<Node> fq = fakeQuantize.empty() ? nullptr :
ngraph::builder::makeFakeQuantize(
@ -50,46 +49,46 @@ std::shared_ptr<ngraph::Function> ClampFunction::getOriginal(
fakeQuantize.outputLowValues,
fakeQuantize.outputHighValues);
const std::shared_ptr<ngraph::opset1::Clamp> clamp = std::make_shared<ngraph::opset1::Clamp>(
const std::shared_ptr<ov::opset1::Clamp> clamp = std::make_shared<ov::opset1::Clamp>(
fakeQuantize.empty() ? input : fq,
clampLowConst,
clampHighConst);
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(clamp) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "ClampFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(clamp) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "ClampFunction");
}
std::shared_ptr<ngraph::Function> ClampFunction::getWithNonDequantizationMultiply(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precision) {
const auto input1 = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto input2 = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
std::shared_ptr<ov::Model> ClampFunction::getWithNonDequantizationMultiply(
const ov::PartialShape& inputShape,
const ov::element::Type precision) {
const auto input1 = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
const auto input2 = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
const auto multiply = std::make_shared<ngraph::opset1::Multiply>(input1, input2);
const auto clamp = std::make_shared<ngraph::opset1::Clamp>(multiply, 0.0, 6.0);
const auto multiply = std::make_shared<ov::opset1::Multiply>(input1, input2);
const auto clamp = std::make_shared<ov::opset1::Clamp>(multiply, 0.0, 6.0);
clamp->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(clamp) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input1, input2 }, "ClampFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(clamp) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input1, input2 }, "ClampFunction");
}
std::shared_ptr<ngraph::Function> ClampFunction::getReference(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeDequantization,
std::shared_ptr<ov::Model> ClampFunction::getReference(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precisionBeforeDequantization, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precisionBeforeDequantization, inputShape);
std::shared_ptr<Node> quantizationOpBefore = makeDequantization(input, dequantizationBefore);
std::shared_ptr<ngraph::opset1::Clamp> clamp = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Clamp>>(quantizationOpBefore, 0, 10);
std::shared_ptr<ov::opset1::Clamp> clamp = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Clamp>>(quantizationOpBefore, 0, 10);
ov::pass::low_precision::NetworkHelper::setOutDataPrecision(clamp, precisionAfterOperation);
const std::shared_ptr<Node> quantizationOpAfter = makeDequantization(clamp, dequantizationAfter);
quantizationOpAfter->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(quantizationOpAfter) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "ClampFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(quantizationOpAfter) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "ClampFunction");
}
} // namespace subgraph

View File

@ -3,7 +3,6 @@
//
#include "ov_lpt_models/common/add.hpp"
#include <ngraph/opsets/opset1.hpp>
namespace ngraph {
namespace builder {
@ -11,25 +10,25 @@ namespace subgraph {
Add::Add() :
isEmpty(true),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
constantShapeIsDefined(false)
{}
Add::Add(const float value) :
isEmpty(false),
values({ value }),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
constantShapeIsDefined(false) {
}
Add::Add(const std::vector<float>& values) :
isEmpty(values.empty()),
values(values),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
constantShapeIsDefined(false) {
}
Add::Add(const std::vector<float>& values, const ngraph::element::Type outPrecision) :
Add::Add(const std::vector<float>& values, const ov::element::Type outPrecision) :
isEmpty(false),
values(values),
outPrecision(outPrecision),
@ -38,8 +37,8 @@ Add::Add(const std::vector<float>& values, const ngraph::element::Type outPrecis
Add::Add(
const std::vector<float>& values,
const ngraph::element::Type outPrecision,
const ngraph::Shape& constantShape) :
const ov::element::Type outPrecision,
const ov::Shape& constantShape) :
isEmpty(false),
values(values),
outPrecision(outPrecision),

View File

@ -7,7 +7,7 @@
#include <queue>
#include <memory>
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include "ov_ops/type_relaxed.hpp"
#include "ov_models/subgraph_builders.hpp"
#include "low_precision/network_helper.hpp"
@ -24,14 +24,14 @@ std::shared_ptr<Node> makeDequantization(
Output<Node> parent = data;
if (!dequantizationOperations.convert.empty()) {
auto convert = std::make_shared<opset1::Convert>(data, dequantizationOperations.convert.outPrecision);
auto convert = std::make_shared<ov::opset1::Convert>(data, dequantizationOperations.convert.outPrecision);
NetworkHelper::copyInfo({ data.get_node_shared_ptr(), convert }, convert);
convert->set_friendly_name(data.get_node_shared_ptr()->get_friendly_name() + "/DequantizationConvert");
parent = convert;
}
if (!dequantizationOperations.subtract.empty()) {
std::shared_ptr<ngraph::opset1::Subtract> subtract;
std::shared_ptr<ov::opset1::Subtract> subtract;
std::vector<size_t> shape;
auto values = dequantizationOperations.subtract.values;
@ -50,7 +50,7 @@ std::shared_ptr<Node> makeDequantization(
}
}
std::shared_ptr<Node> subtractConst = std::make_shared<ngraph::opset1::Constant>(
std::shared_ptr<Node> subtractConst = std::make_shared<ov::opset1::Constant>(
dequantizationOperations.subtract.constantPrecision != element::undefined ?
dequantizationOperations.subtract.constantPrecision :
parent.get_element_type(),
@ -58,7 +58,7 @@ std::shared_ptr<Node> makeDequantization(
values);
if (dequantizationOperations.subtract.addConvert) {
std::shared_ptr<Node> subtractConstConvert = std::make_shared<ngraph::opset1::Convert>(
std::shared_ptr<Node> subtractConstConvert = std::make_shared<ov::opset1::Convert>(
subtractConst,
dequantizationOperations.subtract.outPrecision == element::undefined ?
parent.get_element_type() :
@ -81,17 +81,17 @@ std::shared_ptr<Node> makeDequantization(
(dequantizationOperations.subtract.constantPrecision == parent.get_element_type())) ||
dequantizationOperations.subtract.addConvert)) {
subtract = dequantizationOperations.subtract.constantIndex == 1ul ?
std::make_shared<opset1::Subtract>(parent, subtractConst) :
subtract = std::make_shared<opset1::Subtract>(subtractConst, parent);
std::make_shared<ov::opset1::Subtract>(parent, subtractConst) :
subtract = std::make_shared<ov::opset1::Subtract>(subtractConst, parent);
} else {
if (dequantizationOperations.subtract.constantIndex == 1ul) {
subtract = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Subtract>>(
subtract = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Subtract>>(
std::vector<element::Type>{element::f32, element::f32},
std::vector<element::Type>{ element::f32 },
ov::op::TemporaryReplaceOutputType(parent, element::f32).get(),
ov::op::TemporaryReplaceOutputType(subtractConst, element::f32).get());
} else {
subtract = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Subtract>>(
subtract = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Subtract>>(
std::vector<element::Type>{element::f32, element::f32},
std::vector<element::Type>{ element::f32 },
ov::op::TemporaryReplaceOutputType(subtractConst, element::f32).get(),
@ -142,12 +142,12 @@ std::shared_ptr<Node> makeMultiply(const Output<Node>& parent, const Dequantizat
}
}
std::shared_ptr<ngraph::opset1::Multiply> newMultiply;
std::shared_ptr<ov::opset1::Multiply> newMultiply;
if (((multiply.outPrecision == element::undefined) ||
(multiply.outPrecision == parent.get_element_type())) &&
((multiply.constantPrecision == element::undefined) ||
(multiply.constantPrecision == parent.get_element_type()))) {
const std::shared_ptr<ngraph::opset1::Constant> constant = std::make_shared<ngraph::opset1::Constant>(
const std::shared_ptr<ov::opset1::Constant> constant = std::make_shared<ov::opset1::Constant>(
multiply.constantPrecision != element::undefined ?
multiply.constantPrecision :
parent.get_element_type(),
@ -155,10 +155,10 @@ std::shared_ptr<Node> makeMultiply(const Output<Node>& parent, const Dequantizat
values);
newMultiply = multiply.constantIndex == 1ul ?
std::make_shared<ngraph::opset1::Multiply>(parent, constant) :
std::make_shared<ngraph::opset1::Multiply>(constant, parent);
std::make_shared<ov::opset1::Multiply>(parent, constant) :
std::make_shared<ov::opset1::Multiply>(constant, parent);
} else {
const std::shared_ptr<ngraph::opset1::Constant> constant = std::make_shared<ngraph::opset1::Constant>(
const std::shared_ptr<ov::opset1::Constant> constant = std::make_shared<ov::opset1::Constant>(
multiply.constantPrecision != element::undefined ?
multiply.constantPrecision :
parent.get_element_type(),
@ -167,12 +167,12 @@ std::shared_ptr<Node> makeMultiply(const Output<Node>& parent, const Dequantizat
// TODO: use templates
newMultiply = multiply.constantIndex == 1ul ?
std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Multiply>>(
std::make_shared<ov::op::TypeRelaxed<ov::opset1::Multiply>>(
std::vector<element::Type>{element::f32, element::f32},
std::vector<element::Type>{ multiply.outPrecision },
ov::op::TemporaryReplaceOutputType(parent, element::f32).get(),
ov::op::TemporaryReplaceOutputType(constant, element::f32).get()) :
std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Multiply>>(
std::make_shared<ov::op::TypeRelaxed<ov::opset1::Multiply>>(
std::vector<element::Type>{element::f32, element::f32},
std::vector<element::Type>{ multiply.outPrecision },
ov::op::TemporaryReplaceOutputType(constant, element::f32).get(),
@ -183,20 +183,20 @@ std::shared_ptr<Node> makeMultiply(const Output<Node>& parent, const Dequantizat
}
std::shared_ptr<Node> makeReshape(const Output<Node>& data, const Reshape& reshape) {
auto constant = makeConstant(ngraph::element::i64, Shape({ reshape.values.size() }), reshape.values);
return std::make_shared<ngraph::opset1::Reshape>(data, constant->output(0), reshape.special_zero);
auto constant = makeConstant(ov::element::i64, Shape({ reshape.values.size() }), reshape.values);
return std::make_shared<ov::opset1::Reshape>(data, constant->output(0), reshape.special_zero);
}
std::shared_ptr<Node> makeTranspose(const Output<Node>& data, const Transpose& transpose) {
auto constant = makeConstant(ngraph::element::i64, Shape({ transpose.values.size() }), transpose.values);
return std::make_shared<ngraph::opset1::Transpose>(data, constant->output(0));
auto constant = makeConstant(ov::element::i64, Shape({ transpose.values.size() }), transpose.values);
return std::make_shared<ov::opset1::Transpose>(data, constant->output(0));
}
std::shared_ptr<ngraph::opset1::FakeQuantize> makeFakeQuantize(
std::shared_ptr<ov::opset1::FakeQuantize> makeFakeQuantize(
const Output<Node>& output,
const ngraph::element::Type constantType,
const ov::element::Type constantType,
const FakeQuantizeOnData& fqOnData) {
return ov::as_type_ptr<ngraph::opset1::FakeQuantize>(ngraph::builder::makeFakeQuantize(
return ov::as_type_ptr<ov::opset1::FakeQuantize>(ngraph::builder::makeFakeQuantize(
output,
constantType,
fqOnData.quantizationLevel,
@ -207,19 +207,19 @@ std::shared_ptr<ngraph::opset1::FakeQuantize> makeFakeQuantize(
fqOnData.outputHighValues));
}
std::shared_ptr<ngraph::opset1::Convolution> makeConvolution(const Output<Node>& output, const Convolution& convolution) {
std::shared_ptr<ov::opset1::Convolution> makeConvolution(const Output<Node>& output, const Convolution& convolution) {
auto parentOnActivations = output;
if (!convolution.zeroPointOnActivations.empty()) {
auto constant = std::make_shared<ngraph::opset1::Constant>(
auto constant = std::make_shared<ov::opset1::Constant>(
convolution.zeroPointOnActivations.outPrecision,
convolution.zeroPointOnActivations.constantShape,
convolution.zeroPointOnActivations.values);
parentOnActivations = std::make_shared<ngraph::opset1::Subtract>(parentOnActivations, constant);
parentOnActivations = std::make_shared<ov::opset1::Subtract>(parentOnActivations, constant);
}
assert(!convolution.constantOnWeights.empty());
ngraph::Output<ngraph::Node> weights = std::make_shared<ngraph::opset1::Constant>(
ov::Output<ov::Node> weights = std::make_shared<ov::opset1::Constant>(
convolution.constantOnWeights.outPrecision,
convolution.constantOnWeights.shape,
convolution.constantOnWeights.values);
@ -228,60 +228,60 @@ std::shared_ptr<ngraph::opset1::Convolution> makeConvolution(const Output<Node>&
weights = makeDequantization(weights, convolution.dequantizationOnWeights);
}
return std::make_shared<ngraph::opset1::Convolution>(
return std::make_shared<ov::opset1::Convolution>(
parentOnActivations,
weights,
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
}
std::shared_ptr<ngraph::opset1::FakeQuantize> makeFakeQuantizeTypeRelaxed(
const Output<ngraph::Node>& output,
const ngraph::element::Type precision,
std::shared_ptr<ov::opset1::FakeQuantize> makeFakeQuantizeTypeRelaxed(
const Output<ov::Node>& output,
const ov::element::Type precision,
const FakeQuantizeOnData& fqOnData) {
const std::shared_ptr<ngraph::opset1::FakeQuantize> fq = makeFakeQuantize(output, precision, fqOnData);
return std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::FakeQuantize>>(
const std::shared_ptr<ov::opset1::FakeQuantize> fq = makeFakeQuantize(output, precision, fqOnData);
return std::make_shared<ov::op::TypeRelaxed<ov::opset1::FakeQuantize>>(
*fq,
fqOnData.outputPrecision == element::undefined ? precision : fqOnData.outputPrecision);
}
std::shared_ptr<ngraph::opset1::FakeQuantize> makeFakeQuantize(
std::shared_ptr<ov::opset1::FakeQuantize> makeFakeQuantize(
const Output<Node>& input,
const ngraph::element::Type constantPrecision,
const ov::element::Type constantPrecision,
const FakeQuantizeOnDataWithConstant& fqOnData,
const bool subgraphOnConstantPath) {
std::shared_ptr<Node> inputLowNode;
std::shared_ptr<Node> inputHighNode;
if (subgraphOnConstantPath) {
const auto topConstant = ngraph::builder::makeConstant(constantPrecision, ngraph::Shape{1}, std::vector<float>(1, 0.f), false);
const auto convert = std::make_shared<opset1::Convert>(topConstant, element::f32);
const auto topConstant = ngraph::builder::makeConstant(constantPrecision, ov::Shape{1}, std::vector<float>(1, 0.f), false);
const auto convert = std::make_shared<ov::opset1::Convert>(topConstant, element::f32);
const auto subtractMin = std::make_shared<opset1::Subtract>(
std::make_shared<opset1::Constant>(constantPrecision, ngraph::Shape{ 1 }, std::vector<float>{fqOnData.outputLowValues[0]}),
const auto subtractMin = std::make_shared<ov::opset1::Subtract>(
std::make_shared<ov::opset1::Constant>(constantPrecision, ov::Shape{ 1 }, std::vector<float>{fqOnData.outputLowValues[0]}),
convert);
const auto subtractMax = std::make_shared<opset1::Subtract>(
std::make_shared<opset1::Constant>(constantPrecision, ngraph::Shape{ 1 }, std::vector<float>{fqOnData.outputHighValues[0]}),
const auto subtractMax = std::make_shared<ov::opset1::Subtract>(
std::make_shared<ov::opset1::Constant>(constantPrecision, ov::Shape{ 1 }, std::vector<float>{fqOnData.outputHighValues[0]}),
convert);
inputLowNode = std::make_shared<opset1::Multiply>(
std::make_shared<opset1::Constant>(
inputLowNode = std::make_shared<ov::opset1::Multiply>(
std::make_shared<ov::opset1::Constant>(
constantPrecision,
ngraph::Shape{ 1 },
ov::Shape{ 1 },
std::vector<float>{fqOnData.inputLowValues[0] / fqOnData.outputLowValues[0]}),
subtractMin);
inputHighNode = std::make_shared<opset1::Multiply>(
std::make_shared<opset1::Constant>(
inputHighNode = std::make_shared<ov::opset1::Multiply>(
std::make_shared<ov::opset1::Constant>(
constantPrecision,
ngraph::Shape{ 1 },
ov::Shape{ 1 },
std::vector<float>{fqOnData.inputHighValues[0] / fqOnData.outputHighValues[0]}),
subtractMax);
} else {
inputLowNode = ngraph::builder::makeConstant(
constantPrecision,
fqOnData.constantShapes.empty() ? ngraph::Shape{} : fqOnData.constantShapes[0],
fqOnData.constantShapes.empty() ? ov::Shape{} : fqOnData.constantShapes[0],
fqOnData.inputLowValues,
fqOnData.inputLowValues.empty());
if (fqOnData.addConverts) {
@ -291,7 +291,7 @@ std::shared_ptr<ngraph::opset1::FakeQuantize> makeFakeQuantize(
inputHighNode = ngraph::builder::makeConstant(
constantPrecision,
fqOnData.constantShapes.empty() ?
ngraph::Shape{} :
ov::Shape{} :
(fqOnData.constantShapes.size() == 1 ? fqOnData.constantShapes[0] : fqOnData.constantShapes[1]),
fqOnData.inputHighValues,
fqOnData.inputHighValues.empty());
@ -303,7 +303,7 @@ std::shared_ptr<ngraph::opset1::FakeQuantize> makeFakeQuantize(
auto outputLowNode = ngraph::builder::makeConstant(
constantPrecision,
fqOnData.constantShapes.empty() ?
ngraph::Shape{} :
ov::Shape{} :
(fqOnData.constantShapes.size() == 1 ? fqOnData.constantShapes[0] : fqOnData.constantShapes[2]),
fqOnData.outputLowValues,
fqOnData.outputLowValues.empty());
@ -314,7 +314,7 @@ std::shared_ptr<ngraph::opset1::FakeQuantize> makeFakeQuantize(
auto outputHighNode = ngraph::builder::makeConstant(
constantPrecision,
fqOnData.constantShapes.empty() ?
ngraph::Shape{} :
ov::Shape{} :
(fqOnData.constantShapes.size() == 1 ? fqOnData.constantShapes[0] : fqOnData.constantShapes[3]),
fqOnData.outputHighValues,
fqOnData.outputHighValues.empty());
@ -322,7 +322,7 @@ std::shared_ptr<ngraph::opset1::FakeQuantize> makeFakeQuantize(
outputHighNode = std::make_shared<ov::op::v0::Convert>(outputHighNode, ov::element::f32);
}
auto fq = std::make_shared<ngraph::opset1::FakeQuantize>(input, inputLowNode, inputHighNode, outputLowNode, outputHighNode, fqOnData.quantizationLevel);
auto fq = std::make_shared<ov::opset1::FakeQuantize>(input, inputLowNode, inputHighNode, outputLowNode, outputHighNode, fqOnData.quantizationLevel);
auto& rt = fq->get_rt_info();
for (auto& attribute : fqOnData.attributes) {
@ -334,17 +334,17 @@ std::shared_ptr<ngraph::opset1::FakeQuantize> makeFakeQuantize(
return fq;
}
std::shared_ptr<ngraph::opset1::FakeQuantize> makeFakeQuantizeTypeRelaxed(
const std::shared_ptr<ngraph::Node>& input,
const ngraph::element::Type constantPrecision,
std::shared_ptr<ov::opset1::FakeQuantize> makeFakeQuantizeTypeRelaxed(
const std::shared_ptr<ov::Node>& input,
const ov::element::Type constantPrecision,
const FakeQuantizeOnDataWithConstant& fqOnData) {
const std::shared_ptr<ngraph::opset1::FakeQuantize> fq = makeFakeQuantize(input, constantPrecision, fqOnData);
return std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::FakeQuantize>>(
const std::shared_ptr<ov::opset1::FakeQuantize> fq = makeFakeQuantize(input, constantPrecision, fqOnData);
return std::make_shared<ov::op::TypeRelaxed<ov::opset1::FakeQuantize>>(
*fq,
fqOnData.outputPrecision == ngraph::element::undefined ? constantPrecision : fqOnData.outputPrecision);
fqOnData.outputPrecision == ov::element::undefined ? constantPrecision : fqOnData.outputPrecision);
}
void addAttributes(std::vector<std::shared_ptr<ngraph::Node>> nodes, std::vector<ov::Any> attributes) {
void addAttributes(std::vector<std::shared_ptr<ov::Node>> nodes, std::vector<ov::Any> attributes) {
for (const auto& node : nodes) {
for (const auto& attribute : attributes) {
if (attribute.is<ov::RuntimeAttribute>()) {
@ -365,10 +365,10 @@ std::shared_ptr<Node> makeConvolution(
std::shared_ptr<Node> weights;
if (weightsWithoutFQ) {
weights = std::make_shared<opset1::Constant>(weightsprecision, shape, std::vector<int>(ngraph::shape_size(shape), 100));
weights = std::make_shared<ov::opset1::Constant>(weightsprecision, shape, std::vector<int>(ov::shape_size(shape), 100));
} else {
weights = ngraph::builder::makeFakeQuantize(
std::make_shared<opset1::Constant>(precision, shape, std::vector<float>(ngraph::shape_size(shape), 1.f)),
std::make_shared<ov::opset1::Constant>(precision, shape, std::vector<float>(ov::shape_size(shape), 1.f)),
precision,
255,
{ outputChannels, 1, 1, 1 },
@ -379,13 +379,13 @@ std::shared_ptr<Node> makeConvolution(
weights->set_friendly_name("fakeQuantizeOnWeights");
}
const auto convolution = std::make_shared<ngraph::opset1::Convolution>(
const auto convolution = std::make_shared<ov::opset1::Convolution>(
ov::op::TemporaryReplaceOutputType(parent, precision).get(),
ov::op::TemporaryReplaceOutputType(weights, precision).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
convolution->set_friendly_name("convolution");

View File

@ -3,7 +3,6 @@
//
#include "ov_lpt_models/common/constant.hpp"
#include <ngraph/opsets/opset1.hpp>
namespace ngraph {
namespace builder {
@ -11,25 +10,25 @@ namespace subgraph {
Constant::Constant() :
isEmpty(true),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
shapeIsDefined(false)
{}
Constant::Constant(const float value) :
isEmpty(false),
values({ value }),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
shapeIsDefined(false) {
}
Constant::Constant(const std::vector<float>& values) :
isEmpty(values.empty()),
values(values),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
shapeIsDefined(false) {
}
Constant::Constant(const std::vector<float>& values, const ngraph::element::Type outPrecision) :
Constant::Constant(const std::vector<float>& values, const ov::element::Type outPrecision) :
isEmpty(false),
values(values),
outPrecision(outPrecision),
@ -38,8 +37,8 @@ Constant::Constant(const std::vector<float>& values, const ngraph::element::Type
Constant::Constant(
const std::vector<float>& values,
const ngraph::element::Type outPrecision,
const ngraph::Shape& shape) :
const ov::element::Type outPrecision,
const ov::Shape& shape) :
isEmpty(false),
values(values),
outPrecision(outPrecision),

View File

@ -3,7 +3,7 @@
//
#include "ov_lpt_models/common/dequantization_operations.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
namespace ngraph {
namespace builder {
@ -11,10 +11,10 @@ namespace subgraph {
DequantizationOperations::Convert::Convert() :
isEmpty(true),
outPrecision(ngraph::element::undefined)
outPrecision(ov::element::undefined)
{}
DequantizationOperations::Convert::Convert(const ngraph::element::Type outPrecision, const bool toRemove) :
DequantizationOperations::Convert::Convert(const ov::element::Type outPrecision, const bool toRemove) :
isEmpty(false),
outPrecision(outPrecision)
{}
@ -29,27 +29,27 @@ bool DequantizationOperations::Convert::equal(const DequantizationOperations::Co
DequantizationOperations::Subtract::Subtract() :
isEmpty(true),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
constantShapeIsDefined(false)
{}
DequantizationOperations::Subtract::Subtract(const float value, const bool toRemove) :
isEmpty(false),
values({ value }),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
constantShapeIsDefined(false) {
}
DequantizationOperations::Subtract::Subtract(const std::vector<float>& values) :
isEmpty(values.empty()),
values(values),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
constantShapeIsDefined(false) {
}
DequantizationOperations::Subtract::Subtract(
const std::vector<float>& values,
const ngraph::element::Type outPrecision) :
const ov::element::Type outPrecision) :
isEmpty(false),
values(values),
outPrecision(outPrecision),
@ -58,11 +58,11 @@ DequantizationOperations::Subtract::Subtract(
DequantizationOperations::Subtract::Subtract(
const std::vector<float>& values,
const ngraph::element::Type outPrecision,
const ngraph::Shape& constantShape,
const ov::element::Type outPrecision,
const ov::Shape& constantShape,
const bool toRemove,
const size_t constantIndex,
const ngraph::element::Type constantPrecision,
const ov::element::Type constantPrecision,
const bool addConvert,
const ov::Node::RTMap& attributes,
const ov::Node::RTMap& convertAttributes) :
@ -91,32 +91,32 @@ bool DequantizationOperations::Subtract::equal(const DequantizationOperations::S
(constantIndex == value.constantIndex);
}
DequantizationOperations::Subtract& DequantizationOperations::Subtract::setConstantPrecision(const ngraph::element::Type& precision) {
DequantizationOperations::Subtract& DequantizationOperations::Subtract::setConstantPrecision(const ov::element::Type& precision) {
constantPrecision = precision;
return *this;
}
DequantizationOperations::Multiply::Multiply() :
isEmpty(true),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
constantShapeIsDefined(false) {
}
DequantizationOperations::Multiply::Multiply(const float value) :
isEmpty(false),
values({ value }),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
constantShapeIsDefined(false) {
}
DequantizationOperations::Multiply::Multiply(const std::vector<float>& values) :
isEmpty(values.empty()),
values(values),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
constantShapeIsDefined(false) {
}
DequantizationOperations::Multiply::Multiply(const std::vector<float>& values, const ngraph::element::Type outPrecision) :
DequantizationOperations::Multiply::Multiply(const std::vector<float>& values, const ov::element::Type outPrecision) :
isEmpty(false),
values(values),
outPrecision(outPrecision),
@ -125,11 +125,11 @@ DequantizationOperations::Multiply::Multiply(const std::vector<float>& values, c
DequantizationOperations::Multiply::Multiply(
const std::vector<float>& values,
const ngraph::element::Type outPrecision,
const ngraph::Shape& constantShape,
const ov::element::Type outPrecision,
const ov::Shape& constantShape,
const bool toRemove,
const size_t constantIndex,
ngraph::element::Type constantPrecision) :
ov::element::Type constantPrecision) :
isEmpty(false),
values(values),
outPrecision(outPrecision),
@ -161,7 +161,7 @@ bool DequantizationOperations::equal(const DequantizationOperations& value) cons
(multiply == value.multiply);
}
DequantizationOperations::Multiply& DequantizationOperations::Multiply::setConstantPrecision(const ngraph::element::Type& precision) {
DequantizationOperations::Multiply& DequantizationOperations::Multiply::setConstantPrecision(const ov::element::Type& precision) {
constantPrecision = precision;
return *this;
}
@ -177,7 +177,7 @@ DequantizationOperations::DequantizationOperations(
multiply(multiply)
{}
void DequantizationOperations::setPrecision(const ngraph::element::Type& type) noexcept {
void DequantizationOperations::setPrecision(const ov::element::Type& type) noexcept {
convert.outPrecision = type;
subtract.constantPrecision = type;
subtract.outPrecision = type;

View File

@ -3,7 +3,7 @@
//
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
namespace ngraph {
namespace builder {
@ -13,12 +13,12 @@ FakeQuantizeOnData::FakeQuantizeOnData() : quantizationLevel(0) {}
FakeQuantizeOnData::FakeQuantizeOnData(
const uint64_t quantizationLevel,
const ngraph::Shape& constantShape,
const ov::Shape& constantShape,
const std::vector<float>& inputLowValues,
const std::vector<float>& inputHighValues,
const std::vector<float>& outputLowValues,
const std::vector<float>& outputHighValues,
const ngraph::element::Type outputPrecision,
const ov::element::Type outputPrecision,
const std::vector<ov::Any>& attributes) :
quantizationLevel(quantizationLevel),
constantShape(constantShape),
@ -48,16 +48,16 @@ bool FakeQuantizeOnData::empty() const {
FakeQuantizeOnDataWithConstant::FakeQuantizeOnDataWithConstant() :
quantizationLevel(0),
outputPrecision(ngraph::element::undefined) {}
outputPrecision(ov::element::undefined) {}
FakeQuantizeOnDataWithConstant::FakeQuantizeOnDataWithConstant(
const uint64_t quantizationLevel,
const std::vector<ngraph::Shape>& constantShapes,
const std::vector<ov::Shape>& constantShapes,
const std::vector<float>& inputLowValues,
const std::vector<float>& inputHighValues,
const std::vector<float>& outputLowValues,
const std::vector<float>& outputHighValues,
const ngraph::element::Type outputPrecision,
const ov::element::Type outputPrecision,
const std::vector<ov::Any>& attributes,
const bool addConverts) :
quantizationLevel(quantizationLevel),

View File

@ -3,7 +3,7 @@
//
#include "ov_lpt_models/common/fake_quantize_on_weights.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
namespace ngraph {
namespace builder {
@ -13,12 +13,12 @@ FakeQuantizeOnWeights::FakeQuantizeOnWeights() {}
FakeQuantizeOnWeights::FakeQuantizeOnWeights(
const uint64_t quantizationLevel,
const ngraph::Shape& constantShape,
const ov::Shape& constantShape,
const std::vector<float>& inputLowValues,
const std::vector<float>& inputHighValues,
const std::vector<float>& outputLowValues,
const std::vector<float>& outputHighValues,
const ngraph::element::Type outputPrecision) :
const ov::element::Type outputPrecision) :
FakeQuantizeOnData(quantizationLevel, constantShape, inputLowValues, inputHighValues, outputLowValues, outputHighValues, outputPrecision) {}
FakeQuantizeOnWeights::~FakeQuantizeOnWeights() {}

View File

@ -3,7 +3,7 @@
//
#include "ov_lpt_models/common/multiply.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
namespace ngraph {
namespace builder {
@ -11,25 +11,25 @@ namespace subgraph {
Multiply::Multiply() :
isEmpty(true),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
constantShapeIsDefined(false) {
}
Multiply::Multiply(const float value) :
isEmpty(false),
values({ value }),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
constantShapeIsDefined(false) {
}
Multiply::Multiply(const std::vector<float>& values) :
isEmpty(values.empty()),
values(values),
outPrecision(ngraph::element::undefined),
outPrecision(ov::element::undefined),
constantShapeIsDefined(false) {
}
Multiply::Multiply(const std::vector<float>& values, const ngraph::element::Type outPrecision) :
Multiply::Multiply(const std::vector<float>& values, const ov::element::Type outPrecision) :
isEmpty(false),
values(values),
outPrecision(outPrecision),
@ -38,8 +38,8 @@ Multiply::Multiply(const std::vector<float>& values, const ngraph::element::Type
Multiply::Multiply(
const std::vector<float>& values,
const ngraph::element::Type outPrecision,
const ngraph::Shape& constantShape) :
const ov::element::Type outPrecision,
const ov::Shape& constantShape) :
isEmpty(false),
values(values),
outPrecision(outPrecision),

View File

@ -5,7 +5,7 @@
#include "ov_lpt_models/compose_fake_quantize.hpp"
#include "low_precision/network_helper.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include "ov_models/subgraph_builders.hpp"
#include "ov_lpt_models/common/builders.hpp"
@ -15,31 +15,31 @@ namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<ngraph::Function> ComposeFakeQuantizeFunction::get(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
std::shared_ptr<ov::Model> ComposeFakeQuantizeFunction::get(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData,
const ngraph::builder::subgraph::DequantizationOperations& dequantization1,
const ngraph::builder::subgraph::DequantizationOperations& dequantization2) {
const auto input = std::make_shared<ngraph::op::v0::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::op::v0::Parameter>(precision, inputShape);
auto fakeQuantize = makeFakeQuantize(input, precision, fqOnData);
auto results = ngraph::ResultVector{};
auto results = ov::ResultVector{};
if (dequantization1.empty() && dequantization2.empty()) {
results.push_back(std::make_shared<ngraph::opset1::Result>(fakeQuantize));
results.push_back(std::make_shared<ov::opset1::Result>(fakeQuantize));
} else {
if (!dequantization1.empty()) {
const auto deq = makeDequantization(fakeQuantize, dequantization1);
results.push_back(std::make_shared<ngraph::opset1::Result>(deq));
results.push_back(std::make_shared<ov::opset1::Result>(deq));
}
if (!dequantization2.empty()) {
const auto deq = makeDequantization(fakeQuantize, dequantization2);
results.push_back(std::make_shared<ngraph::opset1::Result>(deq));
results.push_back(std::make_shared<ov::opset1::Result>(deq));
}
}
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "ComposeFakeQuantizeFunction");
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "ComposeFakeQuantizeFunction");
}
} // namespace subgraph

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
#include "ov_lpt_models/convolution.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include <ov_ops/type_relaxed.hpp>
#include "ov_models/subgraph_builders.hpp"
#include "low_precision/network_helper.hpp"
@ -22,12 +22,12 @@ namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<ngraph::Function> ConvolutionFunction::getOriginal(
const ngraph::element::Type netPrecision,
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> ConvolutionFunction::getOriginal(
const ov::element::Type netPrecision,
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationOnActivations,
std::shared_ptr<ngraph::opset1::Constant> weights,
std::shared_ptr<ov::opset1::Constant> weights,
const ngraph::builder::subgraph::FakeQuantizeOnWeights fqOnWeights,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationOnWeights,
const bool transposeOnData,
@ -35,7 +35,7 @@ std::shared_ptr<ngraph::Function> ConvolutionFunction::getOriginal(
const bool transposeOnInputHigh,
const bool transposeOnOutputLow,
const bool transposeOnOutputHigh) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(inputPrecision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(inputPrecision, inputShape);
auto dequantizationStructure = dequantizationOnActivations;
dequantizationStructure.multiply.outPrecision = netPrecision;
const auto dequantization = makeDequantization(input, dequantizationStructure);
@ -50,14 +50,14 @@ std::shared_ptr<ngraph::Function> ConvolutionFunction::getOriginal(
}
if (weights->cast_vector<float>().size() == 1ul) {
auto targetShape = ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 };
weights = ov::as_type_ptr<ngraph::opset1::Constant>(fold<ngraph::opset1::Broadcast>(
weights, op::Constant::create(ngraph::element::i64, Shape{ targetShape.size() }, targetShape)));
auto targetShape = ov::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 };
weights = ov::as_type_ptr<ov::opset1::Constant>(fold<ov::opset1::Broadcast>(
weights, op::Constant::create(ov::element::i64, Shape{ targetShape.size() }, targetShape)));
}
std::shared_ptr<Node> convertedWeights;
if (dequantizationOnWeights.empty()) {
const auto convertOnWeights = std::make_shared<opset1::Convert>(weights, netPrecision);
const auto convertOnWeights = std::make_shared<ov::opset1::Convert>(weights, netPrecision);
OutputVector convertedOutput(1);
convertOnWeights->constant_fold(convertedOutput, convertOnWeights->input_values());
convertedWeights = convertedOutput[0].get_node_shared_ptr();
@ -65,44 +65,44 @@ std::shared_ptr<ngraph::Function> ConvolutionFunction::getOriginal(
convertedWeights = weights;
}
const std::shared_ptr<ngraph::Node> constant = ngraph::opset1::Constant::create(ngraph::element::u64, ngraph::Shape{4}, {0, 1, 2, 3});
const std::shared_ptr<ov::Node> constant = ov::opset1::Constant::create(ov::element::u64, ov::Shape{4}, {0, 1, 2, 3});
std::shared_ptr<Node> onWeights;
if (fqOnWeights.empty()) {
onWeights = dequantizationOnWeights.empty() ? convertedWeights : makeDequantization(convertedWeights, dequantizationOnWeights);
} else {
onWeights = std::make_shared<opset1::FakeQuantize>(
transposeOnData ? std::make_shared<opset1::Transpose>(convertedWeights, constant) : convertedWeights,
onWeights = std::make_shared<ov::opset1::FakeQuantize>(
transposeOnData ? std::make_shared<ov::opset1::Transpose>(convertedWeights, constant) : convertedWeights,
transposeOnInputLow ?
std::make_shared<opset1::Transpose>(
std::make_shared<ov::opset1::Transpose>(
makeConstant(netPrecision, fqOnWeights.constantShape, fqOnWeights.inputLowValues, fqOnWeights.inputLowValues.empty()),
constant->clone_with_new_inputs({})) :
makeConstant(netPrecision, fqOnWeights.constantShape, fqOnWeights.inputLowValues, fqOnWeights.inputLowValues.empty()),
transposeOnInputHigh ?
std::make_shared<opset1::Transpose>(
std::make_shared<ov::opset1::Transpose>(
makeConstant(netPrecision, fqOnWeights.constantShape, fqOnWeights.inputHighValues, fqOnWeights.inputHighValues.empty()),
constant->clone_with_new_inputs({})) :
makeConstant(netPrecision, fqOnWeights.constantShape, fqOnWeights.inputHighValues, fqOnWeights.inputHighValues.empty()),
transposeOnOutputLow ?
std::make_shared<opset1::Transpose>(
std::make_shared<ov::opset1::Transpose>(
makeConstant(netPrecision, fqOnWeights.constantShape, fqOnWeights.outputLowValues, fqOnWeights.outputLowValues.empty()),
constant->clone_with_new_inputs({})) :
makeConstant(netPrecision, fqOnWeights.constantShape, fqOnWeights.outputLowValues, fqOnWeights.outputLowValues.empty()),
transposeOnOutputHigh ?
std::make_shared<opset1::Transpose>(
std::make_shared<ov::opset1::Transpose>(
makeConstant(netPrecision, fqOnWeights.constantShape, fqOnWeights.outputHighValues, fqOnWeights.outputHighValues.empty()),
constant->clone_with_new_inputs({})) :
makeConstant(netPrecision, fqOnWeights.constantShape, fqOnWeights.outputHighValues, fqOnWeights.outputHighValues.empty()),
fqOnWeights.quantizationLevel);
}
auto convolutionOriginal = ngraph::opset1::Convolution(
auto convolutionOriginal = ov::opset1::Convolution(
ov::op::TemporaryReplaceOutputType(dequantization, netPrecision).get(),
ov::op::TemporaryReplaceOutputType(onWeights, netPrecision).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
std::shared_ptr<ngraph::opset1::Convolution> convolution = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Convolution>>(
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
std::shared_ptr<ov::opset1::Convolution> convolution = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Convolution>>(
convolutionOriginal,
std::vector<element::Type>{ netPrecision, netPrecision },
std::vector<element::Type>{ netPrecision });
@ -110,55 +110,55 @@ std::shared_ptr<ngraph::Function> ConvolutionFunction::getOriginal(
auto& rtInfo = convolution->get_rt_info();
rtInfo["Variant::std::string"] = "convolution";
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(convolution) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "ConvolutionTransformation");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(convolution) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "ConvolutionTransformation");
}
std::shared_ptr<ngraph::Function> ConvolutionFunction::getOriginalWithIncorrectWeights(
const ngraph::Shape& inputShape,
ngraph::element::Type precision,
std::shared_ptr<ov::Model> ConvolutionFunction::getOriginalWithIncorrectWeights(
const ov::Shape& inputShape,
ov::element::Type precision,
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights,
ngraph::builder::subgraph::DequantizationOperations dequantization,
bool isCorrect) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, ngraph::Shape(inputShape));
const auto input = std::make_shared<ov::opset1::Parameter>(precision, ov::Shape(inputShape));
const auto deq = makeDequantization(input, dequantization);
const size_t inputChannelsCount = inputShape[1];
const size_t outputChannelsCount = 2 * inputShape[1];
const auto weights = ngraph::opset1::Constant::create(
ngraph::element::f32,
ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
const auto weights = ov::opset1::Constant::create(
ov::element::f32,
ov::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
std::vector<float>(outputChannelsCount * inputChannelsCount, 1));
const auto fqOnWeights = fakeQuantizeOnWeights.empty() ?
nullptr :
ngraph::builder::makeFakeQuantize(
weights, ngraph::element::f32, fakeQuantizeOnWeights.quantizationLevel, fakeQuantizeOnWeights.constantShape,
weights, ov::element::f32, fakeQuantizeOnWeights.quantizationLevel, fakeQuantizeOnWeights.constantShape,
fakeQuantizeOnWeights.inputLowValues, fakeQuantizeOnWeights.inputHighValues,
fakeQuantizeOnWeights.outputLowValues, fakeQuantizeOnWeights.outputHighValues);
const auto subtract = isCorrect ? nullptr : std::make_shared<opset1::Subtract>(fqOnWeights,
std::make_shared<ngraph::opset1::Constant>(ngraph::element::f32, Shape{1, 1, 1, 1}, 3.0f));
const auto subtract = isCorrect ? nullptr : std::make_shared<ov::opset1::Subtract>(fqOnWeights,
std::make_shared<ov::opset1::Constant>(ov::element::f32, Shape{1, 1, 1, 1}, 3.0f));
const auto convolution = std::make_shared<ngraph::opset1::Convolution>(
const auto convolution = std::make_shared<ov::opset1::Convolution>(
deq,
isCorrect ? fqOnWeights : subtract,
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(convolution) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "IncorrectWeightsAndConvolutionFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(convolution) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "IncorrectWeightsAndConvolutionFunction");
}
std::shared_ptr<ngraph::Function> ConvolutionFunction::getOriginalWithIncorrectWeights(
const ngraph::PartialShape& inputShape,
ngraph::element::Type precision,
std::shared_ptr<ov::Model> ConvolutionFunction::getOriginalWithIncorrectWeights(
const ov::PartialShape& inputShape,
ov::element::Type precision,
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights,
ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData,
bool isCorrect) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
const auto fqOnData = fakeQuantizeOnData.empty() ?
nullptr :
ngraph::builder::makeFakeQuantize(
@ -167,9 +167,9 @@ std::shared_ptr<ngraph::Function> ConvolutionFunction::getOriginalWithIncorrectW
const size_t inputChannelsCount = inputShape[1].get_length();
const size_t outputChannelsCount = 2 * inputShape[1].get_length();
const auto weights = ngraph::opset1::Constant::create(
const auto weights = ov::opset1::Constant::create(
precision,
ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
ov::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
std::vector<float>(outputChannelsCount * inputChannelsCount, 1));
const auto fqOnWeights = fakeQuantizeOnWeights.empty() ?
@ -179,29 +179,29 @@ std::shared_ptr<ngraph::Function> ConvolutionFunction::getOriginalWithIncorrectW
fakeQuantizeOnWeights.inputLowValues, fakeQuantizeOnWeights.inputHighValues,
fakeQuantizeOnWeights.outputLowValues, fakeQuantizeOnWeights.outputHighValues);
const auto subtract = isCorrect ? nullptr : std::make_shared<opset1::Subtract>(fqOnWeights,
std::make_shared<ngraph::opset1::Constant>(precision, Shape{ 1, 1, 1, 1 }, 3.0f));
const auto subtract = isCorrect ? nullptr : std::make_shared<ov::opset1::Subtract>(fqOnWeights,
std::make_shared<ov::opset1::Constant>(precision, Shape{ 1, 1, 1, 1 }, 3.0f));
const auto convolution = std::make_shared<ngraph::opset1::Convolution>(
const auto convolution = std::make_shared<ov::opset1::Convolution>(
fakeQuantizeOnData.empty() ? input : fqOnData,
isCorrect ? fqOnWeights : subtract,
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(convolution) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "IncorrectWeightsAndConvolutionFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(convolution) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "IncorrectWeightsAndConvolutionFunction");
}
std::shared_ptr<ngraph::Function> ConvolutionFunction::getReferenceWithIncorrectWeights(
const ngraph::Shape& inputShape,
ngraph::element::Type inputPrecision,
std::shared_ptr<ov::Model> ConvolutionFunction::getReferenceWithIncorrectWeights(
const ov::Shape& inputShape,
ov::element::Type inputPrecision,
ngraph::builder::subgraph::DequantizationOperations dequantizationBefore,
ngraph::element::Type weightsPrecision,
ov::element::Type weightsPrecision,
std::vector<float> weightsValues,
ngraph::builder::subgraph::DequantizationOperations dequantizationAfter) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(inputPrecision, ngraph::Shape(inputShape));
const auto input = std::make_shared<ov::opset1::Parameter>(inputPrecision, ov::Shape(inputShape));
input->set_friendly_name("input");
const auto deqBefore = makeDequantization(input, dequantizationBefore);
@ -213,43 +213,43 @@ std::shared_ptr<ngraph::Function> ConvolutionFunction::getReferenceWithIncorrect
throw std::runtime_error("unexpected actual weights values size");
}
const std::shared_ptr<ngraph::Node> weights = ngraph::opset1::Constant::create(
const std::shared_ptr<ov::Node> weights = ov::opset1::Constant::create(
weightsPrecision,
ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
ov::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
weightsValues.size() == 1ul ?
std::vector<float>(outputChannelsCount * inputChannelsCount, weightsValues[0]) :
weightsValues);
auto convolutionOriginal = ngraph::opset1::Convolution(
auto convolutionOriginal = ov::opset1::Convolution(
ov::op::TemporaryReplaceOutputType(deqBefore, element::f32).get(),
ov::op::TemporaryReplaceOutputType(weights, element::f32).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
std::shared_ptr<ngraph::opset1::Convolution> convolution = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Convolution>>(
std::shared_ptr<ov::opset1::Convolution> convolution = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Convolution>>(
convolutionOriginal,
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{});
const auto deqAfter = makeDequantization(convolution, dequantizationAfter);
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(deqAfter) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "IncorrectWeightsAndConvolutionFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(deqAfter) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "IncorrectWeightsAndConvolutionFunction");
}
std::shared_ptr<ngraph::Function> ConvolutionFunction::getReference(
const ngraph::element::Type netPrecision,
const ngraph::element::Type inputPrecision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> ConvolutionFunction::getReference(
const ov::element::Type netPrecision,
const ov::element::Type inputPrecision,
const ov::PartialShape& inputShape,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
std::shared_ptr<ngraph::opset1::Constant> weights,
std::shared_ptr<ov::opset1::Constant> weights,
const ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter,
const ngraph::element::Type precisionAfterDequantization) {
auto input = std::make_shared<ngraph::opset1::Parameter>(inputPrecision, inputShape);
const ov::element::Type precisionAfterDequantization) {
auto input = std::make_shared<ov::opset1::Parameter>(inputPrecision, inputShape);
auto dequantizationBeforeStructure = dequantizationBefore;
dequantizationBeforeStructure.multiply.outPrecision = netPrecision;
const auto deqBefore = makeDequantization(input, dequantizationBeforeStructure);
@ -264,20 +264,20 @@ std::shared_ptr<ngraph::Function> ConvolutionFunction::getReference(
}
if (weights->cast_vector<float>().size() == 1ul) {
auto targetShape = ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 };
weights = ov::as_type_ptr<ngraph::opset1::Constant>(fold<ngraph::opset1::Broadcast>(
weights, op::Constant::create(ngraph::element::i64, Shape{ targetShape.size() }, targetShape)));
auto targetShape = ov::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 };
weights = ov::as_type_ptr<ov::opset1::Constant>(fold<ov::opset1::Broadcast>(
weights, op::Constant::create(ov::element::i64, Shape{ targetShape.size() }, targetShape)));
}
const auto convertOnWeights = std::make_shared<opset1::Convert>(weights, netPrecision);
const auto convertOnWeights = std::make_shared<ov::opset1::Convert>(weights, netPrecision);
OutputVector convertedOutput(1);
convertOnWeights->constant_fold(convertedOutput, convertOnWeights->input_values());
const auto convertedWeights = convertedOutput[0].get_node_shared_ptr();
std::shared_ptr<ngraph::Node> onWeights = fakeQuantizeOnWeights.empty() ?
std::shared_ptr<ov::Node> onWeights = fakeQuantizeOnWeights.empty() ?
(weights->get_output_element_type(0).is_real() ?
convertedWeights :
std::dynamic_pointer_cast<ngraph::Node>(weights)) :
std::dynamic_pointer_cast<ov::Node>(weights)) :
ngraph::builder::makeFakeQuantize(
convertedWeights->output(0),
netPrecision,
@ -288,15 +288,15 @@ std::shared_ptr<ngraph::Function> ConvolutionFunction::getReference(
fakeQuantizeOnWeights.outputLowValues,
fakeQuantizeOnWeights.outputHighValues);
auto convolutionOriginal = ngraph::opset1::Convolution(
auto convolutionOriginal = ov::opset1::Convolution(
ov::op::TemporaryReplaceOutputType(deqBefore, netPrecision).get(),
ov::op::TemporaryReplaceOutputType(onWeights, netPrecision).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
std::shared_ptr<ngraph::opset1::Convolution> convolution = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Convolution>>(
std::shared_ptr<ov::opset1::Convolution> convolution = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Convolution>>(
convolutionOriginal,
std::vector<element::Type>{ netPrecision, netPrecision },
std::vector<element::Type>{ netPrecision });
@ -313,21 +313,21 @@ std::shared_ptr<ngraph::Function> ConvolutionFunction::getReference(
const auto deqAfter = makeDequantization(convolution, dequantizationStructure);
deqAfter->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(deqAfter) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "ConvolutionTransformation");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(deqAfter) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "ConvolutionTransformation");
}
std::shared_ptr<ngraph::Function> ConvolutionFunction::get(
const ngraph::Shape& inputShape,
const ngraph::element::Type precision,
std::shared_ptr<ov::Model> ConvolutionFunction::get(
const ov::Shape& inputShape,
const ov::element::Type precision,
const ngraph::builder::subgraph::FakeQuantizeOnData& fakeQuantizeOnData,
const std::vector<float>& weightsValues,
const ngraph::builder::subgraph::FakeQuantizeOnWeights& fakeQuantizeOnWeights,
const std::vector<ov::pass::low_precision::QuantizationGranularityRestriction>& restrictions) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, ngraph::Shape(inputShape));
const auto input = std::make_shared<ov::opset1::Parameter>(precision, ov::Shape(inputShape));
input->set_friendly_name("input");
const std::shared_ptr<ngraph::opset1::FakeQuantize> fqOnData = ov::as_type_ptr<ngraph::opset1::FakeQuantize>(ngraph::builder::makeFakeQuantize(
const std::shared_ptr<ov::opset1::FakeQuantize> fqOnData = ov::as_type_ptr<ov::opset1::FakeQuantize>(ngraph::builder::makeFakeQuantize(
input,
precision,
fakeQuantizeOnData.quantizationLevel,
@ -343,31 +343,31 @@ std::shared_ptr<ngraph::Function> ConvolutionFunction::get(
throw std::runtime_error("unexpected actual weights values size");
}
const std::shared_ptr<ngraph::Node> parentOnData = fakeQuantizeOnData.empty() ? std::dynamic_pointer_cast<ngraph::Node>(input) : fqOnData;
const std::shared_ptr<ov::Node> parentOnData = fakeQuantizeOnData.empty() ? std::dynamic_pointer_cast<ov::Node>(input) : fqOnData;
const std::shared_ptr<ngraph::Node> weights = ngraph::opset1::Constant::create(
const std::shared_ptr<ov::Node> weights = ov::opset1::Constant::create(
precision,
ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
ov::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
weightsValues.size() == 1ul ?
std::vector<float>(outputChannelsCount * inputChannelsCount, weightsValues[0]) :
weightsValues);
const std::shared_ptr<ngraph::Node> parentOnWeights = fakeQuantizeOnWeights.empty() ?
const std::shared_ptr<ov::Node> parentOnWeights = fakeQuantizeOnWeights.empty() ?
weights :
ngraph::builder::makeFakeQuantize(
weights, precision, fakeQuantizeOnWeights.quantizationLevel, fakeQuantizeOnWeights.constantShape,
fakeQuantizeOnWeights.inputLowValues, fakeQuantizeOnWeights.inputHighValues,
fakeQuantizeOnWeights.outputLowValues, fakeQuantizeOnWeights.outputHighValues);
auto convolutionOriginal = ngraph::opset1::Convolution(
auto convolutionOriginal = ov::opset1::Convolution(
ov::op::TemporaryReplaceOutputType(parentOnData, element::f32).get(),
ov::op::TemporaryReplaceOutputType(parentOnWeights, element::f32).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
const std::shared_ptr<ngraph::opset1::Convolution> convolution = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Convolution>>(
const std::shared_ptr<ov::opset1::Convolution> convolution = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Convolution>>(
convolutionOriginal,
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{});
@ -380,8 +380,8 @@ std::shared_ptr<ngraph::Function> ConvolutionFunction::get(
}
}
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(convolution) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "ConvolutionFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(convolution) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "ConvolutionFunction");
}
} // namespace subgraph

View File

@ -4,7 +4,7 @@
#include "ov_lpt_models/convolution_backprop_data.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include <ov_ops/type_relaxed.hpp>
#include "ov_models/subgraph_builders.hpp"
#include "low_precision/network_helper.hpp"
@ -21,16 +21,16 @@ namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<Function> ConvolutionBackpropDataFunction::get(
std::shared_ptr<ov::Model> ConvolutionBackpropDataFunction::get(
const element::Type netPrecision,
const PartialShape& inputShape,
const Shape& outputShape,
const builder::subgraph::FakeQuantizeOnData& fqOnData,
const std::shared_ptr<Node>& weights) {
const auto input = std::make_shared<opset1::Parameter>(netPrecision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(netPrecision, inputShape);
const auto fq = makeFakeQuantize(input, netPrecision, fqOnData);
auto convolutionBackpropData = std::make_shared<opset1::ConvolutionBackpropData>(
auto convolutionBackpropData = std::make_shared<ov::opset1::ConvolutionBackpropData>(
fq,
weights,
Strides{ 1, 1 },
@ -39,22 +39,22 @@ std::shared_ptr<Function> ConvolutionBackpropDataFunction::get(
Strides{ 1, 1 });
convolutionBackpropData->set_friendly_name("convolutionBackpropData");
ngraph::ResultVector results{ std::make_shared<opset1::Result>(convolutionBackpropData) };
return std::make_shared<ngraph::Function>(results, ParameterVector{ input }, "ConvolutionBackpropDataTransformation");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(convolutionBackpropData) };
return std::make_shared<ov::Model>(results, ParameterVector{ input }, "ConvolutionBackpropDataTransformation");
}
std::shared_ptr<Node> ConvolutionBackpropDataFunction::getWeights(
const Shape& shape,
const element::Type& netPrecision,
const builder::subgraph::FakeQuantizeOnWeights& fqOnWeights,
const std::shared_ptr<opset1::Constant>& value) {
const std::shared_ptr<ov::opset1::Constant>& value) {
const auto weights = value != nullptr ?
value :
std::make_shared<opset1::Constant>(
std::make_shared<ov::opset1::Constant>(
element::i8,
shape,
std::vector<float>(shape_size(shape), 1));
const auto convert = std::make_shared<opset1::Convert>(weights, netPrecision);
const auto convert = std::make_shared<ov::opset1::Convert>(weights, netPrecision);
OutputVector convertedOutput(1);
convert->constant_fold(convertedOutput, convert->input_values());
const auto convertedWeights = convertedOutput[0].get_node_shared_ptr();
@ -67,11 +67,11 @@ std::shared_ptr<Node> ConvolutionBackpropDataFunction::getWeights(
const Shape& shape,
const element::Type& netPrecision,
const builder::subgraph::DequantizationOperations& dequantizationOnWeights,
const std::shared_ptr<opset1::Constant>& value) {
const std::shared_ptr<ov::opset1::Constant>& value) {
auto weights =
value != nullptr ?
value :
std::make_shared<opset1::Constant>(
std::make_shared<ov::opset1::Constant>(
element::i8,
shape,
std::vector<float>(shape_size(shape), 1));
@ -81,7 +81,7 @@ std::shared_ptr<Node> ConvolutionBackpropDataFunction::getWeights(
dequantizationStructure.subtract.constantPrecision = dequantizationOnWeights.subtract.constantPrecision;
}
if (weights->get_element_type().is_real()) {
weights = ov::as_type_ptr<opset1::Constant>(fold<opset1::Convert>(weights, netPrecision));
weights = ov::as_type_ptr<ov::opset1::Constant>(fold<ov::opset1::Convert>(weights, netPrecision));
}
const auto dq = makeDequantization(weights, dequantizationStructure);
@ -93,12 +93,12 @@ std::shared_ptr<Node> ConvolutionBackpropDataFunction::getWeights(
const element::Type& netPrecision,
const builder::subgraph::FakeQuantizeOnWeights& fqOnWeights,
const builder::subgraph::DequantizationOperations& dequantizationOnWeights,
const std::shared_ptr<opset1::Constant>& value) {
const std::shared_ptr<ov::opset1::Constant>& value) {
const auto weights =
value != nullptr
? value
: std::make_shared<opset1::Constant>(element::i8, shape, std::vector<float>(shape_size(shape), 1));
const auto convert = std::make_shared<opset1::Convert>(weights, netPrecision);
: std::make_shared<ov::opset1::Constant>(element::i8, shape, std::vector<float>(shape_size(shape), 1));
const auto convert = std::make_shared<ov::opset1::Convert>(weights, netPrecision);
OutputVector convertedOutput(1);
convert->constant_fold(convertedOutput, convert->input_values());
const auto convertedWeights = convertedOutput[0].get_node_shared_ptr();
@ -109,19 +109,19 @@ std::shared_ptr<Node> ConvolutionBackpropDataFunction::getWeights(
return makeDequantization(fq, dequantizationStructure);
}
std::shared_ptr<Function> ConvolutionBackpropDataFunction::getOriginal(
std::shared_ptr<ov::Model> ConvolutionBackpropDataFunction::getOriginal(
const element::Type precision,
const element::Type netPrecision,
const PartialShape& inputShape,
const Shape& outputShape,
const builder::subgraph::DequantizationOperations& dequantization,
const std::shared_ptr<Node>& weights) {
const auto input = std::make_shared<opset1::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
auto dequantizationStructure = dequantization;
dequantizationStructure.multiply.outPrecision = netPrecision;
const auto activations = makeDequantization(input, dequantizationStructure);
auto convolutionBackpropData = std::make_shared<opset1::ConvolutionBackpropData>(
auto convolutionBackpropData = std::make_shared<ov::opset1::ConvolutionBackpropData>(
activations,
weights,
Strides{ 1, 1 },
@ -130,11 +130,11 @@ std::shared_ptr<Function> ConvolutionBackpropDataFunction::getOriginal(
Strides{ 1, 1 });
convolutionBackpropData->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<opset1::Result>(convolutionBackpropData) };
return std::make_shared<ngraph::Function>(results, ParameterVector{ input }, "ConvolutionBackpropDataTransformation");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(convolutionBackpropData) };
return std::make_shared<ov::Model>(results, ParameterVector{ input }, "ConvolutionBackpropDataTransformation");
}
std::shared_ptr<Function> ConvolutionBackpropDataFunction::getReference(
std::shared_ptr<ov::Model> ConvolutionBackpropDataFunction::getReference(
const element::Type precision,
const element::Type netPrecision,
const PartialShape& inputShape,
@ -142,12 +142,12 @@ std::shared_ptr<Function> ConvolutionBackpropDataFunction::getReference(
const builder::subgraph::DequantizationOperations& dequantization,
const std::shared_ptr<Node>& weights,
const builder::subgraph::DequantizationOperations& dequantizationAfter) {
const auto input = std::make_shared<opset1::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
auto dequantizationStructure = dequantization;
dequantizationStructure.multiply.outPrecision = netPrecision;
const auto activations = makeDequantization(input, dequantizationStructure);
auto convolutionBackpropData = std::make_shared<ov::op::TypeRelaxed<opset1::ConvolutionBackpropData>>(
auto convolutionBackpropData = std::make_shared<ov::op::TypeRelaxed<ov::opset1::ConvolutionBackpropData>>(
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{ dequantizationAfter.empty() ? netPrecision : element::f32 },
ov::op::TemporaryReplaceOutputType(activations, element::f32).get(),
@ -161,8 +161,8 @@ std::shared_ptr<Function> ConvolutionBackpropDataFunction::getReference(
dequantizationStructureAfter.multiply.outPrecision = netPrecision;
const auto result = makeDequantization(convolutionBackpropData, dequantizationStructureAfter);
result->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<opset1::Result>(result) };
return std::make_shared<ngraph::Function>(results, ParameterVector{ input }, "ConvolutionBackpropDataTransformation");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(result) };
return std::make_shared<ov::Model>(results, ParameterVector{ input }, "ConvolutionBackpropDataTransformation");
}
} // namespace subgraph

View File

@ -11,68 +11,68 @@ namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<ngraph::Function> DepthToSpaceFunction::getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
const ngraph::opset1::DepthToSpace::DepthToSpaceMode mode,
std::shared_ptr<ov::Model> DepthToSpaceFunction::getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ov::opset1::DepthToSpace::DepthToSpaceMode mode,
const size_t blockSize) {
const float low = 0.f;
const float high = 255.f;
const float inputScale = 10.f;
const float outputScale = 20.f;
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
const auto fakeQuantize = ngraph::builder::makeFakeQuantize(
input, precision, 256, { 1, 1, 1, 1 },
{ low / inputScale }, { high / inputScale }, { low / outputScale }, { high / outputScale });
auto d2s = std::make_shared<ngraph::opset1::DepthToSpace>(fakeQuantize, mode, blockSize);
auto d2s = std::make_shared<ov::opset1::DepthToSpace>(fakeQuantize, mode, blockSize);
d2s->set_friendly_name("output");
ngraph::ResultVector results = { std::make_shared<ngraph::opset1::Result>(d2s) };
ov::ResultVector results = { std::make_shared<ov::opset1::Result>(d2s) };
const auto function = std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "DepthToSpaceTransformation");
const auto function = std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "DepthToSpaceTransformation");
return function;
}
std::shared_ptr<ngraph::Function> DepthToSpaceFunction::getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::opset1::DepthToSpace::DepthToSpaceMode mode,
std::shared_ptr<ov::Model> DepthToSpaceFunction::getOriginal(
const ov::PartialShape& inputShape,
const ov::opset1::DepthToSpace::DepthToSpaceMode mode,
const size_t blockSize,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantization) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precisionBeforeDequantization, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precisionBeforeDequantization, inputShape);
const auto dequantizationOp = makeDequantization(input, dequantization);
auto d2s = std::make_shared<ngraph::opset1::DepthToSpace>(dequantizationOp, mode, blockSize);
auto d2s = std::make_shared<ov::opset1::DepthToSpace>(dequantizationOp, mode, blockSize);
d2s->set_friendly_name("output");
ngraph::ResultVector results = { std::make_shared<ngraph::opset1::Result>(d2s) };
ov::ResultVector results = { std::make_shared<ov::opset1::Result>(d2s) };
const auto function = std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "DepthToSpaceTransformation");
const auto function = std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "DepthToSpaceTransformation");
return function;
}
std::shared_ptr<ngraph::Function> DepthToSpaceFunction::getReference(
const ngraph::PartialShape& inputShape,
const ngraph::opset1::DepthToSpace::DepthToSpaceMode mode,
std::shared_ptr<ov::Model> DepthToSpaceFunction::getReference(
const ov::PartialShape& inputShape,
const ov::opset1::DepthToSpace::DepthToSpaceMode mode,
const size_t blockSize,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOperation,
const ov::element::Type precisionAfterOperation,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precisionBeforeDequantization, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precisionBeforeDequantization, inputShape);
const std::shared_ptr<Node> dequantizationOpBefore = makeDequantization(input, dequantizationBefore);
auto d2s = std::make_shared<ngraph::opset1::DepthToSpace>(dequantizationOpBefore, mode, blockSize);
auto d2s = std::make_shared<ov::opset1::DepthToSpace>(dequantizationOpBefore, mode, blockSize);
const std::shared_ptr<Node> dequantizationOpAfter = makeDequantization(d2s, dequantizationAfter);
dequantizationOpAfter->set_friendly_name("output");
ngraph::ResultVector results = { std::make_shared<ngraph::opset1::Result>(dequantizationOpAfter) };
ov::ResultVector results = { std::make_shared<ov::opset1::Result>(dequantizationOpAfter) };
ov::pass::low_precision::NetworkHelper::setOutDataPrecision(d2s, precisionAfterOperation);
const auto function = std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "DepthToSpaceTransformation");
const auto function = std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "DepthToSpaceTransformation");
return function;
}

View File

@ -5,7 +5,7 @@
#include "ov_lpt_models/elementwise.hpp"
#include "low_precision/layer_transformation.hpp"
#include "ngraph/opsets/opset1.hpp"
#include "openvino/opsets/opset1.hpp"
#include "ov_lpt_models/common/dequantization_operations.hpp"
using namespace ov::pass::low_precision;
@ -16,9 +16,9 @@ namespace subgraph {
namespace {
std::shared_ptr<ngraph::opset1::FakeQuantize> makeFakeQuantizeWithNames(
std::shared_ptr<ov::opset1::FakeQuantize> makeFakeQuantizeWithNames(
const Output<Node>& parent,
const ngraph::element::Type precision,
const ov::element::Type precision,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData,
const std::string name) {
auto fq = ngraph::builder::subgraph::makeFakeQuantize(parent, precision, fqOnData);
@ -32,9 +32,9 @@ std::shared_ptr<ngraph::opset1::FakeQuantize> makeFakeQuantizeWithNames(
} // namespace
std::shared_ptr<ngraph::Function> ElementwiseFunction::getOriginalSubgraphWithConvolutions(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> ElementwiseFunction::getOriginalSubgraphWithConvolutions(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const bool broadcast,
const std::string& elementWiseType,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnDataBefore1,
@ -44,7 +44,7 @@ std::shared_ptr<ngraph::Function> ElementwiseFunction::getOriginalSubgraphWithCo
const ngraph::builder::subgraph::Convolution& convolution2,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnDataAfter2,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnDataAfter) {
ngraph::PartialShape inputShape2 = inputShape;
ov::PartialShape inputShape2 = inputShape;
if (broadcast) {
inputShape2[2] = 1;
@ -52,16 +52,16 @@ std::shared_ptr<ngraph::Function> ElementwiseFunction::getOriginalSubgraphWithCo
}
auto makeBranch = [&](
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const size_t index,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnDataBefore,
const ngraph::builder::subgraph::Convolution& convolution,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnDataAfter) ->
std::pair<std::shared_ptr<ngraph::opset1::Parameter>, std::shared_ptr<ngraph::Node>> {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
std::pair<std::shared_ptr<ov::opset1::Parameter>, std::shared_ptr<ov::Node>> {
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
input->set_friendly_name("input" + std::to_string(index));
std::shared_ptr<ngraph::Node> parent = input;
std::shared_ptr<ov::Node> parent = input;
if (!fqOnDataBefore.empty()) {
parent = makeFakeQuantizeWithNames(parent, precision, fqOnDataBefore, "fakeQuantizeBefore" + std::to_string(index));
@ -82,12 +82,12 @@ std::shared_ptr<ngraph::Function> ElementwiseFunction::getOriginalSubgraphWithCo
const auto branch1 = makeBranch(precision, inputShape, 1, fqOnDataBefore1, convolution1, fqOnDataAfter1);
const auto branch2 = makeBranch(precision, inputShape, 2, fqOnDataBefore2, convolution2, fqOnDataAfter2);
std::shared_ptr<ngraph::Node> result;
std::shared_ptr<ov::Node> result;
if (elementWiseType == "add") {
result = std::make_shared<ngraph::opset1::Add>(branch1.second, branch2.second);
result = std::make_shared<ov::opset1::Add>(branch1.second, branch2.second);
result->set_friendly_name("add");
} else if (elementWiseType == "multiply") {
result = std::make_shared<ngraph::opset1::Multiply>(branch1.second, branch2.second);
result = std::make_shared<ov::opset1::Multiply>(branch1.second, branch2.second);
result->set_friendly_name("multiply");
} else {
THROW_TRANSFORMATION_EXCEPTION << "not supported element-wise operation type " << elementWiseType;
@ -97,7 +97,7 @@ std::shared_ptr<ngraph::Function> ElementwiseFunction::getOriginalSubgraphWithCo
result = makeFakeQuantizeWithNames(result, precision, fqOnDataAfter, "fakeQuantizeAfter");
// we need a some operation to move dequantization operations away from FakeQuantize to avoid cleanup fuse
result = std::make_shared<ngraph::opset1::MaxPool>(
result = std::make_shared<ov::opset1::MaxPool>(
result,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -107,11 +107,11 @@ std::shared_ptr<ngraph::Function> ElementwiseFunction::getOriginalSubgraphWithCo
result->set_friendly_name("maxPool");
}
result = std::make_shared<ngraph::opset1::Result>(result);
result = std::make_shared<ov::opset1::Result>(result);
result->set_friendly_name("result");
ngraph::ResultVector results{ std::dynamic_pointer_cast<ngraph::opset1::Result>(result) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ branch1.first, branch2.first }, "AddTransformation");
ov::ResultVector results{ std::dynamic_pointer_cast<ov::opset1::Result>(result) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ branch1.first, branch2.first }, "AddTransformation");
}
} // namespace subgraph

View File

@ -5,7 +5,7 @@
#include "ov_lpt_models/elementwise_with_multi_parent_dequantization.hpp"
#include "low_precision/network_helper.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include "ov_models/builders.hpp"
#include "ov_models/subgraph_builders.hpp"
@ -15,44 +15,44 @@ namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<ngraph::Function> ElementwiseWithMultiParentDequantizationFunction::get(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
std::shared_ptr<ov::Model> ElementwiseWithMultiParentDequantizationFunction::get(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ov::pass::low_precision::LayerTransformation::Params& params,
const ngraph::element::Type& precision1,
const ov::element::Type& precision1,
const ngraph::builder::subgraph::DequantizationOperations& dequantization1,
const ngraph::element::Type& precision2,
const ov::element::Type& precision2,
const ngraph::builder::subgraph::DequantizationOperations& dequantization2) {
const auto input1_1 = std::make_shared<ngraph::opset1::Parameter>(precision1, inputShape);
const auto input1_2 = std::make_shared<ngraph::opset1::Parameter>(precision1, ngraph::Shape({ inputShape[0], inputShape[1], 1, 1 }));
const std::shared_ptr<ngraph::Node> multiply1 = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Multiply>>(
opset1::Multiply(
const auto input1_1 = std::make_shared<ov::opset1::Parameter>(precision1, inputShape);
const auto input1_2 = std::make_shared<ov::opset1::Parameter>(precision1, ov::Shape({ inputShape[0], inputShape[1], 1, 1 }));
const std::shared_ptr<ov::Node> multiply1 = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Multiply>>(
ov::opset1::Multiply(
ov::op::TemporaryReplaceOutputType(input1_1, element::f32).get(),
ov::op::TemporaryReplaceOutputType(input1_2, element::f32).get()),
std::vector<element::Type>{element::f32, element::f32},
std::vector<element::Type>{});
const std::shared_ptr<ngraph::Node> parent1 = dequantization1.empty() ? multiply1 : makeDequantization(multiply1, dequantization1);
const std::shared_ptr<ov::Node> parent1 = dequantization1.empty() ? multiply1 : makeDequantization(multiply1, dequantization1);
const auto input2_1 = std::make_shared<ngraph::opset1::Parameter>(precision1, inputShape);
const auto input2_2 = std::make_shared<ngraph::opset1::Parameter>(precision1, ngraph::Shape({ inputShape[0], inputShape[1], 1, 1 }));
const std::shared_ptr<ngraph::Node> multiply2 = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Multiply>>(
opset1::Multiply(
const auto input2_1 = std::make_shared<ov::opset1::Parameter>(precision1, inputShape);
const auto input2_2 = std::make_shared<ov::opset1::Parameter>(precision1, ov::Shape({ inputShape[0], inputShape[1], 1, 1 }));
const std::shared_ptr<ov::Node> multiply2 = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Multiply>>(
ov::opset1::Multiply(
ov::op::TemporaryReplaceOutputType(input2_1, element::f32).get(),
ov::op::TemporaryReplaceOutputType(input2_2, element::f32).get()),
std::vector<element::Type>{element::f32, element::f32},
std::vector<element::Type>{});
const std::shared_ptr<ngraph::Node> parent2 = dequantization2.empty() ? multiply2 : makeDequantization(multiply2, dequantization2);
const std::shared_ptr<ov::Node> parent2 = dequantization2.empty() ? multiply2 : makeDequantization(multiply2, dequantization2);
const auto add = std::make_shared<ngraph::opset1::Add>(parent1, parent2);
const auto add = std::make_shared<ov::opset1::Add>(parent1, parent2);
add->set_friendly_name("output");
auto& rtInfo = add->get_rt_info();
rtInfo["Variant::std::string"] = "add";
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(add) };
ngraph::ParameterVector parameters = { input1_1, input1_2, input2_1, input2_2 };
return std::make_shared<ngraph::Function>(results, parameters, "ElementwiseWithMultiParentDequantization");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(add) };
ov::ParameterVector parameters = { input1_1, input1_2, input2_1, input2_2 };
return std::make_shared<ov::Model>(results, parameters, "ElementwiseWithMultiParentDequantization");
}
} // namespace subgraph

View File

@ -4,7 +4,7 @@
#include "ov_lpt_models/fake_quantize.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include "ov_ops/type_relaxed.hpp"
#include "ov_models/subgraph_builders.hpp"
#include "low_precision/network_helper.hpp"
@ -17,19 +17,19 @@ namespace ngraph {
namespace builder {
namespace subgraph {
using namespace ngraph::pass;
using namespace ov::pass;
std::shared_ptr<ngraph::Function> FakeQuantizeFunction::getOriginalWithMaxPool(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> FakeQuantizeFunction::getOriginalWithMaxPool(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fakeQuantizeOnData) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
input->set_friendly_name("input");
const auto fakeQuantize = ngraph::builder::makeFakeQuantize(
input, element::f32, fakeQuantizeOnData.quantizationLevel, fakeQuantizeOnData.constantShape,
fakeQuantizeOnData.inputLowValues, fakeQuantizeOnData.inputHighValues, fakeQuantizeOnData.outputLowValues, fakeQuantizeOnData.outputHighValues);
const auto maxPool = std::make_shared<opset1::MaxPool>(
const auto maxPool = std::make_shared<ov::opset1::MaxPool>(
fakeQuantize,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -40,27 +40,27 @@ std::shared_ptr<ngraph::Function> FakeQuantizeFunction::getOriginalWithMaxPool(
auto& rtInfo = fakeQuantize->get_rt_info();
rtInfo["Variant::std::string"] = "fakeQuantize";
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(maxPool) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "FakeQuantizeFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(maxPool) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "FakeQuantizeFunction");
}
std::shared_ptr<ngraph::Function> FakeQuantizeFunction::getOriginal(
std::shared_ptr<ov::Model> FakeQuantizeFunction::getOriginal(
const ov::pass::low_precision::LayerTransformation::Params& params,
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnDataWithConstant& fakeQuantizeOnData,
const bool addNotPrecisionPreservedOperation) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
input->set_friendly_name("input");
const auto fakeQuantize = makeFakeQuantize(input, ngraph::element::f32, fakeQuantizeOnData);
const auto fakeQuantize = makeFakeQuantize(input, ov::element::f32, fakeQuantizeOnData);
fakeQuantize->set_friendly_name("fakeQuantize");
auto& rtInfo = fakeQuantize->get_rt_info();
rtInfo["Variant::std::string"] = "fakeQuantize";
std::shared_ptr<Node> lastOperation = fakeQuantize;
if (addNotPrecisionPreservedOperation) {
lastOperation = std::make_shared<opset1::AvgPool>(
lastOperation = std::make_shared<ov::opset1::AvgPool>(
fakeQuantize,
Strides{ 1, 1 },
Shape{ 1, 1 },
@ -71,30 +71,30 @@ std::shared_ptr<ngraph::Function> FakeQuantizeFunction::getOriginal(
}
lastOperation->set_friendly_name("lastOperation");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(lastOperation) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "FakeQuantizeFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(lastOperation) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "FakeQuantizeFunction");
}
std::shared_ptr<ngraph::Function> FakeQuantizeFunction::getReference(
std::shared_ptr<ov::Model> FakeQuantizeFunction::getReference(
const ov::pass::low_precision::LayerTransformation::Params& params,
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const bool updatePrecisions,
const FakeQuantizeOnDataWithConstant& fakeQuantizeOnData,
const ngraph::element::Type fakeQuantizeOutputPrecision,
const ov::element::Type fakeQuantizeOutputPrecision,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const bool addNotPrecisionPreservedOperation) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
input->set_friendly_name("input");
auto fakeQuantize = makeFakeQuantizeTypeRelaxed(input, ngraph::element::f32, fakeQuantizeOnData);
auto fakeQuantize = makeFakeQuantizeTypeRelaxed(input, ov::element::f32, fakeQuantizeOnData);
auto& rtInfo = fakeQuantize->get_rt_info();
rtInfo["Variant::std::string"] = "fakeQuantize";
std::shared_ptr<Node> lastOperation = fakeQuantize;
if (addNotPrecisionPreservedOperation) {
lastOperation = std::make_shared<ov::op::TypeRelaxed<opset1::AvgPool>>(
lastOperation = std::make_shared<ov::op::TypeRelaxed<ov::opset1::AvgPool>>(
std::vector<element::Type>{element::f32}, std::vector<element::Type>{element::f32},
ov::op::TemporaryReplaceOutputType(fakeQuantize, element::f32).get(),
Strides{ 1, 1 },
@ -128,8 +128,8 @@ std::shared_ptr<ngraph::Function> FakeQuantizeFunction::getReference(
deq->set_friendly_name("lastOperation");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(deq) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "FakeQuantizeFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(deq) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "FakeQuantizeFunction");
}
} // namespace subgraph

View File

@ -4,25 +4,24 @@
#include "ov_lpt_models/fake_quantize_and_convolution.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include "ov_models/subgraph_builders.hpp"
#include "ov_lpt_models/common/builders.hpp"
#include "inference_engine.hpp"
namespace ngraph {
namespace builder {
namespace subgraph {
// TODO: remove, reuse mode extended method
std::shared_ptr<ngraph::Function> FakeQuantizeAndConvolutionFunction::get(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> FakeQuantizeAndConvolutionFunction::get(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fqOnData,
const FakeQuantizeOnWeights& fqOnWeights) {
const auto rankLength = inputShape.rank().is_dynamic() ? 4 : inputShape.rank().get_length();
OPENVINO_ASSERT(rankLength == 3ul || rankLength == 4ul || rankLength == 5ul, "not supported input shape rank: ", rankLength);
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
const auto fakeQuantizeOnActivations = fqOnData.empty() ?
nullptr :
ngraph::builder::makeFakeQuantize(
@ -34,14 +33,14 @@ std::shared_ptr<ngraph::Function> FakeQuantizeAndConvolutionFunction::get(
const size_t inputChannelsCount = inputShape[1].get_length();
const size_t outputChannelsCount = 2 * inputShape[1].get_length();
const auto weights = ngraph::opset1::Constant::create(
const auto weights = ov::opset1::Constant::create(
precision,
rankLength == 3ul ?
(ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1}) :
(ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 }),
(ov::Shape{ outputChannelsCount, inputChannelsCount, 1}) :
(ov::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 }),
std::vector<float>(outputChannelsCount * inputChannelsCount, 1));
auto maxPool = std::make_shared<opset1::MaxPool>(
auto maxPool = std::make_shared<ov::opset1::MaxPool>(
fqOnData.empty() ? input : fakeQuantizeOnActivations,
Strides(rankLength - 2, 1ul),
Shape(rankLength - 2, 1ul),
@ -50,26 +49,26 @@ std::shared_ptr<ngraph::Function> FakeQuantizeAndConvolutionFunction::get(
op::RoundingType::FLOOR);
maxPool->set_friendly_name("maxPool");
const auto convolution = std::make_shared<ngraph::opset1::Convolution>(
const auto convolution = std::make_shared<ov::opset1::Convolution>(
maxPool, //fqOnData.empty() ? input : fakeQuantizeOnActivations,
fqOnWeights.empty() ?
weights->output(0) :
ngraph::builder::makeFakeQuantize(
weights, precision, fqOnWeights.quantizationLevel, fqOnWeights.constantShape,
fqOnWeights.inputLowValues, fqOnWeights.inputHighValues, fqOnWeights.outputLowValues, fqOnWeights.outputHighValues),
ngraph::Strides(rankLength - 2, 1ul),
ngraph::CoordinateDiff(rankLength - 2, 0ul),
ngraph::CoordinateDiff(rankLength - 2, 0ul),
ngraph::Strides(rankLength - 2, 1ul));
ov::Strides(rankLength - 2, 1ul),
ov::CoordinateDiff(rankLength - 2, 0ul),
ov::CoordinateDiff(rankLength - 2, 0ul),
ov::Strides(rankLength - 2, 1ul));
convolution->set_friendly_name("convolution");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(convolution) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "FakeQuantizeAndConvolutionFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(convolution) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "FakeQuantizeAndConvolutionFunction");
}
std::shared_ptr<ngraph::Function> FakeQuantizeAndConvolutionFunction::get(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> FakeQuantizeAndConvolutionFunction::get(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnDataWithConstant& fqOnData,
const DequantizationOperations::Convert& convertOnData,
const DequantizationOperations& dequantizationOnData,
@ -97,9 +96,9 @@ std::shared_ptr<ngraph::Function> FakeQuantizeAndConvolutionFunction::get(
operation);
}
std::shared_ptr<ngraph::Function> FakeQuantizeAndConvolutionFunction::get(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> FakeQuantizeAndConvolutionFunction::get(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnDataWithConstant& fqOnData,
const DequantizationOperations::Convert& convertOnData,
const DequantizationOperations& dequantizationOnData,
@ -114,7 +113,7 @@ std::shared_ptr<ngraph::Function> FakeQuantizeAndConvolutionFunction::get(
const DequantizationOperations& dequantizationAfter,
const std::string operation,
bool multiplyAfter) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
std::shared_ptr<Node> parentOnActivation = input;
{
@ -125,7 +124,7 @@ std::shared_ptr<ngraph::Function> FakeQuantizeAndConvolutionFunction::get(
}
if (!convertOnData.empty()) {
parentOnActivation = std::make_shared<opset1::Convert>(parentOnActivation, convertOnData.outPrecision);
parentOnActivation = std::make_shared<ov::opset1::Convert>(parentOnActivation, convertOnData.outPrecision);
}
if (!dequantizationOnData.empty()) {
@ -145,12 +144,12 @@ std::shared_ptr<ngraph::Function> FakeQuantizeAndConvolutionFunction::get(
outputChannelsCount = numGroups;
}
const Shape shape = constantOnWeights.shapeIsDefined ? constantOnWeights.shape : ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 };
parentOnWeights = ngraph::opset1::Constant::create(
const Shape shape = constantOnWeights.shapeIsDefined ? constantOnWeights.shape : ov::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 };
parentOnWeights = ov::opset1::Constant::create(
constantOnWeights.outPrecision,
shape,
constantOnWeights.values.size() != ngraph::shape_size(shape) ?
std::vector<float>(ngraph::shape_size(shape), constantOnWeights.values[0]) :
constantOnWeights.values.size() != ov::shape_size(shape) ?
std::vector<float>(ov::shape_size(shape), constantOnWeights.values[0]) :
constantOnWeights.values);
if (!fqOnWeights.empty()) {
@ -160,7 +159,7 @@ std::shared_ptr<ngraph::Function> FakeQuantizeAndConvolutionFunction::get(
}
if (!convertOnWeights.empty()) {
parentOnWeights = std::make_shared<opset1::Convert>(parentOnWeights, convertOnWeights.outPrecision);
parentOnWeights = std::make_shared<ov::opset1::Convert>(parentOnWeights, convertOnWeights.outPrecision);
}
if (!dequantizationOnWeights.empty()) {
@ -186,35 +185,35 @@ std::shared_ptr<ngraph::Function> FakeQuantizeAndConvolutionFunction::get(
std::shared_ptr<Node> lastOperation;
if (operation == "Convolution") {
lastOperation = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Convolution>>(
ngraph::opset1::Convolution(
lastOperation = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Convolution>>(
ov::opset1::Convolution(
ov::op::TemporaryReplaceOutputType(parentOnActivation, element::f32).get(),
ov::op::TemporaryReplaceOutputType(parentOnWeights, element::f32).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 }),
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 }),
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{});
} else if (operation == "GroupConvolution") {
lastOperation = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::GroupConvolution>>(
ngraph::opset1::GroupConvolution(
lastOperation = std::make_shared<ov::op::TypeRelaxed<ov::opset1::GroupConvolution>>(
ov::opset1::GroupConvolution(
ov::op::TemporaryReplaceOutputType(parentOnActivation, element::f32).get(),
ov::op::TemporaryReplaceOutputType(parentOnWeights, element::f32).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 }),
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 }),
std::vector<element::Type>{ element::f32, element::f32 },
std::vector<element::Type>{});
if (multiplyAfter) {
const auto& O = lastOperation->get_shape()[1];
std::vector<float> weights_val(O, 1);
auto constant = op::Constant::create(element::f32, Shape{O, 1, 1}, weights_val);
lastOperation = std::make_shared<ngraph::opset1::Multiply>(lastOperation, constant);
lastOperation = std::make_shared<ov::opset1::Multiply>(lastOperation, constant);
}
} else {
IE_THROW() << "unknown operation type " << operation;
OPENVINO_THROW("Unknown operation type ", operation);
}
if (!dequantizationAfter.empty()) {
@ -225,8 +224,8 @@ std::shared_ptr<ngraph::Function> FakeQuantizeAndConvolutionFunction::get(
lastOperation->set_friendly_name("output");
}
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(lastOperation) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "FakeQuantizeAndConvolutionFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(lastOperation) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "FakeQuantizeAndConvolutionFunction");
}
} // namespace subgraph

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include "ov_lpt_models/common/builders.hpp"
#include "ov_lpt_models/fake_quantize_and_two_output_branches_with_convolution.hpp"
#include "ov_lpt_models/common/fake_quantize_on_weights.hpp"
@ -14,21 +14,21 @@ namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<ngraph::opset1::Convolution> createConvolution(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::opset1::Convolution> createConvolution(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const std::shared_ptr<Node>& parent,
const FakeQuantizeOnWeights& fqOnWeights,
bool typeRelaxed) {
const size_t inputChannelsCount = inputShape[1].get_length();
const size_t outputChannelsCount = 2 * inputShape[1].get_length();
const auto weights = ngraph::opset1::Constant::create(
const auto weights = ov::opset1::Constant::create(
precision,
ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
ov::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
std::vector<float>(outputChannelsCount * inputChannelsCount, 1));
const std::shared_ptr<ngraph::opset1::Convolution> convolution = typeRelaxed ?
std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Convolution>>(
const std::shared_ptr<ov::opset1::Convolution> convolution = typeRelaxed ?
std::make_shared<ov::op::TypeRelaxed<ov::opset1::Convolution>>(
std::vector<element::Type>{ element::f32, element::f32 }, std::vector<element::Type>{},
ov::op::TemporaryReplaceOutputType(parent, element::f32).get(),
ov::op::TemporaryReplaceOutputType(fqOnWeights.empty() ?
@ -36,31 +36,31 @@ std::shared_ptr<ngraph::opset1::Convolution> createConvolution(
ngraph::builder::makeFakeQuantize(
weights, precision, fqOnWeights.quantizationLevel, fqOnWeights.constantShape,
fqOnWeights.inputLowValues, fqOnWeights.inputHighValues, fqOnWeights.outputLowValues, fqOnWeights.outputHighValues), element::f32).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 }) :
std::make_shared<ngraph::opset1::Convolution>(
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 }) :
std::make_shared<ov::opset1::Convolution>(
parent,
fqOnWeights.empty() ? weights->output(0) :
ngraph::builder::makeFakeQuantize(
weights, precision, fqOnWeights.quantizationLevel, fqOnWeights.constantShape,
fqOnWeights.inputLowValues, fqOnWeights.inputHighValues, fqOnWeights.outputLowValues, fqOnWeights.outputHighValues),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
return convolution;
}
std::shared_ptr<ngraph::Function> FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const FakeQuantizeOnData& fqOnData,
const FakeQuantizeOnWeights fqOnWeights1,
FakeQuantizeOnWeights fqOnWeights2) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
const auto fakeQuantizeOnActivations = fqOnData.empty() ?
nullptr :
ngraph::builder::makeFakeQuantize(
@ -73,43 +73,43 @@ std::shared_ptr<ngraph::Function> FakeQuantizeAndTwoOutputBranchesWithConvolutio
fqOnData.outputLowValues,
fqOnData.outputHighValues);
const std::shared_ptr<ngraph::opset1::Convolution> convolution1 = createConvolution(
const std::shared_ptr<ov::opset1::Convolution> convolution1 = createConvolution(
precision,
inputShape,
fakeQuantizeOnActivations,
fqOnWeights1,
false);
const std::shared_ptr<ngraph::opset1::Convolution> convolution2 = createConvolution(
const std::shared_ptr<ov::opset1::Convolution> convolution2 = createConvolution(
precision,
inputShape,
fakeQuantizeOnActivations,
fqOnWeights2,
false);
const std::shared_ptr<ngraph::opset1::Concat> concat = std::make_shared<ngraph::opset1::Concat>(NodeVector{ convolution1, convolution2 }, 1ul);
ngraph::ResultVector results { std::make_shared<ngraph::opset1::Result>(concat) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction");
const std::shared_ptr<ov::opset1::Concat> concat = std::make_shared<ov::opset1::Concat>(NodeVector{ convolution1, convolution2 }, 1ul);
ov::ResultVector results { std::make_shared<ov::opset1::Result>(concat) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction");
}
std::shared_ptr<ngraph::Function> FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::getReference(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
std::shared_ptr<ov::Model> FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::getReference(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ov::pass::low_precision::LayerTransformation::Params& params,
const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData,
const ngraph::element::Type precisionBeforeOp,
const ov::element::Type precisionBeforeOp,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore,
const ngraph::element::Type precisionAfterOp,
const ov::element::Type precisionAfterOp,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter1,
const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter2) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, ngraph::Shape(inputShape));
const auto input = std::make_shared<ov::opset1::Parameter>(precision, ov::Shape(inputShape));
const auto fakeQuantizeOnActivations = fqOnData.empty() ?
nullptr :
makeFakeQuantizeTypeRelaxed(input, precision, fqOnData);
ov::pass::low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantizeOnActivations, precisionBeforeOp);
const auto deqBefore = makeDequantization(fakeQuantizeOnActivations, dequantizationBefore);
const std::shared_ptr<ngraph::opset1::Convolution> convolution1 = createConvolution(
const std::shared_ptr<ov::opset1::Convolution> convolution1 = createConvolution(
precision,
inputShape,
deqBefore,
@ -117,7 +117,7 @@ std::shared_ptr<ngraph::Function> FakeQuantizeAndTwoOutputBranchesWithConvolutio
true);
const auto deqAfter1 = makeDequantization(convolution1, dequantizationAfter1);
const std::shared_ptr<ngraph::opset1::Convolution> convolution2 = createConvolution(
const std::shared_ptr<ov::opset1::Convolution> convolution2 = createConvolution(
precision,
inputShape,
deqBefore,
@ -125,20 +125,20 @@ std::shared_ptr<ngraph::Function> FakeQuantizeAndTwoOutputBranchesWithConvolutio
true);
const auto deqAfter2 = makeDequantization(convolution2, dequantizationAfter2);
const std::shared_ptr<ngraph::opset1::Concat> concat = std::make_shared<ngraph::opset1::Concat>(NodeVector{ deqAfter1, deqAfter2 }, 1ul);
const std::shared_ptr<ov::opset1::Concat> concat = std::make_shared<ov::opset1::Concat>(NodeVector{ deqAfter1, deqAfter2 }, 1ul);
ov::pass::low_precision::NetworkHelper::setOutDataPrecision(concat, precisionAfterOp);
if (params.updatePrecisions) {
replace_node(
convolution1->get_input_node_shared_ptr(1),
ov::pass::low_precision::fold<ngraph::opset1::Convert>(convolution1->get_input_node_shared_ptr(1), element::i8));
ov::pass::low_precision::fold<ov::opset1::Convert>(convolution1->get_input_node_shared_ptr(1), element::i8));
replace_node(
convolution2->get_input_node_shared_ptr(1),
ov::pass::low_precision::fold<ngraph::opset1::Convert>(convolution2->get_input_node_shared_ptr(1), element::i8));
ov::pass::low_precision::fold<ov::opset1::Convert>(convolution2->get_input_node_shared_ptr(1), element::i8));
}
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(concat) };
auto function = std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(concat) };
auto function = std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction");
return function;
}

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include "ov_lpt_models/common/builders.hpp"
#include "ov_lpt_models/fake_quantize_on_weights_and_unsupported_child.hpp"
#include "ov_lpt_models/common/fake_quantize_on_weights.hpp"
@ -13,33 +13,33 @@
namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<ngraph::Function> FakeQuantizeOnWeightsAndUnsupportedChildFunction::get(
const ngraph::Shape& inputShape,
const ngraph::element::Type inputPrecision,
const std::shared_ptr<ngraph::opset1::Constant> weights,
std::shared_ptr<ov::Model> FakeQuantizeOnWeightsAndUnsupportedChildFunction::get(
const ov::Shape& inputShape,
const ov::element::Type inputPrecision,
const std::shared_ptr<ov::opset1::Constant> weights,
const ngraph::builder::subgraph::FakeQuantizeOnWeights fqOnWeights) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(inputPrecision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(inputPrecision, inputShape);
input->set_friendly_name("Input");
weights->set_friendly_name("Weights");
std::shared_ptr<ngraph::Node> weightsParent = weights;
std::shared_ptr<ov::Node> weightsParent = weights;
if (!fqOnWeights.empty()) {
const auto fakeQuantizeOnWeights = makeFakeQuantize(weights, inputPrecision, fqOnWeights);
fakeQuantizeOnWeights->set_friendly_name("FakeQuantize");
weightsParent = fakeQuantizeOnWeights;
}
auto unsupportedOperation = std::make_shared<ngraph::opset1::ConvolutionBackpropData>(
input, weightsParent, ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 }, ngraph::CoordinateDiff{ 0, 0 }, ngraph::Strides{ 1, 1 });
auto unsupportedOperation = std::make_shared<ov::opset1::ConvolutionBackpropData>(
input, weightsParent, ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 }, ov::CoordinateDiff{ 0, 0 }, ov::Strides{ 1, 1 });
unsupportedOperation->set_friendly_name("UnsupportedOperation");
const auto result = std::make_shared<ngraph::opset1::Result>(unsupportedOperation);
const auto result = std::make_shared<ov::opset1::Result>(unsupportedOperation);
result->set_friendly_name("Result");
std::shared_ptr<ngraph::Function> function = std::make_shared<ngraph::Function>(
std::shared_ptr<ov::Model> function = std::make_shared<ov::Model>(
ResultVector{ result },
ngraph::ParameterVector{ input },
ov::ParameterVector{ input },
"FakeQuantizeOnWeightsWithUnsupportedOperations");
return function;

View File

@ -4,7 +4,7 @@
#include "ov_lpt_models/fake_quantize_precision_selection.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include <ov_ops/type_relaxed.hpp>
#include "ov_models/subgraph_builders.hpp"
#include "ov_lpt_models/common/builders.hpp"
@ -14,15 +14,15 @@ namespace ngraph {
namespace builder {
namespace subgraph {
using namespace ngraph::pass;
using namespace ov::pass;
std::shared_ptr<ngraph::Function> FakeQuantizePrecisionSelectionFunction::getOriginal(
const ngraph::element::Type precision,
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> FakeQuantizePrecisionSelectionFunction::getOriginal(
const ov::element::Type precision,
const ov::PartialShape& inputShape,
const ActualValues& values) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precision, inputShape);
input->set_friendly_name("input");
std::shared_ptr<ngraph::Node> parent = input;
std::shared_ptr<ov::Node> parent = input;
const auto fakeQuantize = ngraph::builder::makeFakeQuantize(
input, precision,
@ -34,29 +34,29 @@ std::shared_ptr<ngraph::Function> FakeQuantizePrecisionSelectionFunction::getOri
values.fakeQuantizeOnData.outputHighValues);
fakeQuantize->set_friendly_name("fakeQuantize");
std::shared_ptr<ngraph::Node> branch1Last;
std::shared_ptr<ov::Node> branch1Last;
{
// branch with limitation precision operation (Convolution)
std::shared_ptr<ngraph::Node> branch1Operation = values.operationBeforeLimitedOperationIsPrecisionTransparent ?
std::dynamic_pointer_cast<ngraph::Node>(std::make_shared<ngraph::opset1::MaxPool>(
std::shared_ptr<ov::Node> branch1Operation = values.operationBeforeLimitedOperationIsPrecisionTransparent ?
std::dynamic_pointer_cast<ov::Node>(std::make_shared<ov::opset1::MaxPool>(
fakeQuantize,
Strides{ 1, 1 }, Shape{ 1, 1 }, Shape{ 0, 0 }, Shape{ 2, 2 },
op::RoundingType::FLOOR)) :
std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::PRelu>>(
opset1::PRelu(
std::make_shared<ov::op::TypeRelaxed<ov::opset1::PRelu>>(
ov::opset1::PRelu(
fakeQuantize,
std::make_shared<opset1::Constant>(element::f32, Shape{}, std::vector<float>{ 0.01 })),
std::make_shared<ov::opset1::Constant>(element::f32, Shape{}, std::vector<float>{ 0.01 })),
element::f32);
const size_t inputChannelsCount = inputShape[1].get_length();
const size_t outputChannelsCount = 2 * inputShape[1].get_length();
const auto weights = ngraph::opset1::Constant::create(
const auto weights = ov::opset1::Constant::create(
precision,
ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
ov::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
std::vector<float>(outputChannelsCount * inputChannelsCount, 1.f));
std::shared_ptr<ngraph::opset1::Convolution> convolution = std::make_shared<ngraph::opset1::Convolution>(
std::shared_ptr<ov::opset1::Convolution> convolution = std::make_shared<ov::opset1::Convolution>(
branch1Operation,
values.fakeQuantizeOnWeights.empty() ?
weights->output(0) :
@ -69,37 +69,37 @@ std::shared_ptr<ngraph::Function> FakeQuantizePrecisionSelectionFunction::getOri
values.fakeQuantizeOnWeights.inputHighValues,
values.fakeQuantizeOnWeights.outputLowValues,
values.fakeQuantizeOnWeights.outputHighValues),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
branch1Last = convolution;
}
std::shared_ptr<ngraph::Node> branch2Last;
std::shared_ptr<ov::Node> branch2Last;
{
// just another branch
branch2Last = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::PRelu>>(
opset1::PRelu(
branch2Last = std::make_shared<ov::op::TypeRelaxed<ov::opset1::PRelu>>(
ov::opset1::PRelu(
fakeQuantize,
std::make_shared<opset1::Constant>(element::f32, Shape{}, std::vector<float>{ 0.01 })),
std::make_shared<ov::opset1::Constant>(element::f32, Shape{}, std::vector<float>{ 0.01 })),
element::f32);
}
const std::shared_ptr<ngraph::opset1::Concat> concat = std::make_shared<ngraph::opset1::Concat>(
ngraph::OutputVector{ branch1Last->output(0), branch2Last->output(0) }, 1);
const std::shared_ptr<ov::opset1::Concat> concat = std::make_shared<ov::opset1::Concat>(
ov::OutputVector{ branch1Last->output(0), branch2Last->output(0) }, 1);
concat->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(concat) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "FakeQuantizePrecisionSelectionFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(concat) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "FakeQuantizePrecisionSelectionFunction");
}
std::shared_ptr<ngraph::Function> FakeQuantizePrecisionSelectionFunction::getReference(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
std::shared_ptr<ov::Model> FakeQuantizePrecisionSelectionFunction::getReference(
const ov::element::Type precision,
const ov::Shape& inputShape,
const ExpectedValues& values) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precision, ngraph::Shape(inputShape));
const auto input = std::make_shared<ov::opset1::Parameter>(precision, ov::Shape(inputShape));
input->set_friendly_name("input");
const auto fakeQuantize = ngraph::builder::subgraph::makeFakeQuantizeTypeRelaxed(
@ -109,24 +109,24 @@ std::shared_ptr<ngraph::Function> FakeQuantizePrecisionSelectionFunction::getRef
fakeQuantize->set_friendly_name("fakeQuantize");
// branch with limitation precision operation (Convolution)
std::shared_ptr<ngraph::Node> branch1Pooling = values.operationBeforeLimitedOperationIsPrecisionTransparent ?
std::dynamic_pointer_cast<ngraph::Node>(std::make_shared<ngraph::opset1::MaxPool>(
std::shared_ptr<ov::Node> branch1Pooling = values.operationBeforeLimitedOperationIsPrecisionTransparent ?
std::dynamic_pointer_cast<ov::Node>(std::make_shared<ov::opset1::MaxPool>(
fakeQuantize,
Strides{ 1, 1 }, Shape{ 1, 1 }, Shape{ 0, 0 }, Shape{ 2, 2 },
op::RoundingType::FLOOR)) :
std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::PRelu>>(
std::make_shared<ov::op::TypeRelaxed<ov::opset1::PRelu>>(
fakeQuantize,
std::make_shared<opset1::Constant>(element::f32, Shape{}, std::vector<float>{ 0.01 }));
std::make_shared<ov::opset1::Constant>(element::f32, Shape{}, std::vector<float>{ 0.01 }));
const size_t inputChannelsCount = inputShape[1];
const size_t outputChannelsCount = 2 * inputShape[1];
const auto weights = ngraph::opset1::Constant::create(
const auto weights = ov::opset1::Constant::create(
precision,
ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
ov::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 },
std::vector<float>(outputChannelsCount * inputChannelsCount, -126.f));
std::shared_ptr<ngraph::Node> onWeights = values.fakeQuantizeOnWeights.empty() ?
std::shared_ptr<ov::Node> onWeights = values.fakeQuantizeOnWeights.empty() ?
weights :
ngraph::builder::makeFakeQuantize(
weights,
@ -138,28 +138,28 @@ std::shared_ptr<ngraph::Function> FakeQuantizePrecisionSelectionFunction::getRef
values.fakeQuantizeOnWeights.outputLowValues,
values.fakeQuantizeOnWeights.outputHighValues);
std::shared_ptr<ngraph::opset1::Convolution> convolution = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::Convolution>>(
std::shared_ptr<ov::opset1::Convolution> convolution = std::make_shared<ov::op::TypeRelaxed<ov::opset1::Convolution>>(
std::vector<element::Type>{ element::f32, element::f32 }, std::vector<element::Type>{},
ov::op::TemporaryReplaceOutputType(branch1Pooling, element::f32).get(),
ov::op::TemporaryReplaceOutputType(onWeights, element::f32).get(),
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
std::shared_ptr<ngraph::opset1::Multiply> branch1Multiply = std::make_shared<ngraph::opset1::Multiply>(
std::shared_ptr<ov::opset1::Multiply> branch1Multiply = std::make_shared<ov::opset1::Multiply>(
convolution,
std::make_shared<ngraph::opset1::Constant>(precision, Shape({}), std::vector<float>({ 0.0001f })));
std::make_shared<ov::opset1::Constant>(precision, Shape({}), std::vector<float>({ 0.0001f })));
// just another branch
std::shared_ptr<ngraph::opset1::PRelu> branch2PRelu = std::make_shared<ov::op::TypeRelaxed<ngraph::opset1::PRelu>>(
std::shared_ptr<ov::opset1::PRelu> branch2PRelu = std::make_shared<ov::op::TypeRelaxed<ov::opset1::PRelu>>(
fakeQuantize,
std::make_shared<opset1::Constant>(element::f32, Shape{}, std::vector<float>{ 0.01 }));
std::make_shared<ov::opset1::Constant>(element::f32, Shape{}, std::vector<float>{ 0.01 }));
const std::shared_ptr<ngraph::Node> branch2Multiply = std::make_shared<ngraph::opset1::Multiply>(
const std::shared_ptr<ov::Node> branch2Multiply = std::make_shared<ov::opset1::Multiply>(
branch2PRelu,
std::make_shared<ngraph::opset1::Constant>(precision, Shape({}), std::vector<float>({0.01f})));
std::make_shared<ov::opset1::Constant>(precision, Shape({}), std::vector<float>({0.01f})));
if (values.fakeQuantizeOnDataOutPrecision != precision) {
ov::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize, values.fakeQuantizeOnDataOutPrecision);
@ -178,19 +178,19 @@ std::shared_ptr<ngraph::Function> FakeQuantizePrecisionSelectionFunction::getRef
if (values.fakeQuantizeOnWeights.empty()) {
replace_node(
weights,
ov::pass::low_precision::fold<ngraph::opset1::Convert>(weights, ngraph::element::i8));
ov::pass::low_precision::fold<ov::opset1::Convert>(weights, ov::element::i8));
}
ov::pass::low_precision::NetworkHelper::setOutDataPrecision(branch2PRelu, precision);
}
const std::shared_ptr<ngraph::opset1::Concat> concat = std::make_shared<ngraph::opset1::Concat>(
ngraph::OutputVector{ branch1Multiply->output(0), branch2Multiply->output(0) }, 1);
const std::shared_ptr<ov::opset1::Concat> concat = std::make_shared<ov::opset1::Concat>(
ov::OutputVector{ branch1Multiply->output(0), branch2Multiply->output(0) }, 1);
concat->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(concat) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "FakeQuantizePrecisionSelectionFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(concat) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "FakeQuantizePrecisionSelectionFunction");
}
} // namespace subgraph

View File

@ -4,7 +4,7 @@
#include "ov_lpt_models/fold_fake_quantize.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include "ov_ops/type_relaxed.hpp"
#include "ov_models/subgraph_builders.hpp"
@ -12,32 +12,32 @@ namespace ngraph {
namespace builder {
namespace subgraph {
using namespace ngraph::pass;
using namespace ov::pass;
std::shared_ptr<ngraph::Function> FoldFakeQuantizeFunction::getOriginal(
const ngraph::element::Type precision,
const ngraph::Shape& constShape,
std::shared_ptr<ov::Model> FoldFakeQuantizeFunction::getOriginal(
const ov::element::Type precision,
const ov::Shape& constShape,
const std::vector<float>& constValues,
const FakeQuantizeOnData& fakeQuantizeOnData) {
const auto constant = std::make_shared<ngraph::opset1::Constant>(precision, constShape, constValues);
const auto constant = std::make_shared<ov::opset1::Constant>(precision, constShape, constValues);
const auto fakeQuantize = ngraph::builder::makeFakeQuantize(
constant, precision, fakeQuantizeOnData.quantizationLevel, fakeQuantizeOnData.constantShape,
fakeQuantizeOnData.inputLowValues, fakeQuantizeOnData.inputHighValues, fakeQuantizeOnData.outputLowValues, fakeQuantizeOnData.outputHighValues);
fakeQuantize->set_friendly_name("fakeQuantize");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(fakeQuantize) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{}, "FoldFakeQuantizeFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(fakeQuantize) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{}, "FoldFakeQuantizeFunction");
}
std::shared_ptr<ngraph::Function> FoldFakeQuantizeFunction::getReference(
const ngraph::element::Type precision,
const ngraph::Shape& constShape,
std::shared_ptr<ov::Model> FoldFakeQuantizeFunction::getReference(
const ov::element::Type precision,
const ov::Shape& constShape,
const std::vector<float>& constValues) {
const std::shared_ptr<Node> constant = std::make_shared<ngraph::opset1::Constant>(precision, constShape, constValues);
const std::shared_ptr<Node> constant = std::make_shared<ov::opset1::Constant>(precision, constShape, constValues);
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(constant) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{}, "FoldFakeQuantizeFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(constant) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{}, "FoldFakeQuantizeFunction");
}
} // namespace subgraph

View File

@ -4,7 +4,7 @@
#include "ov_lpt_models/fuse_convert.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include "ov_models/subgraph_builders.hpp"
#include "ov_lpt_models/common/builders.hpp"
@ -12,18 +12,18 @@ namespace ngraph {
namespace builder {
namespace subgraph {
std::shared_ptr<ngraph::Function> FuseConvertFunction::get(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type inputPrecision,
std::shared_ptr<ov::Model> FuseConvertFunction::get(
const ov::PartialShape& inputShape,
const ov::element::Type inputPrecision,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const ngraph::builder::subgraph::FakeQuantizeOnData& fakeQuantize,
const bool constInput) {
std::shared_ptr<Node> parent;
std::shared_ptr<op::Parameter> input;
if (constInput) {
parent = std::make_shared<opset1::Constant>(inputPrecision, inputShape.to_shape(), std::vector<float>{ 128.f });
parent = std::make_shared<ov::opset1::Constant>(inputPrecision, inputShape.to_shape(), std::vector<float>{ 128.f });
} else {
input = std::make_shared<ngraph::opset1::Parameter>(
input = std::make_shared<ov::opset1::Parameter>(
inputPrecision,
inputShape);
parent = input;
@ -38,24 +38,24 @@ std::shared_ptr<ngraph::Function> FuseConvertFunction::get(
parent->set_friendly_name("output");
auto parameters = constInput ?
ngraph::ParameterVector{}:
ngraph::ParameterVector{ input };
ov::ParameterVector{}:
ov::ParameterVector{ input };
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(parent)};
return std::make_shared<ngraph::Function>(results, parameters, "FuseConvertFunction");
ov::ResultVector results{std::make_shared<ov::opset1::Result>(parent)};
return std::make_shared<ov::Model>(results, parameters, "FuseConvertFunction");
}
std::shared_ptr<ngraph::Function> FuseConvertFunction::getWithFQ(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type inputPrecision,
std::shared_ptr<ov::Model> FuseConvertFunction::getWithFQ(
const ov::PartialShape& inputShape,
const ov::element::Type inputPrecision,
const ngraph::builder::subgraph::DequantizationOperations& dequantization,
const bool constInput) {
std::shared_ptr<Node> parent;
std::shared_ptr<op::Parameter> input1;
if (constInput) {
parent = std::make_shared<opset1::Constant>(inputPrecision, inputShape.to_shape(), std::vector<float>{ 128.f });
parent = std::make_shared<ov::opset1::Constant>(inputPrecision, inputShape.to_shape(), std::vector<float>{ 128.f });
} else {
input1 = std::make_shared<ngraph::opset1::Parameter>(
input1 = std::make_shared<ov::opset1::Parameter>(
inputPrecision,
inputShape);
parent = input1;
@ -64,7 +64,7 @@ std::shared_ptr<ngraph::Function> FuseConvertFunction::getWithFQ(
deqStructure.multiply.outPrecision = inputPrecision;
const std::shared_ptr<Node> dequantizationOp = makeDequantization(parent, deqStructure);
std::shared_ptr<op::Parameter> input2 = std::make_shared<ngraph::opset1::Parameter>(
std::shared_ptr<op::Parameter> input2 = std::make_shared<ov::opset1::Parameter>(
inputPrecision,
inputShape);
@ -73,22 +73,22 @@ std::shared_ptr<ngraph::Function> FuseConvertFunction::getWithFQ(
{ 0.f }, { 255.f }, { 0.f }, { 255.f });
// just some non-transparent layer
const auto power = std::make_shared<opset1::Power>(
const auto power = std::make_shared<ov::opset1::Power>(
fakeQuantizeOnActivations,
std::make_shared<opset1::Constant>(inputPrecision, Shape{}, std::vector<float>{2.f}));
std::make_shared<ov::opset1::Constant>(inputPrecision, Shape{}, std::vector<float>{2.f}));
const auto add = std::make_shared<opset1::Add>(
const auto add = std::make_shared<ov::opset1::Add>(
dequantizationOp,
power);
add->set_friendly_name("output");
auto parameters = constInput ?
ngraph::ParameterVector{ input2 }:
ngraph::ParameterVector{ input1, input2 };
ov::ParameterVector{ input2 }:
ov::ParameterVector{ input1, input2 };
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(add) };
return std::make_shared<ngraph::Function>(results, parameters, "FuseConvertFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(add) };
return std::make_shared<ov::Model>(results, parameters, "FuseConvertFunction");
}

View File

@ -4,7 +4,7 @@
#include "ov_lpt_models/fuse_fake_quantize.hpp"
#include <ngraph/opsets/opset1.hpp>
#include <openvino/opsets/opset1.hpp>
#include "ov_ops/type_relaxed.hpp"
#include "low_precision/network_helper.hpp"
#include "ov_models/subgraph_builders.hpp"
@ -17,23 +17,23 @@ namespace ngraph {
namespace builder {
namespace subgraph {
using namespace ngraph::pass;
using namespace ov::pass;
std::shared_ptr<ngraph::Function> FuseFakeQuantizeFunction::getOriginal(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeAdd,
std::shared_ptr<ov::Model> FuseFakeQuantizeFunction::getOriginal(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeAdd,
const Add& add,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const DequantizationOperations& dequantization,
const ngraph::element::Type precisionAfterDequantization,
const ngraph::element::Type precisionFqOnData,
const ov::element::Type precisionAfterDequantization,
const ov::element::Type precisionFqOnData,
const FakeQuantizeOnDataWithConstant& fqOnData) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(add.empty() ? precisionBeforeDequantization : precisionBeforeAdd, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(add.empty() ? precisionBeforeDequantization : precisionBeforeAdd, inputShape);
input->set_friendly_name("input");
std::shared_ptr<Node> parent = input;
if (!add.empty()) {
parent = makeElementwise<ngraph::opset1::Add>(parent, add);
parent = makeElementwise<ov::opset1::Add>(parent, add);
}
const std::shared_ptr<Node> lastDequantization = makeDequantization(parent, dequantization);
@ -43,19 +43,19 @@ std::shared_ptr<ngraph::Function> FuseFakeQuantizeFunction::getOriginal(
makeFakeQuantizeTypeRelaxed(lastDequantization, precisionFqOnData, fqOnData);
fakeQuantize->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(fakeQuantize) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "FuseFakeQuantizeFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(fakeQuantize) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "FuseFakeQuantizeFunction");
}
namespace {
std::shared_ptr<ngraph::opset1::Convolution> make_convolution(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBefore,
std::shared_ptr<ov::opset1::Convolution> make_convolution(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBefore,
const std::shared_ptr<Node>& parent,
const size_t index) {
const ov::Shape shape = inputShape.to_shape();
const ov::Shape weightsShape({ shape[1], shape[1], 1ull, 1ull });
auto weightsConstant = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, weightsShape, std::vector<float>(9, 1.f));
auto weightsConstant = std::make_shared<ov::op::v0::Constant>(ov::element::f32, weightsShape, std::vector<float>(9, 1.f));
auto weights = makeFakeQuantize(
weightsConstant,
precisionBefore,
@ -68,40 +68,40 @@ std::shared_ptr<ngraph::opset1::Convolution> make_convolution(
{ 1.28f, 1.28f, 1.28f },
precisionBefore));
auto convolution = std::make_shared<ngraph::opset1::Convolution>(
auto convolution = std::make_shared<ov::opset1::Convolution>(
parent,
weights,
ngraph::Strides{ 1, 1 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::CoordinateDiff{ 0, 0 },
ngraph::Strides{ 1, 1 });
ov::Strides{ 1, 1 },
ov::CoordinateDiff{ 0, 0 },
ov::CoordinateDiff{ 0, 0 },
ov::Strides{ 1, 1 });
convolution->set_friendly_name("convolution" + std::to_string(index));
return convolution;
}
} // namespace
std::shared_ptr<ngraph::Function> FuseFakeQuantizeFunction::getReference(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBeforeAdd,
std::shared_ptr<ov::Model> FuseFakeQuantizeFunction::getReference(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBeforeAdd,
const Add& add,
const ngraph::element::Type precisionBeforeDequantization,
const ov::element::Type precisionBeforeDequantization,
const DequantizationOperations& dequantization,
const ngraph::element::Type precisionAfterDequantization,
const ngraph::element::Type precisionFqOnData,
const ov::element::Type precisionAfterDequantization,
const ov::element::Type precisionFqOnData,
const FakeQuantizeOnDataWithConstant& fqOnData) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(add.empty() ? precisionBeforeDequantization : precisionBeforeAdd, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(add.empty() ? precisionBeforeDequantization : precisionBeforeAdd, inputShape);
input->set_friendly_name("input");
std::shared_ptr<Node> parent = input;
if (!add.empty()) {
parent = makeElementwise<ngraph::opset1::Add>(parent, add);
parent = makeElementwise<ov::opset1::Add>(parent, add);
}
const std::shared_ptr<Node> lastDequantization = makeDequantization(parent, dequantization);
auto fqOnDataCopy = fqOnData;
fqOnDataCopy.outputHighValues = {255.f};
fqOnDataCopy.outputPrecision = fqOnData.outputPrecision == element::undefined ? ngraph::element::u8 : fqOnData.outputPrecision;
fqOnDataCopy.outputPrecision = fqOnData.outputPrecision == element::undefined ? ov::element::u8 : fqOnData.outputPrecision;
std::shared_ptr<Node> lastNode = makeFakeQuantizeTypeRelaxed(lastDequantization, precisionFqOnData, fqOnDataCopy);
lastNode = makeDequantization(
@ -116,17 +116,17 @@ std::shared_ptr<ngraph::opset1::Convolution> make_convolution(
});
lastNode->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(lastNode) };
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "FuseFakeQuantizeFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(lastNode) };
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "FuseFakeQuantizeFunction");
}
std::shared_ptr<ngraph::Function> FuseFakeQuantizeFunction::get(
const ngraph::PartialShape& inputShape,
const ngraph::element::Type precisionBefore,
std::shared_ptr<ov::Model> FuseFakeQuantizeFunction::get(
const ov::PartialShape& inputShape,
const ov::element::Type precisionBefore,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2,
const DequantizationOperations& dequantizationOperations2) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(precisionBefore, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(precisionBefore, inputShape);
input->set_friendly_name("input");
std::shared_ptr<Node> parent = input;
@ -142,10 +142,10 @@ std::shared_ptr<ngraph::Function> FuseFakeQuantizeFunction::get(
const std::vector<size_t> stride = { 1, 1 };
const std::vector<size_t> padBegin = { 0, 0 };
const std::vector<size_t> padEnd = { 0, 0 };
const ngraph::op::PadType padType = ngraph::op::PadType::NOTSET;
const ngraph::op::RoundingType roundingType = ngraph::op::RoundingType::FLOOR;
const ov::op::PadType padType = ov::op::PadType::NOTSET;
const ov::op::RoundingType roundingType = ov::op::RoundingType::FLOOR;
parent = std::make_shared<ngraph::opset1::MaxPool>(
parent = std::make_shared<ov::opset1::MaxPool>(
parent,
stride,
padBegin,
@ -163,17 +163,17 @@ std::shared_ptr<ngraph::Function> FuseFakeQuantizeFunction::get(
parent = makeDequantization(parent, dequantizationOperations2);
}
ngraph::ResultVector results{
std::make_shared<ngraph::opset1::Result>(make_convolution(inputShape, precisionBefore, parent, 0)),
std::make_shared<ngraph::opset1::Result>(make_convolution(inputShape, precisionBefore, parent, 1))
ov::ResultVector results{
std::make_shared<ov::opset1::Result>(make_convolution(inputShape, precisionBefore, parent, 0)),
std::make_shared<ov::opset1::Result>(make_convolution(inputShape, precisionBefore, parent, 1))
};
return std::make_shared<ngraph::Function>(results, ngraph::ParameterVector{ input }, "FuseFakeQuantizeFunction");
return std::make_shared<ov::Model>(results, ov::ParameterVector{ input }, "FuseFakeQuantizeFunction");
}
std::shared_ptr<ngraph::Function> FuseFakeQuantizeFunction::get(
const ngraph::PartialShape& inputShape,
std::shared_ptr<ov::Model> FuseFakeQuantizeFunction::get(
const ov::PartialShape& inputShape,
const std::vector<Branch>& branches,
const ngraph::element::Type precisionFqOnData,
const ov::element::Type precisionFqOnData,
const FakeQuantizeOnData& fqOnData) {
if (branches.size() != 2ul) {
throw std::runtime_error("unsupported branches count");
@ -183,25 +183,25 @@ std::shared_ptr<ngraph::Function> FuseFakeQuantizeFunction::get(
throw std::runtime_error("branch precisions are not equal");
}
ngraph::ParameterVector inputs;
ov::ParameterVector inputs;
std::vector<std::shared_ptr<Node>> lastDequantizations;
for (const Branch& branch : branches) {
const auto input = std::make_shared<ngraph::opset1::Parameter>(branch.precisionBeforeDequantization, inputShape);
const auto input = std::make_shared<ov::opset1::Parameter>(branch.precisionBeforeDequantization, inputShape);
inputs.push_back(input);
const std::shared_ptr<Node> lastDequantization = makeDequantization(input, branch.dequantization);
lastDequantizations.push_back(lastDequantization);
}
std::shared_ptr<ngraph::opset1::Multiply> multiply = std::make_shared<ngraph::opset1::Multiply>(lastDequantizations[0], lastDequantizations[1]);
std::shared_ptr<ov::opset1::Multiply> multiply = std::make_shared<ov::opset1::Multiply>(lastDequantizations[0], lastDequantizations[1]);
const std::shared_ptr<Node> fakeQuantize = branches[0].dequantization.multiply.outPrecision == precisionFqOnData ?
makeFakeQuantize(multiply, precisionFqOnData, fqOnData) :
makeFakeQuantizeTypeRelaxed(multiply, precisionFqOnData, fqOnData);
fakeQuantize->set_friendly_name("output");
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(fakeQuantize) };
return std::make_shared<ngraph::Function>(results, inputs, "FuseFakeQuantizeFunction");
ov::ResultVector results{ std::make_shared<ov::opset1::Result>(fakeQuantize) };
return std::make_shared<ov::Model>(results, inputs, "FuseFakeQuantizeFunction");
}
} // namespace subgraph

Some files were not shown because too many files have changed in this diff Show More