Added new tests for tensors element types (#9667)

This commit is contained in:
Ilya Churaev
2022-01-14 22:59:08 +03:00
committed by GitHub
parent 5ad242ecce
commit 3d4e82dcd1
5 changed files with 137 additions and 0 deletions

View File

@@ -19,4 +19,52 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestIOTensorTest,
::testing::ValuesIn(configs)),
OVInferRequestIOTensorTest::getTestCaseName);
std::vector<ov::element::Type> prcs = {
ov::element::boolean,
ov::element::bf16,
ov::element::f16,
ov::element::f32,
ov::element::f64,
ov::element::i4,
ov::element::i8,
ov::element::i16,
ov::element::i32,
ov::element::i64,
ov::element::u1,
ov::element::u4,
ov::element::u8,
ov::element::u16,
ov::element::u32,
ov::element::u64,
};
const std::vector<std::map<std::string, std::string>> emptyConfigs = {{}};
const std::vector<std::map<std::string, std::string>> HeteroConfigs = {
{{"TARGET_FALLBACK", CommonTestUtils::DEVICE_TEMPLATE}}};
const std::vector<std::map<std::string, std::string>> Multiconfigs = {
{{ MULTI_CONFIG_KEY(DEVICE_PRIORITIES) , CommonTestUtils::DEVICE_TEMPLATE}}
};
INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestCheckTensorPrecision,
::testing::Combine(
::testing::ValuesIn(prcs),
::testing::Values(CommonTestUtils::DEVICE_TEMPLATE),
::testing::ValuesIn(emptyConfigs)),
OVInferRequestCheckTensorPrecision::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Hetero_BehaviorTests, OVInferRequestCheckTensorPrecision,
::testing::Combine(
::testing::ValuesIn(prcs),
::testing::Values(CommonTestUtils::DEVICE_HETERO),
::testing::ValuesIn(HeteroConfigs)),
OVInferRequestCheckTensorPrecision::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, OVInferRequestCheckTensorPrecision,
::testing::Combine(
::testing::ValuesIn(prcs),
::testing::Values(CommonTestUtils::DEVICE_MULTI),
::testing::ValuesIn(Multiconfigs)),
OVInferRequestCheckTensorPrecision::getTestCaseName);
} // namespace

View File

@@ -23,6 +23,8 @@ const std::vector<std::map<std::string, std::string>> Autoconfigs = {
{{ MULTI_CONFIG_KEY(DEVICE_PRIORITIES) , CommonTestUtils::DEVICE_CPU}}
};
const std::vector<std::map<std::string, std::string>> emptyConfigs = {{}};
INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestIOTensorTest,
::testing::Combine(
::testing::Values(CommonTestUtils::DEVICE_CPU),
@@ -81,4 +83,24 @@ INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, OVInferRequestIOTensorSetPrec
::testing::ValuesIn(Autoconfigs)),
OVInferRequestIOTensorSetPrecisionTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestCheckTensorPrecision,
::testing::Combine(
::testing::ValuesIn(prcs),
::testing::Values(CommonTestUtils::DEVICE_CPU),
::testing::ValuesIn(emptyConfigs)),
OVInferRequestCheckTensorPrecision::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, OVInferRequestCheckTensorPrecision,
::testing::Combine(
::testing::ValuesIn(prcs),
::testing::Values(CommonTestUtils::DEVICE_MULTI),
::testing::ValuesIn(Multiconfigs)),
OVInferRequestCheckTensorPrecision::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, OVInferRequestCheckTensorPrecision,
::testing::Combine(
::testing::ValuesIn(prcs),
::testing::Values(CommonTestUtils::DEVICE_AUTO),
::testing::ValuesIn(Autoconfigs)),
OVInferRequestCheckTensorPrecision::getTestCaseName);
} // namespace

View File

