Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into itikhono/transfor…
Browse files Browse the repository at this point in the history
…mations/ngraph_to_ov_refactoring
  • Loading branch information
itikhono committed Oct 4, 2023
2 parents cab83af + 3b8ac28 commit edbab1f
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,38 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "subgraph_tests/constant_result.hpp"

#include <vector>

#include "subgraph_tests/constant_result.hpp"
#include "common_test_utils/test_constants.hpp"

using namespace SubgraphTestsDefinitions;
using namespace InferenceEngine;
using namespace ov::test;

namespace {

const std::vector<ConstantSubgraphType> types = {
ConstantSubgraphType::SINGLE_COMPONENT,
ConstantSubgraphType::SEVERAL_COMPONENT
};

const std::vector<SizeVector> shapes = {
{1, 3, 10, 10},
{2, 3, 4, 5}
};

const std::vector<Precision> precisions = {
Precision::U8,
Precision::I8,
Precision::U16,
Precision::I16,
Precision::I32,
Precision::U64,
Precision::I64,
Precision::FP32,
Precision::BOOL
};

INSTANTIATE_TEST_SUITE_P(smoke_Check, ConstantResultSubgraphTest,
::testing::Combine(
::testing::ValuesIn(types),
::testing::ValuesIn(shapes),
::testing::ValuesIn(precisions),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ConstantResultSubgraphTest::getTestCaseName);

} // namespace
const std::vector<ConstantSubgraphType> types = {ConstantSubgraphType::SINGLE_COMPONENT,
ConstantSubgraphType::SEVERAL_COMPONENT};

const std::vector<ov::Shape> shapes = {{1, 3, 10, 10}, {2, 3, 4, 5}};

const std::vector<ov::element::Type> precisions = {ov::element::u8,
ov::element::i8,
ov::element::u16,
ov::element::i16,
ov::element::u32,
ov::element::i32,
ov::element::u64,
ov::element::i64,
ov::element::f32,
ov::element::boolean};

INSTANTIATE_TEST_SUITE_P(smoke_Check,
ConstantResultSubgraphTest,
::testing::Combine(::testing::ValuesIn(types),
::testing::ValuesIn(shapes),
::testing::ValuesIn(precisions),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ConstantResultSubgraphTest::getTestCaseName);

} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "subgraph_tests/constant_result.hpp"

#include <vector>

#include "common_test_utils/test_constants.hpp"
#include "subgraph_tests/constant_result_legacy.hpp"

using namespace SubgraphTestsDefinitions;
using namespace InferenceEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <vector>

#include "subgraph_tests/constant_result.hpp"
#include "subgraph_tests/constant_result_legacy.hpp"
#include "common_test_utils/test_constants.hpp"

using namespace SubgraphTestsDefinitions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

#include "shared_test_classes/subgraph/constant_result.hpp"

namespace SubgraphTestsDefinitions {
namespace ov {
namespace test {

TEST_P(ConstantResultSubgraphTest, CompareWithRefs) {
Run();
run();
}

} // namespace SubgraphTestsDefinitions

} // namespace test
} // namespace ov
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include "shared_test_classes/subgraph/constant_result.hpp"

namespace SubgraphTestsDefinitions {

TEST_P(ConstantResultSubgraphTest, CompareWithRefs) {
Run();
}

} // namespace SubgraphTestsDefinitions
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,63 @@

#pragma once

#include <tuple>
#include <memory>
#include <string>
#include <tuple>
#include <vector>
#include <memory>

#include "openvino/core/type/element_type.hpp"
#include "shared_test_classes/base/layer_test_utils.hpp"
#include "ov_models/builders.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"

namespace SubgraphTestsDefinitions {
namespace ov {
namespace test {

enum class ConstantSubgraphType { SINGLE_COMPONENT, SEVERAL_COMPONENT };

std::ostream& operator<<(std::ostream& os, ConstantSubgraphType type);

typedef std::tuple<ConstantSubgraphType,
ov::Shape, // input shape
ov::element::Type, // input element type
std::string // Device name
>
constResultParams;

class ConstantResultSubgraphTest : public testing::WithParamInterface<constResultParams>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<constResultParams>& obj);
void createGraph(const ConstantSubgraphType& type,
const ov::Shape& input_shape,
const ov::element::Type& input_type);

enum class ConstantSubgraphType {
SINGLE_COMPONENT,
SEVERAL_COMPONENT
protected:
void SetUp() override;
};

std::ostream& operator<<(std::ostream &os, ConstantSubgraphType type);
} // namespace test
} // namespace ov

typedef std::tuple <
ConstantSubgraphType,
InferenceEngine::SizeVector, // input shape
InferenceEngine::Precision, // input precision
std::string // Device name
> constResultParams;
namespace SubgraphTestsDefinitions {

using ov::test::ConstantSubgraphType;

typedef std::tuple<ConstantSubgraphType,
InferenceEngine::SizeVector, // input shape
InferenceEngine::Precision, // input precision
std::string // Device name
>
constResultParams;

class ConstantResultSubgraphTest : public testing::WithParamInterface<constResultParams>,
virtual public LayerTestsUtils::LayerTestsCommon {
public:
static std::string getTestCaseName(const testing::TestParamInfo<constResultParams>& obj);
void createGraph(const ConstantSubgraphType& type, const InferenceEngine::SizeVector &inputShape, const InferenceEngine::Precision &inputPrecision);
void createGraph(const ConstantSubgraphType& type,
const InferenceEngine::SizeVector& inputShape,
const InferenceEngine::Precision& inputPrecision);

protected:
void SetUp() override;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,84 @@

#include "shared_test_classes/subgraph/constant_result.hpp"

using namespace InferenceEngine;
using namespace ngraph;
#include "ov_models/builders.hpp"
#include "openvino/op/result.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"

namespace SubgraphTestsDefinitions {
namespace ov {
namespace test {

std::ostream& operator<<(std::ostream &os, ConstantSubgraphType type) {
std::ostream& operator<<(std::ostream& os, ConstantSubgraphType type) {
switch (type) {
case ConstantSubgraphType::SINGLE_COMPONENT:
os << "SINGLE_COMPONENT";
break;
case ConstantSubgraphType::SEVERAL_COMPONENT:
os << "SEVERAL_COMPONENT";
break;
default:
os << "UNSUPPORTED_CONST_SUBGRAPH_TYPE";
case ConstantSubgraphType::SINGLE_COMPONENT:
os << "SINGLE_COMPONENT";
break;
case ConstantSubgraphType::SEVERAL_COMPONENT:
os << "SEVERAL_COMPONENT";
break;
default:
os << "UNSUPPORTED_CONST_SUBGRAPH_TYPE";
}
return os;
}

std::string ConstantResultSubgraphTest::getTestCaseName(const testing::TestParamInfo<constResultParams>& obj) {
ConstantSubgraphType type;
SizeVector IS;
Precision inputPrecision;
ov::Shape input_shape;
ov::element::Type input_type;
std::string target_device;

std::tie(type, input_shape, input_type, target_device) = obj.param;
std::ostringstream result;
result << "SubgraphType=" << type << "_";
result << "IS=" << input_shape << "_";
result << "IT=" << input_type << "_";
result << "Device=" << target_device;
return result.str();
}

void ConstantResultSubgraphTest::createGraph(const ConstantSubgraphType& type,
const ov::Shape& input_shape,
const ov::element::Type& input_type) {
ParameterVector params;
ResultVector results;
switch (type) {
case ConstantSubgraphType::SINGLE_COMPONENT: {
auto input = ngraph::builder::makeConstant<float>(input_type, input_shape, {}, true);
results.push_back(std::make_shared<ov::op::v0::Result>(input));
break;
}
case ConstantSubgraphType::SEVERAL_COMPONENT: {
auto input1 = ngraph::builder::makeConstant<float>(input_type, input_shape, {}, true);
results.push_back(std::make_shared<ov::op::v0::Result>(input1));
auto input2 = ngraph::builder::makeConstant<float>(input_type, input_shape, {}, true);
results.push_back(std::make_shared<ov::op::v0::Result>(input2));
break;
}
default: {
throw std::runtime_error("Unsupported constant graph type");
}
}
function = std::make_shared<ov::Model>(results, params, "ConstResult");
}

void ConstantResultSubgraphTest::SetUp() {
ConstantSubgraphType type;
ov::Shape input_shape;
ov::element::Type input_type;
std::tie(type, input_shape, input_type, targetDevice) = this->GetParam();

createGraph(type, input_shape, input_type);
}
} // namespace test
} // namespace ov

namespace SubgraphTestsDefinitions {

std::string ConstantResultSubgraphTest::getTestCaseName(const testing::TestParamInfo<constResultParams>& obj) {
ConstantSubgraphType type;
InferenceEngine::SizeVector IS;
InferenceEngine::Precision inputPrecision;
std::string targetDevice;

std::tie(type, IS, inputPrecision, targetDevice) = obj.param;
Expand All @@ -38,35 +93,37 @@ std::string ConstantResultSubgraphTest::getTestCaseName(const testing::TestParam
return result.str();
}

void ConstantResultSubgraphTest::createGraph(const ConstantSubgraphType& type, const SizeVector &inputShape, const Precision &inputPrecision) {
void ConstantResultSubgraphTest::createGraph(const ConstantSubgraphType& type,
const InferenceEngine::SizeVector& inputShape,
const InferenceEngine::Precision& inputPrecision) {
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision);

ParameterVector params;
ResultVector results;
ov::ParameterVector params;
ov::ResultVector results;
switch (type) {
case ConstantSubgraphType::SINGLE_COMPONENT: {
auto input = builder::makeConstant<float>(ngPrc, inputShape, {}, true);
results.push_back(std::make_shared<opset3::Result>(input));
break;
}
case ConstantSubgraphType::SEVERAL_COMPONENT: {
auto input1 = builder::makeConstant<float>(ngPrc, inputShape, {}, true);
results.push_back(std::make_shared<opset3::Result>(input1));
auto input2 = builder::makeConstant<float>(ngPrc, inputShape, {}, true);
results.push_back(std::make_shared<opset3::Result>(input2));
break;
}
default: {
throw std::runtime_error("Unsupported constant graph type");
}
case ConstantSubgraphType::SINGLE_COMPONENT: {
auto input = ngraph::builder::makeConstant<float>(ngPrc, inputShape, {}, true);
results.push_back(std::make_shared<ov::op::v0::Result>(input));
break;
}
case ConstantSubgraphType::SEVERAL_COMPONENT: {
auto input1 = ngraph::builder::makeConstant<float>(ngPrc, inputShape, {}, true);
results.push_back(std::make_shared<ov::op::v0::Result>(input1));
auto input2 = ngraph::builder::makeConstant<float>(ngPrc, inputShape, {}, true);
results.push_back(std::make_shared<ov::op::v0::Result>(input2));
break;
}
default: {
throw std::runtime_error("Unsupported constant graph type");
}
}
function = std::make_shared<Function>(results, params, "ConstResult");
function = std::make_shared<ov::Model>(results, params, "ConstResult");
}

void ConstantResultSubgraphTest::SetUp() {
ConstantSubgraphType type;
SizeVector IS;
Precision inputPrecision;
InferenceEngine::SizeVector IS;
InferenceEngine::Precision inputPrecision;
std::tie(type, IS, inputPrecision, targetDevice) = this->GetParam();

createGraph(type, IS, inputPrecision);
Expand Down

0 comments on commit edbab1f

Please sign in to comment.