Refactor ngraph builders 4 (#21100)
* Remove and deprecate some ngraph builders
This commit is contained in:
1 parent
d29207e201
commit
71af0eef38
80 files changed
+246
-514
No files matched your search
@@ -89,6 +89,7 @@ protected:
|
||||
|
||||
auto activation = ngraph::builder::makeActivation(conv, ngPrc, actType);
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
auto maxpool = ngraph::builder::makePooling(activation,
|
||||
{1, 2},
|
||||
{0, 0},
|
||||
@@ -98,6 +99,7 @@ protected:
|
||||
ngraph::op::PadType::VALID,
|
||||
false,
|
||||
ngraph::helpers::PoolingTypes::MAX);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(maxpool)};
|
||||
function = std::make_shared<ngraph::Function>(results, inputVector, "ActMaxpoolReordering");
|
||||
|
||||
@@ -82,7 +82,7 @@ protected:
|
||||
|
||||
const int axis = 1;
|
||||
ov::OutputVector to_concat{readValue, reshape};
|
||||
auto concat = ngraph::builder::makeConcat(to_concat, axis);
|
||||
auto concat = std::make_shared<ov::op::v0::Concat>(to_concat, axis);
|
||||
|
||||
const auto concat_shape = concat->get_output_shape(0);
|
||||
const auto concat_shape_size = ov::shape_size(concat_shape);
|
||||
|
||||
@@ -62,7 +62,7 @@ struct ReLUConcatAxis {
|
||||
auto constValues = ov::test::utils::generate_float_numbers(totalSize, -0.1f, 0.1f);
|
||||
auto constNode = ngraph::builder::makeConstant(ngPrc, {inputShape}, constValues);
|
||||
concatInputs.push_back(constNode);
|
||||
auto concat = ngraph::builder::makeConcat(concatInputs, axis);
|
||||
auto concat = std::make_shared<ov::op::v0::Concat>(concatInputs, axis);
|
||||
|
||||
ov::ResultVector results{std::make_shared<ov::opset10::Result>(concat)};
|
||||
return std::make_shared<ngraph::Function>(results, params, getName());
|
||||
@@ -108,7 +108,7 @@ struct MatmulConcatAxis {
|
||||
concatInputs.push_back(matmul1);
|
||||
auto matmul2 = std::make_shared<ov::opset10::MatMul>(params[0], constMul2, false, true);
|
||||
concatInputs.push_back(matmul2);
|
||||
auto concat = ngraph::builder::makeConcat(concatInputs, axis);
|
||||
auto concat = std::make_shared<ov::op::v0::Concat>(concatInputs, axis);
|
||||
|
||||
ov::ResultVector results{std::make_shared<ov::opset10::Result>(concat)};
|
||||
return std::make_shared<ngraph::Function>(results, params, getName());
|
||||
@@ -150,7 +150,7 @@ struct ConvNCHWConcatAxis {
|
||||
auto constValues = ov::test::utils::generate_float_numbers(totalSize, -0.0001f, 0.0001f);
|
||||
auto constNode = ngraph::builder::makeConstant(ngPrc, {inputShape}, constValues);
|
||||
concatInputs.push_back(constNode);
|
||||
auto concat = ngraph::builder::makeConcat(concatInputs, axis);
|
||||
auto concat = std::make_shared<ov::op::v0::Concat>(concatInputs, axis);
|
||||
|
||||
ov::ResultVector results{std::make_shared<ov::opset10::Result>(concat)};
|
||||
return std::make_shared<ngraph::Function>(results, params, getName());
|
||||
@@ -196,7 +196,7 @@ struct ConvNHWCConcatAxis {
|
||||
auto constValues = ov::test::utils::generate_float_numbers(totalSize, -0.0001f, 0.0001f);
|
||||
auto constNode = ngraph::builder::makeConstant(ngPrc, {inputShape}, constValues);
|
||||
concatInputs.push_back(constNode);
|
||||
auto concat = ngraph::builder::makeConcat(concatInputs, axis);
|
||||
auto concat = std::make_shared<ov::op::v0::Concat>(concatInputs, axis);
|
||||
|
||||
ov::ResultVector results{std::make_shared<ov::opset10::Result>(concat)};
|
||||
return std::make_shared<ngraph::Function>(results, params, getName());
|
||||
@@ -251,7 +251,7 @@ struct ConvConcatNHWCAxis {
|
||||
|
||||
concatInputs.push_back(conv1);
|
||||
concatInputs.push_back(conv2);
|
||||
auto concat = ngraph::builder::makeConcat(concatInputs, axis);
|
||||
auto concat = std::make_shared<ov::op::v0::Concat>(concatInputs, axis);
|
||||
|
||||
auto transposeOutOrder = ov::opset10::Constant::create(ov::element::i64, ov::Shape{4}, {0, 2, 3, 1});
|
||||
auto transposeOut = std::make_shared<ov::opset10::Transpose>(concat, transposeOutOrder);
|
||||
@@ -313,7 +313,7 @@ struct ConvConcatConcatNHWCAxis {
|
||||
|
||||
concat1Inputs.push_back(transposeOut1);
|
||||
concat1Inputs.push_back(transposeOut2);
|
||||
auto concat1 = ngraph::builder::makeConcat(concat1Inputs, 2);
|
||||
auto concat1 = std::make_shared<ov::op::v0::Concat>(concat1Inputs, 2);
|
||||
auto squeeze = std::make_shared<ov::opset10::Squeeze>(
|
||||
concat1,
|
||||
ov::opset10::Constant::create(ov::element::i64, ov::Shape{2}, {0, 1}));
|
||||
@@ -324,7 +324,7 @@ struct ConvConcatConcatNHWCAxis {
|
||||
|
||||
concat2Inputs.push_back(squeeze);
|
||||
concat2Inputs.push_back(constNode);
|
||||
auto concat2 = ngraph::builder::makeConcat(concat2Inputs, axis);
|
||||
auto concat2 = std::make_shared<ov::op::v0::Concat>(concat2Inputs, axis);
|
||||
auto reshape = std::make_shared<ov::opset10::Reshape>(
|
||||
concat2,
|
||||
ov::opset10::Constant::create(ov::element::i64,
|
||||
@@ -424,7 +424,7 @@ struct TransposeTransposeConcat {
|
||||
auto transpose_r2 = make_shared<Transpose>(reshape_r3, transpose_r2_const);
|
||||
|
||||
// Concat
|
||||
auto concat = makeConcat({transpose_l1, transpose_r2}, 0);
|
||||
auto concat = std::make_shared<ov::op::v0::Concat>(ov::NodeVector{transpose_l1, transpose_r2}, 0);
|
||||
|
||||
auto width_after_conv = (conv_input_shape[3] - kernel_shape[1]) + 1;
|
||||
auto reshape_const =
|
||||
|
||||
@@ -145,6 +145,7 @@ protected:
|
||||
node_before_pooling = reshapeNode2;
|
||||
}
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
auto maxpool = ngraph::builder::makePooling(node_before_pooling,
|
||||
{1, 2},
|
||||
{0, 0},
|
||||
@@ -154,6 +155,7 @@ protected:
|
||||
ngraph::op::PadType::VALID,
|
||||
false,
|
||||
ngraph::helpers::PoolingTypes::MAX);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(maxpool)};
|
||||
function = std::make_shared<ngraph::Function>(results, inputVector, "FQMaxPoolReorder");
|
||||
|
||||
@@ -185,6 +185,7 @@ protected:
|
||||
filter_weights_1);
|
||||
size_t out_width = ((inputShape[3] - kernal_size) / stride_size + 1);
|
||||
size_t out_height = ((inputShape[2] - 1) + 1);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
auto pool = ngraph::builder::makePooling(conv1,
|
||||
{1, 2},
|
||||
{0, 0},
|
||||
@@ -194,6 +195,7 @@ protected:
|
||||
ngraph::op::PadType::VALID,
|
||||
false,
|
||||
ngraph::helpers::PoolingTypes::MAX);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
out_width /= 2;
|
||||
|
||||
ngraph::Shape pattern2_shape = {1, 1, 1, num_out_channels * out_height * out_width};
|
||||
|
||||
+3
-1
@@ -111,6 +111,7 @@ std::shared_ptr<ngraph::Node> CreateConvolution(const ngraph::Output<ngraph::Nod
|
||||
}
|
||||
|
||||
auto pool_kernal_shape = GetKernelShape(GetLayerTransposedOutputShape(conv), 2, false);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
auto pool = ngraph::builder::makePooling(conv,
|
||||
pool_kernal_shape,
|
||||
std::vector<size_t>(shape_size - 2, 0),
|
||||
@@ -120,6 +121,7 @@ std::shared_ptr<ngraph::Node> CreateConvolution(const ngraph::Output<ngraph::Nod
|
||||
ngraph::op::PadType::VALID,
|
||||
false,
|
||||
ngraph::helpers::PoolingTypes::MAX);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
return withActivation ? std::make_shared<ngraph::opset3::Relu>(pool) : pool;
|
||||
}
|
||||
|
||||
@@ -616,7 +618,7 @@ protected:
|
||||
ngraph::Shape{1, conv2_out_size});
|
||||
auto reshape2 = std::make_shared<ngraph::opset1::Reshape>(permute2, pattern2, false);
|
||||
|
||||
auto concat = ngraph::builder::makeConcat({reshape1, reshape2}, 1);
|
||||
auto concat = std::make_shared<ov::op::v0::Concat>(ov::NodeVector{reshape1, reshape2}, 1);
|
||||
|
||||
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(concat)};
|
||||
function = std::make_shared<ngraph::Function>(results, params, "RemoveSharedPermutationTest");
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ protected:
|
||||
ngraph::opset8::Constant::create(ngraph::element::f32, {1}, {-10.}),
|
||||
ngraph::opset8::Constant::create(ngraph::element::f32, {1}, {10.}),
|
||||
static_cast<uint32_t>(std::numeric_limits<uint16_t>::max()) + 1);
|
||||
auto concat = ngraph::builder::makeConcat({fq1, fq2}, 1);
|
||||
auto concat = std::make_shared<ov::op::v0::Concat>(ov::NodeVector{fq1, fq2}, 1);
|
||||
function = std::make_shared<ngraph::Function>(concat, params, "WeighableLayerWithoutFq");
|
||||
}
|
||||
}; // class WeighableLayerWithoutFqTest
|
||||
|
||||
@@ -144,6 +144,7 @@ void GNAPWLExtraSegmentsTestFixture::SetUp() {
|
||||
std::shared_ptr<Result> result = nullptr;
|
||||
|
||||
if (use_pooling) {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
auto maxpool = ngraph::builder::makePooling(activation,
|
||||
stride,
|
||||
pad_begin_pool,
|
||||
@@ -153,6 +154,7 @@ void GNAPWLExtraSegmentsTestFixture::SetUp() {
|
||||
PadType::VALID,
|
||||
false,
|
||||
ngraph::helpers::PoolingTypes::MAX);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
result = std::make_shared<Result>(maxpool);
|
||||
} else {
|
||||
result = std::make_shared<Result>(activation);
|
||||
|
||||
@@ -340,6 +340,7 @@ TEST_F(GNAMemoryOrderTest, orderingFusedLayersMaxPool) {
|
||||
|
||||
auto input = std::make_shared<ngraph::opset8::Parameter>(ov::element::f32, input_shape);
|
||||
auto conv = std::make_shared<ngraph::opset8::Convolution>(input, weights, strides, pad_begin, pad_end, dilations);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
auto maxpool = ngraph::builder::makePooling(conv,
|
||||
{1, 1},
|
||||
{0, 0},
|
||||
@@ -349,6 +350,7 @@ TEST_F(GNAMemoryOrderTest, orderingFusedLayersMaxPool) {
|
||||
ngraph::op::PadType::VALID,
|
||||
false,
|
||||
ngraph::helpers::PoolingTypes::MAX);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
auto result = std::make_shared<ngraph::opset8::Result>(maxpool);
|
||||
auto function =
|
||||
std::make_shared<ov::Model>(ov::ResultVector({result}), ov::ParameterVector({input}), "convolution");
|
||||
@@ -371,6 +373,7 @@ TEST_F(GNAMemoryOrderTest, orderingFusedLayersActivationMaxPool) {
|
||||
auto conv = std::make_shared<ngraph::opset8::Convolution>(input, weights, strides, pad_begin, pad_end, dilations);
|
||||
auto activation =
|
||||
ngraph::builder::makeActivation(conv, ov::element::f32, ngraph::helpers::ActivationTypes::Sigmoid);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
auto maxpool = ngraph::builder::makePooling(activation,
|
||||
{1, 1},
|
||||
{0, 0},
|
||||
@@ -380,6 +383,7 @@ TEST_F(GNAMemoryOrderTest, orderingFusedLayersActivationMaxPool) {
|
||||
ngraph::op::PadType::VALID,
|
||||
false,
|
||||
ngraph::helpers::PoolingTypes::MAX);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
auto result = std::make_shared<ngraph::opset8::Result>(maxpool);
|
||||
auto function =
|
||||
std::make_shared<ov::Model>(ov::ResultVector({result}), ov::ParameterVector({input}), "convolution");
|
||||
|
||||
@@ -640,7 +640,7 @@ public:
|
||||
auto relu = make_shared<Relu>(fq);
|
||||
auto reshape_const = make_shared<Constant>(i64, Shape{1}, m_input_shape);
|
||||
auto reshape = make_shared<Reshape>(inputs[1], reshape_const, false);
|
||||
auto concat = makeConcat({relu, reshape}, 0);
|
||||
auto concat = std::make_shared<ov::op::v0::Concat>(ov::NodeVector{relu, reshape}, 0);
|
||||
auto result = make_shared<Result>(concat);
|
||||
m_func = make_shared<Model>(result, inputs, getName());
|
||||
}
|
||||
@@ -654,7 +654,7 @@ public:
|
||||
auto reshape = make_shared<Reshape>(inputs[1], reshape_const, false);
|
||||
// We expect the following Identity layer to be inserted
|
||||
auto identity = make_shared<Identity>(reshape);
|
||||
auto concat = makeConcat({relu, identity}, 0);
|
||||
auto concat = std::make_shared<ov::op::v0::Concat>(ov::NodeVector{relu, identity}, 0);
|
||||
auto result = make_shared<Result>(concat);
|
||||
m_ref_func = make_shared<Model>(result, inputs, getName());
|
||||
}
|
||||
|
||||
@@ -55,8 +55,7 @@ void RemoveInputConvertTest::SetUp() {
|
||||
// test function
|
||||
{
|
||||
auto params = std::make_shared<ngraph::opset8::Parameter>(target_precision_, input_shape);
|
||||
auto conversion =
|
||||
ngraph::builder::makeConversion(params, net_precision_, ngraph::helpers::ConversionTypes::CONVERT);
|
||||
auto conversion = std::make_shared<ov::op::v0::Convert>(params, net_precision_);
|
||||
auto add_const = ngraph::opset8::Constant::create(net_precision_, input_shape, {10});
|
||||
auto add = std::make_shared<ngraph::opset8::Add>(conversion, add_const);
|
||||
|
||||
@@ -115,8 +114,7 @@ public:
|
||||
auto params = std::make_shared<ngraph::opset8::Parameter>(net_precision_, input_shape);
|
||||
auto add_const = ngraph::opset8::Constant::create(net_precision_, input_shape, {10});
|
||||
auto add = std::make_shared<ngraph::opset8::Add>(params, add_const);
|
||||
auto conversion =
|
||||
ngraph::builder::makeConversion(add, target_precision_, ngraph::helpers::ConversionTypes::CONVERT);
|
||||
auto conversion = std::make_shared<ov::op::v0::Convert>(add, target_precision_);
|
||||
auto result = std::make_shared<ngraph::opset8::Result>(conversion);
|
||||
func_ = std::make_shared<ngraph::Function>(ngraph::ResultVector{result},
|
||||
ngraph::ParameterVector{params},
|
||||
@@ -172,8 +170,7 @@ public:
|
||||
auto params = std::make_shared<ngraph::opset8::Parameter>(net_precision_, input_shape);
|
||||
auto add_const = ngraph::opset8::Constant::create(net_precision_, input_shape, {10});
|
||||
auto add1 = std::make_shared<ngraph::opset8::Add>(params, add_const);
|
||||
auto conversion =
|
||||
ngraph::builder::makeConversion(add1, net_precision_, ngraph::helpers::ConversionTypes::CONVERT);
|
||||
auto conversion = std::make_shared<ov::op::v0::Convert>(add1, net_precision_);
|
||||
auto add2 = std::make_shared<ngraph::opset8::Add>(conversion, add_const);
|
||||
auto result = std::make_shared<ngraph::opset8::Result>(add2);
|
||||
func_ = std::make_shared<ngraph::Function>(ngraph::ResultVector{result},
|
||||
@@ -210,12 +207,9 @@ public:
|
||||
ov::ParameterVector input{std::make_shared<ov::op::v0::Parameter>(target_precision_, input_shape),
|
||||
std::make_shared<ov::op::v0::Parameter>(target_precision_, input_shape),
|
||||
std::make_shared<ov::op::v0::Parameter>(target_precision_, input_shape)};
|
||||
auto convert1 =
|
||||
ngraph::builder::makeConversion(input[0], net_precision_, ngraph::helpers::ConversionTypes::CONVERT);
|
||||
auto convert2 =
|
||||
ngraph::builder::makeConversion(input[1], net_precision_, ngraph::helpers::ConversionTypes::CONVERT);
|
||||
auto convert3 =
|
||||
ngraph::builder::makeConversion(input[2], net_precision_, ngraph::helpers::ConversionTypes::CONVERT);
|
||||
auto convert1 = std::make_shared<ov::op::v0::Convert>(input[0], net_precision_);
|
||||
auto convert2 = std::make_shared<ov::op::v0::Convert>(input[1], net_precision_);
|
||||
auto convert3 = std::make_shared<ov::op::v0::Convert>(input[2], net_precision_);
|
||||
auto mul1 = ngraph::builder::makeEltwise(convert1, convert2, ngraph::helpers::EltwiseTypes::ADD);
|
||||
auto mul2 = ngraph::builder::makeEltwise(convert3, mul1, ngraph::helpers::EltwiseTypes::ADD);
|
||||
auto result = std::make_shared<ngraph::opset8::Result>(mul2);
|
||||
@@ -252,10 +246,8 @@ public:
|
||||
std::make_shared<ov::op::v0::Parameter>(net_precision_, input_shape)};
|
||||
auto mul1 = ngraph::builder::makeEltwise(input[0], input[1], ngraph::helpers::EltwiseTypes::ADD);
|
||||
auto mul2 = ngraph::builder::makeEltwise(input[2], input[3], ngraph::helpers::EltwiseTypes::ADD);
|
||||
auto convert1 =
|
||||
ngraph::builder::makeConversion(mul1, target_precision_, ngraph::helpers::ConversionTypes::CONVERT);
|
||||
auto convert2 =
|
||||
ngraph::builder::makeConversion(mul2, target_precision_, ngraph::helpers::ConversionTypes::CONVERT);
|
||||
auto convert1 = std::make_shared<ov::op::v0::Convert>(mul1, target_precision_);
|
||||
auto convert2 = std::make_shared<ov::op::v0::Convert>(mul2, target_precision_);
|
||||
auto result1 = std::make_shared<ngraph::opset8::Result>(convert1);
|
||||
auto result2 = std::make_shared<ngraph::opset8::Result>(convert2);
|
||||
|
||||
@@ -297,12 +289,9 @@ public:
|
||||
auto mul1 = ngraph::builder::makeEltwise(input[0], input[1], ngraph::helpers::EltwiseTypes::ADD);
|
||||
auto mul2 = ngraph::builder::makeEltwise(input[2], input[3], ngraph::helpers::EltwiseTypes::ADD);
|
||||
auto mul3 = ngraph::builder::makeEltwise(mul1, mul2, ngraph::helpers::EltwiseTypes::ADD);
|
||||
auto convert1 =
|
||||
ngraph::builder::makeConversion(mul1, target_precision_, ngraph::helpers::ConversionTypes::CONVERT);
|
||||
auto convert2 =
|
||||
ngraph::builder::makeConversion(mul2, target_precision_, ngraph::helpers::ConversionTypes::CONVERT);
|
||||
auto convert3 =
|
||||
ngraph::builder::makeConversion(mul3, target_precision_, ngraph::helpers::ConversionTypes::CONVERT);
|
||||
auto convert1 = std::make_shared<ov::op::v0::Convert>(mul1, target_precision_);
|
||||
auto convert2 = std::make_shared<ov::op::v0::Convert>(mul2, target_precision_);
|
||||
auto convert3 = std::make_shared<ov::op::v0::Convert>(mul3, target_precision_);
|
||||
auto result1 = std::make_shared<ngraph::opset8::Result>(convert1);
|
||||
auto result2 = std::make_shared<ngraph::opset8::Result>(convert2);
|
||||
auto result3 = std::make_shared<ngraph::opset8::Result>(convert3);
|
||||
|
||||
Reference in new issue
Block a user