@@ -172,6 +172,8 @@ std::vector<std::string> disabledTestPatterns() {
R"(smoke_ConversionLayerTest/ConversionLayerTest.CompareWithRefs.*UNSPECIFIED.*)",
// Issue:
R"(.*smoke_VariadicSplit4D_CPU_zero_dims.*)",
// New API tensor tests
R"(.*OVInferRequestCheckTensorPrecision.*)",
// Issue: 75022
R"(.*OVExecutableNetworkBaseTest.*LoadNetworkToDefaultDeviceNoThrow.*)",
R"(.*IEClassBasicTest.*LoadNetworkToDefaultDeviceNoThrow.*)",

View File

@@ -41,6 +41,24 @@ struct OVInferRequestIOTensorSetPrecisionTest : public testing::WithParamInterfa
runtime::ConfigMap config;
element::Type element_type;
};
using OVInferRequestCheckTensorPrecisionParams = OVInferRequestSetPrecisionParams;
struct OVInferRequestCheckTensorPrecision : public testing::WithParamInterface<OVInferRequestCheckTensorPrecisionParams>,
public CommonTestUtils::TestsCommon {
static std::string getTestCaseName(const testing::TestParamInfo<OVInferRequestCheckTensorPrecisionParams>& obj);
void SetUp() override;
void TearDown() override;
std::shared_ptr<ov::runtime::Core> core = utils::PluginCache::get().core();
std::shared_ptr<ov::Model> model;
runtime::CompiledModel compModel;
runtime::InferRequest req;
runtime::ConfigMap config;
std::string target_device;
element::Type element_type;
};
} // namespace behavior
} // namespace test
} // namespace ov

View File

@@ -8,6 +8,9 @@
#include "shared_test_classes/subgraph/basic_lstm.hpp"
#include "behavior/ov_infer_request/io_tensor.hpp"
#include "functional_test_utils/ov_tensor_utils.hpp"
#include "openvino/op/parameter.hpp"
#include "openvino/op/concat.hpp"
#include "openvino/op/result.hpp"
namespace ov {
namespace test {
@@ -228,6 +231,50 @@ TEST_P(OVInferRequestIOTensorSetPrecisionTest, CanSetOutBlobWithDifferentPrecisi
}
}
std::string OVInferRequestCheckTensorPrecision::getTestCaseName(const testing::TestParamInfo<OVInferRequestCheckTensorPrecisionParams>& obj) {
element::Type type;
std::string targetDevice;
std::map<std::string, std::string> configuration;
std::tie(type, targetDevice, configuration) = obj.param;
std::ostringstream result;
result << "type=" << type << "_";
result << "targetDevice=" << targetDevice << "_";
if (!configuration.empty()) {
using namespace CommonTestUtils;
for (auto &configItem : configuration) {
result << "configItem=" << configItem.first << "_" << configItem.second << "_";
}
}
return result.str();
}
void OVInferRequestCheckTensorPrecision::SetUp() {
SKIP_IF_CURRENT_TEST_IS_DISABLED()
std::tie(element_type, target_device, config) = this->GetParam();
{
auto parameter1 = std::make_shared<ov::op::v0::Parameter>(element_type, ov::PartialShape{1, 3, 2, 2});
auto parameter2 = std::make_shared<ov::op::v0::Parameter>(element_type, ov::PartialShape{1, 3, 2, 2});
auto concat = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{parameter1, parameter2}, 1);
auto result = std::make_shared<ov::op::v0::Result>(concat);
model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{parameter1, parameter2});
}
compModel = core->compile_model(model, target_device, config);
req = compModel.create_infer_request();
}
void OVInferRequestCheckTensorPrecision::TearDown() {
compModel = {};
req = {};
}
TEST_P(OVInferRequestCheckTensorPrecision, CheckInputsOutputs) {
EXPECT_EQ(element_type, compModel.input(0).get_element_type());
EXPECT_EQ(element_type, compModel.input(1).get_element_type());
EXPECT_EQ(element_type, compModel.output().get_element_type());
EXPECT_EQ(element_type, req.get_input_tensor(0).get_element_type());
EXPECT_EQ(element_type, req.get_input_tensor(1).get_element_type());
EXPECT_EQ(element_type, req.get_output_tensor().get_element_type());
}
} // namespace behavior
} // namespace test
} // namespace ov