Run IR models via TestCase (#4964)
This commit is contained in:
parent
b55be5594b
commit
3b0c6aa408
0
ngraph/test/models/ir/add_abc.bin
Normal file
0
ngraph/test/models/ir/add_abc.bin
Normal file
75
ngraph/test/models/ir/add_abc.xml
Normal file
75
ngraph/test/models/ir/add_abc.xml
Normal file
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" ?>
|
||||
<net name="add_abc" version="10">
|
||||
<layers>
|
||||
<layer id="0" name="A" type="Parameter" version="opset1">
|
||||
<data element_type="f32" shape="1"/>
|
||||
<output>
|
||||
<port id="0" names="A" precision="FP32">
|
||||
<dim>1</dim>
|
||||
</port>
|
||||
</output>
|
||||
</layer>
|
||||
<layer id="1" name="B" type="Parameter" version="opset1">
|
||||
<data element_type="f32" shape="1"/>
|
||||
<output>
|
||||
<port id="0" names="B" precision="FP32">
|
||||
<dim>1</dim>
|
||||
</port>
|
||||
</output>
|
||||
</layer>
|
||||
<layer id="2" name="add_node1" type="Add" version="opset1">
|
||||
<data auto_broadcast="numpy"/>
|
||||
<input>
|
||||
<port id="0">
|
||||
<dim>1</dim>
|
||||
</port>
|
||||
<port id="1">
|
||||
<dim>1</dim>
|
||||
</port>
|
||||
</input>
|
||||
<output>
|
||||
<port id="2" names="X" precision="FP32">
|
||||
<dim>1</dim>
|
||||
</port>
|
||||
</output>
|
||||
</layer>
|
||||
<layer id="3" name="C" type="Parameter" version="opset1">
|
||||
<data element_type="f32" shape="1"/>
|
||||
<output>
|
||||
<port id="0" names="C" precision="FP32">
|
||||
<dim>1</dim>
|
||||
</port>
|
||||
</output>
|
||||
</layer>
|
||||
<layer id="4" name="Y" type="Add" version="opset1">
|
||||
<data auto_broadcast="numpy"/>
|
||||
<input>
|
||||
<port id="0">
|
||||
<dim>1</dim>
|
||||
</port>
|
||||
<port id="1">
|
||||
<dim>1</dim>
|
||||
</port>
|
||||
</input>
|
||||
<output>
|
||||
<port id="2" names="Y" precision="FP32">
|
||||
<dim>1</dim>
|
||||
</port>
|
||||
</output>
|
||||
</layer>
|
||||
<layer id="5" name="Y/sink_port_0" type="Result" version="opset1">
|
||||
<input>
|
||||
<port id="0">
|
||||
<dim>1</dim>
|
||||
</port>
|
||||
</input>
|
||||
</layer>
|
||||
</layers>
|
||||
<edges>
|
||||
<edge from-layer="0" from-port="0" to-layer="2" to-port="0"/>
|
||||
<edge from-layer="1" from-port="0" to-layer="2" to-port="1"/>
|
||||
<edge from-layer="2" from-port="2" to-layer="4" to-port="0"/>
|
||||
<edge from-layer="3" from-port="0" to-layer="4" to-port="1"/>
|
||||
<edge from-layer="4" from-port="2" to-layer="5" to-port="0"/>
|
||||
</edges>
|
||||
</net>
|
0
ngraph/test/models/ir/weights/add_abc.bin
Normal file
0
ngraph/test/models/ir/weights/add_abc.bin
Normal file
@ -23,6 +23,7 @@
|
||||
using namespace ngraph;
|
||||
|
||||
static std::string s_manifest = "${MANIFEST}";
|
||||
using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
|
||||
|
||||
template <typename T>
|
||||
class ElemTypesTests : public ::testing::Test
|
||||
@ -32,7 +33,6 @@ TYPED_TEST_CASE_P(ElemTypesTests);
|
||||
|
||||
TYPED_TEST_P(ElemTypesTests, onnx_test_add_abc_set_precission)
|
||||
{
|
||||
using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
|
||||
using DataType = TypeParam;
|
||||
const element::Type ng_type = element::from<DataType>();
|
||||
|
||||
@ -53,7 +53,6 @@ TYPED_TEST_P(ElemTypesTests, onnx_test_add_abc_set_precission)
|
||||
|
||||
TYPED_TEST_P(ElemTypesTests, onnx_test_split_multioutput_set_precission)
|
||||
{
|
||||
using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
|
||||
using DataType = TypeParam;
|
||||
const element::Type ng_type = element::from<DataType>();
|
||||
|
||||
@ -77,3 +76,30 @@ REGISTER_TYPED_TEST_CASE_P(ElemTypesTests,
|
||||
onnx_test_split_multioutput_set_precission);
|
||||
typedef ::testing::Types<int8_t, int16_t, int32_t, uint8_t, float> ElemTypes;
|
||||
INSTANTIATE_TYPED_TEST_CASE_P(${BACKEND_NAME}, ElemTypesTests, ElemTypes);
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, add_abc_from_ir) {
|
||||
const auto ir_xml = file_util::path_join(SERIALIZED_ZOO, "ir/add_abc.xml");
|
||||
const auto function = test::function_from_ir(ir_xml);
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(function);
|
||||
test_case.add_input<float>({1});
|
||||
test_case.add_input<float>({2});
|
||||
test_case.add_input<float>({3});
|
||||
test_case.add_expected_output<float>(Shape{1}, {6});
|
||||
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, add_abc_from_ir_with_bin_path) {
|
||||
const auto ir_xml = file_util::path_join(SERIALIZED_ZOO, "ir/add_abc.xml");
|
||||
const auto ir_bin = file_util::path_join(SERIALIZED_ZOO, "ir/weights/add_abc.bin");
|
||||
const auto function = test::function_from_ir(ir_xml, ir_bin);
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(function);
|
||||
test_case.add_input<float>({1});
|
||||
test_case.add_input<float>({2});
|
||||
test_case.add_input<float>({3});
|
||||
test_case.add_expected_output<float>(Shape{1}, {6});
|
||||
|
||||
test_case.run();
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ set (SRC
|
||||
engine/shared_utils.cpp
|
||||
float_util.cpp
|
||||
test_tools.cpp
|
||||
test_case.cpp
|
||||
test_control.cpp
|
||||
visitor.hpp
|
||||
provenance_enabler.hpp
|
||||
|
21
ngraph/test/util/test_case.cpp
Normal file
21
ngraph/test/util/test_case.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <ie_core.hpp>
|
||||
|
||||
#include "test_case.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
namespace test
|
||||
{
|
||||
std::shared_ptr<Function> function_from_ir(const std::string& xml_path,
|
||||
const std::string& bin_path)
|
||||
{
|
||||
InferenceEngine::Core c;
|
||||
auto network = c.ReadNetwork(xml_path, bin_path);
|
||||
return network.getFunction();
|
||||
}
|
||||
}
|
||||
}
|
@ -17,6 +17,9 @@ namespace ngraph
|
||||
{
|
||||
namespace test
|
||||
{
|
||||
std::shared_ptr<Function> function_from_ir(const std::string& xml_path,
|
||||
const std::string& bin_path = {});
|
||||
|
||||
template <typename Engine, TestCaseType tct = TestCaseType::STATIC>
|
||||
class TestCase
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user