Migrate range1,4 to template plugin test (#8023)
* Migrate range1,4 to template plugin test * Fix cpplint issue * Return NULL in default case in range test * Fix cpplint error
This commit is contained in:
parent
f80005f513
commit
e9777a6da0
410
docs/template_plugin/tests/functional/op_reference/range.cpp
Normal file
410
docs/template_plugin/tests/functional/op_reference/range.cpp
Normal file
@ -0,0 +1,410 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "base_reference_test.hpp"
|
||||
#include "openvino/op/range.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
|
||||
using namespace ov;
|
||||
using namespace reference_tests;
|
||||
|
||||
namespace {
|
||||
|
||||
struct RangeParams {
|
||||
template <class IT>
|
||||
RangeParams(const Shape& iShape,
|
||||
const Shape& oShape,
|
||||
const element::Type& iType,
|
||||
const element::Type& oType,
|
||||
const element::Type& nodeType,
|
||||
const std::vector<IT>& oValues,
|
||||
float start,
|
||||
float stop,
|
||||
float step)
|
||||
: inShape(iShape),
|
||||
outShape(oShape),
|
||||
inType(iType),
|
||||
outType(oType),
|
||||
nodeType(nodeType),
|
||||
outData(CreateTensor(oType, oValues)),
|
||||
start(start),
|
||||
stop(stop),
|
||||
step(step) {}
|
||||
|
||||
Shape inShape;
|
||||
Shape outShape;
|
||||
element::Type inType;
|
||||
element::Type outType;
|
||||
element::Type nodeType;
|
||||
runtime::Tensor inData;
|
||||
runtime::Tensor outData;
|
||||
float start;
|
||||
float stop;
|
||||
float step;
|
||||
};
|
||||
|
||||
static std::shared_ptr<op::v0::Constant> CreateConstant(Shape& ishape, element::Type ntype, float input) {
|
||||
switch (ntype) {
|
||||
case element::Type_t::f64:
|
||||
return std::make_shared<op::v0::Constant>(ntype, ishape, std::vector<double>{input});
|
||||
case element::Type_t::f32:
|
||||
return std::make_shared<op::v0::Constant>(ntype, ishape, std::vector<float>{input});
|
||||
case element::Type_t::f16:
|
||||
return std::make_shared<op::v0::Constant>(ntype, ishape, std::vector<float16>{input});
|
||||
case element::Type_t::bf16:
|
||||
return std::make_shared<op::v0::Constant>(ntype, ishape, std::vector<bfloat16>{input});
|
||||
case element::Type_t::i64:
|
||||
return std::make_shared<op::v0::Constant>(ntype, ishape, std::vector<int64_t>{static_cast<int64_t>(input)});
|
||||
case element::Type_t::i32:
|
||||
return std::make_shared<op::v0::Constant>(ntype, ishape, std::vector<int32_t>{static_cast<int16_t>(input)});
|
||||
case element::Type_t::i16:
|
||||
return std::make_shared<op::v0::Constant>(ntype, ishape, std::vector<int16_t>{static_cast<int16_t>(input)});
|
||||
case element::Type_t::i8:
|
||||
return std::make_shared<op::v0::Constant>(ntype, ishape, std::vector<int8_t>{static_cast<int8_t>(input)});
|
||||
case element::Type_t::u64:
|
||||
return std::make_shared<op::v0::Constant>(ntype, ishape, std::vector<uint64_t>{static_cast<uint64_t>(input)});
|
||||
case element::Type_t::u32:
|
||||
return std::make_shared<op::v0::Constant>(ntype, ishape, std::vector<uint32_t>{static_cast<uint32_t>(input)});
|
||||
case element::Type_t::u16:
|
||||
return std::make_shared<op::v0::Constant>(ntype, ishape, std::vector<uint16_t>{static_cast<uint16_t>(input)});
|
||||
case element::Type_t::u8:
|
||||
return std::make_shared<op::v0::Constant>(ntype, ishape, std::vector<uint8_t>{static_cast<uint8_t>(input)});
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
class ReferenceRangeV0LayerTest : public testing::TestWithParam<RangeParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params.inShape,
|
||||
params.outShape,
|
||||
params.inType,
|
||||
params.outType,
|
||||
params.nodeType,
|
||||
params.start,
|
||||
params.stop,
|
||||
params.step);
|
||||
refOutData = {params.outData};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<RangeParams>& obj) {
|
||||
auto param = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "iShape=" << param.inShape << "_";
|
||||
result << "oShape=" << param.outShape << "_";
|
||||
result << "iType=" << param.inType << "_";
|
||||
result << "oType=" << param.outType << "_";
|
||||
result << "nType=" << param.nodeType;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(Shape& ishape,
|
||||
Shape& oshape,
|
||||
element::Type& itype,
|
||||
element::Type& otype,
|
||||
element::Type& ntype,
|
||||
float fstart,
|
||||
float fstop,
|
||||
float fstep) {
|
||||
auto start = CreateConstant(ishape, ntype, fstart);
|
||||
auto stop = CreateConstant(ishape, ntype, fstop);
|
||||
auto step = CreateConstant(ishape, ntype, fstep);
|
||||
auto range = std::make_shared<op::v0::Range>(start, stop, step);
|
||||
return std::make_shared<Function>(NodeVector{range}, ParameterVector{});
|
||||
}
|
||||
};
|
||||
|
||||
class ReferenceRangeV4LayerTest : public testing::TestWithParam<RangeParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params.inShape,
|
||||
params.outShape,
|
||||
params.inType,
|
||||
params.outType,
|
||||
params.nodeType,
|
||||
params.start,
|
||||
params.stop,
|
||||
params.step);
|
||||
refOutData = {params.outData};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<RangeParams>& obj) {
|
||||
auto param = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "iShape=" << param.inShape << "_";
|
||||
result << "oShape=" << param.outShape << "_";
|
||||
result << "iType=" << param.inType << "_";
|
||||
result << "oType=" << param.outType << "_";
|
||||
result << "nType=" << param.nodeType;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(Shape& ishape,
|
||||
Shape& oshape,
|
||||
element::Type& itype,
|
||||
element::Type& otype,
|
||||
element::Type& ntype,
|
||||
float fstart,
|
||||
float fstop,
|
||||
float fstep) {
|
||||
auto start = CreateConstant(ishape, ntype, fstart);
|
||||
auto stop = CreateConstant(ishape, ntype, fstop);
|
||||
auto step = CreateConstant(ishape, ntype, fstep);
|
||||
auto range = std::make_shared<op::v4::Range>(start, stop, step, otype);
|
||||
return std::make_shared<Function>(NodeVector{range}, ParameterVector{});
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceRangeV0LayerTest, RangeWithHardcodedRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
TEST_P(ReferenceRangeV4LayerTest, RangeWithHardcodedRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
template <element::Type_t IN_ET>
|
||||
std::vector<RangeParams> generateParamsForRangeV0Int() {
|
||||
using T = typename element_type_traits<IN_ET>::value_type;
|
||||
|
||||
std::vector<RangeParams> params{
|
||||
RangeParams(
|
||||
ov::Shape{},
|
||||
ov::Shape{4},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{-5, -2, 1, 4},
|
||||
-5,
|
||||
6,
|
||||
3),
|
||||
RangeParams(
|
||||
ov::Shape{},
|
||||
ov::Shape{2},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{10, 7},
|
||||
10,
|
||||
5,
|
||||
-3)};
|
||||
return params;
|
||||
}
|
||||
|
||||
template <element::Type_t IN_ET>
|
||||
std::vector<RangeParams> generateParamsForRangeV0UnsignedInt() {
|
||||
using T = typename element_type_traits<IN_ET>::value_type;
|
||||
|
||||
std::vector<RangeParams> params{
|
||||
RangeParams(
|
||||
ov::Shape{},
|
||||
ov::Shape{10},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
|
||||
0,
|
||||
10,
|
||||
1)
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
template <element::Type_t IN_ET>
|
||||
std::vector<RangeParams> generateParamsForRangeV0Float() {
|
||||
using T = typename element_type_traits<IN_ET>::value_type;
|
||||
|
||||
std::vector<RangeParams> params{
|
||||
RangeParams(ov::Shape{},
|
||||
ov::Shape{4},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{0.0f, 0.25f, 0.5f, 0.75},
|
||||
0.0f,
|
||||
1.0f,
|
||||
0.25f),
|
||||
RangeParams(ov::Shape{},
|
||||
ov::Shape{10},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{-1.0f, -0.8f, -0.6f, -0.4f, -0.2f, 0.0f, 0.2f, 0.4f, 0.6f, 0.8f},
|
||||
-1.0f,
|
||||
0.875f,
|
||||
0.2f),
|
||||
RangeParams(ov::Shape{},
|
||||
ov::Shape{8},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{2.0f, 1.75f, 1.5f, 1.25f, 1.0f, 0.75f, 0.5f, 0.25},
|
||||
2.0f,
|
||||
0.0f,
|
||||
-0.25f)};
|
||||
return params;
|
||||
}
|
||||
|
||||
template <element::Type_t IN_ET>
|
||||
std::vector<RangeParams> generateParamsForRangeV4Int() {
|
||||
using T = typename element_type_traits<IN_ET>::value_type;
|
||||
|
||||
std::vector<RangeParams> params{
|
||||
RangeParams(
|
||||
ov::Shape{},
|
||||
ov::Shape{4},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{-5, -2, 1, 4},
|
||||
-5,
|
||||
6,
|
||||
3),
|
||||
RangeParams(
|
||||
ov::Shape{},
|
||||
ov::Shape{2},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{10, 7},
|
||||
10,
|
||||
5,
|
||||
-3)
|
||||
};
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
template <element::Type_t IN_ET>
|
||||
std::vector<RangeParams> generateParamsForRangeV4UnsignedInt() {
|
||||
using T = typename element_type_traits<IN_ET>::value_type;
|
||||
|
||||
std::vector<RangeParams> params{
|
||||
RangeParams(
|
||||
ov::Shape{},
|
||||
ov::Shape{10},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
element::Type_t::f32,
|
||||
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
1.2f,
|
||||
11.3f,
|
||||
1.6f),
|
||||
RangeParams(
|
||||
ov::Shape{},
|
||||
ov::Shape{10},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
|
||||
0,
|
||||
10,
|
||||
1)
|
||||
};
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
template <element::Type_t IN_ET>
|
||||
std::vector<RangeParams> generateParamsForRangeV4Float() {
|
||||
using T = typename element_type_traits<IN_ET>::value_type;
|
||||
|
||||
std::vector<RangeParams> params{
|
||||
RangeParams(ov::Shape{},
|
||||
ov::Shape{4},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{0.0f, 0.25f, 0.5f, 0.75f},
|
||||
0.0f,
|
||||
1.0f,
|
||||
0.25f),
|
||||
RangeParams(ov::Shape{},
|
||||
ov::Shape{10},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{-1.0f, -0.8f, -0.6f, -0.4f, -0.2f, 0.0f, 0.2f, 0.4f, 0.6f, 0.8f},
|
||||
-1.0f,
|
||||
0.875f,
|
||||
0.2f),
|
||||
RangeParams(ov::Shape{},
|
||||
ov::Shape{8},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{2.0f, 1.75f, 1.5f, 1.25f, 1.0f, 0.75f, 0.5f, 0.25f},
|
||||
2,
|
||||
0,
|
||||
-0.25)
|
||||
};
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<RangeParams> generateCombinedParamsForRangeV0() {
|
||||
const std::vector<std::vector<RangeParams>> allTypeParams{
|
||||
generateParamsForRangeV0Float<element::Type_t::f32>(),
|
||||
generateParamsForRangeV0Float<element::Type_t::f16>(),
|
||||
generateParamsForRangeV0Float<element::Type_t::bf16>(),
|
||||
generateParamsForRangeV0Int<element::Type_t::i64>(),
|
||||
generateParamsForRangeV0Int<element::Type_t::i32>(),
|
||||
generateParamsForRangeV0Int<element::Type_t::i16>(),
|
||||
generateParamsForRangeV0Int<element::Type_t::i8>(),
|
||||
generateParamsForRangeV0UnsignedInt<element::Type_t::u64>(),
|
||||
generateParamsForRangeV0UnsignedInt<element::Type_t::u32>(),
|
||||
generateParamsForRangeV0UnsignedInt<element::Type_t::u16>(),
|
||||
generateParamsForRangeV0UnsignedInt<element::Type_t::u8>(),
|
||||
};
|
||||
|
||||
std::vector<RangeParams> combinedParams;
|
||||
|
||||
for (const auto& params : allTypeParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
std::vector<RangeParams> generateCombinedParamsForRangeV4() {
|
||||
const std::vector<std::vector<RangeParams>> allTypeParams{
|
||||
generateParamsForRangeV4Float<element::Type_t::f32>(),
|
||||
generateParamsForRangeV4Float<element::Type_t::f16>(),
|
||||
generateParamsForRangeV4Float<element::Type_t::bf16>(),
|
||||
generateParamsForRangeV4Int<element::Type_t::i64>(),
|
||||
generateParamsForRangeV4Int<element::Type_t::i32>(),
|
||||
generateParamsForRangeV4Int<element::Type_t::i8>(),
|
||||
generateParamsForRangeV4UnsignedInt<element::Type_t::u64>(),
|
||||
generateParamsForRangeV4UnsignedInt<element::Type_t::u32>(),
|
||||
generateParamsForRangeV4UnsignedInt<element::Type_t::u8>(),
|
||||
};
|
||||
|
||||
std::vector<RangeParams> combinedParams;
|
||||
|
||||
for (const auto& params : allTypeParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_Range_V0_With_Hardcoded_Refs,
|
||||
ReferenceRangeV0LayerTest,
|
||||
::testing::ValuesIn(generateCombinedParamsForRangeV0()),
|
||||
ReferenceRangeV0LayerTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_Range_V4_With_Hardcoded_Refs,
|
||||
ReferenceRangeV4LayerTest,
|
||||
::testing::ValuesIn(generateCombinedParamsForRangeV4()),
|
||||
ReferenceRangeV4LayerTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
@ -499,7 +499,6 @@ set(MULTI_TEST_SRC
|
||||
backend/prior_box.in.cpp
|
||||
backend/proposal.in.cpp
|
||||
backend/psroi_pooling.in.cpp
|
||||
backend/range.in.cpp
|
||||
backend/recurrent_cells.in.cpp
|
||||
backend/region_yolo.in.cpp
|
||||
backend/reorg_yolo.in.cpp
|
||||
|
@ -1,148 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "engines_util/execute_tools.hpp"
|
||||
#include "engines_util/test_case.hpp"
|
||||
#include "engines_util/test_engines.hpp"
|
||||
#include "gtest/gtest.h"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "util/test_control.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
using namespace ngraph::test;
|
||||
|
||||
static string s_manifest = "${MANIFEST}";
|
||||
using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
|
||||
|
||||
template <typename T>
|
||||
struct RangeTest {
|
||||
T start;
|
||||
T stop;
|
||||
T step;
|
||||
Shape expected_result_shape;
|
||||
std::vector<T> expected_result;
|
||||
};
|
||||
|
||||
// ------------------------------ V0 ------------------------------
|
||||
|
||||
// TODO(amprocte): We should test this with more than just int32, but there is a bug in the
|
||||
// handling of element type-changing that is currently blocking doing that easily.
|
||||
NGRAPH_TEST(${BACKEND_NAME}, range_v0_int32) {
|
||||
element::Type_t et = element::i32;
|
||||
std::vector<RangeTest<int32_t>> int32_tests = {
|
||||
RangeTest<int32_t>{0, 10, 1, Shape{10}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}},
|
||||
RangeTest<int32_t>{-5, 6, 3, Shape{4}, {-5, -2, 1, 4}},
|
||||
RangeTest<int32_t>{10, 5, -3, Shape{2}, {10, 7}}};
|
||||
|
||||
for (auto& test : int32_tests) {
|
||||
// Create a graph for f(start,stop,step) = Range(start,stop,step).
|
||||
auto start = make_shared<op::Constant>(et, Shape{}, std::vector<int32_t>{test.start});
|
||||
auto stop = make_shared<op::Constant>(et, Shape{}, std::vector<int32_t>{test.stop});
|
||||
auto step = make_shared<op::Constant>(et, Shape{}, std::vector<int32_t>{test.step});
|
||||
auto range = make_shared<op::Range>(start, stop, step);
|
||||
auto pshape_out = range->get_output_partial_shape(0);
|
||||
ASSERT_TRUE(pshape_out.rank().is_static() && pshape_out.rank() == Dimension{1});
|
||||
auto f = make_shared<Function>(NodeVector{range}, ParameterVector{});
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
|
||||
test_case.add_expected_output<int32_t>(test.expected_result_shape, test.expected_result);
|
||||
test_case.run();
|
||||
}
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, range_v0_float32) {
|
||||
element::Type_t et = element::f32;
|
||||
std::vector<RangeTest<float>> float32_tests = {
|
||||
RangeTest<float>{0, 1, 0.25, Shape{4}, {0.0f, 0.25f, 0.5f, 0.75f}},
|
||||
RangeTest<float>{-1, 0.875, 0.2, Shape{10}, {-1.0f, -0.8f, -0.6f, -0.4f, -0.2f, 0.0f, 0.2f, 0.4f, 0.6f, 0.8f}},
|
||||
RangeTest<float>{2, 0, -0.25, Shape{8}, {2.0f, 1.75f, 1.5f, 1.25f, 1.0f, 0.75f, 0.5f, 0.25f}}};
|
||||
|
||||
for (auto& test : float32_tests) {
|
||||
// Create a graph for f(start,stop,step) = Range(start,stop,step).
|
||||
auto start = make_shared<op::Constant>(et, Shape{}, std::vector<float>{test.start});
|
||||
auto stop = make_shared<op::Constant>(et, Shape{}, std::vector<float>{test.stop});
|
||||
auto step = make_shared<op::Constant>(et, Shape{}, std::vector<float>{test.step});
|
||||
auto range = make_shared<op::Range>(start, stop, step);
|
||||
auto pshape_out = range->get_output_partial_shape(0);
|
||||
ASSERT_TRUE(pshape_out.rank().is_static() && pshape_out.rank() == Dimension{1});
|
||||
auto f = make_shared<Function>(NodeVector{range}, ParameterVector{});
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
|
||||
test_case.add_expected_output<float>(test.expected_result_shape, test.expected_result);
|
||||
test_case.run_with_tolerance_as_fp(1.0e-4f);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------ V4 ------------------------------
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, range_v4_trunc_inputs) {
|
||||
auto start = make_shared<op::Parameter>(element::f32, Shape{});
|
||||
auto stop = make_shared<op::Parameter>(element::f32, Shape{});
|
||||
auto step = make_shared<op::Parameter>(element::f32, Shape{});
|
||||
|
||||
auto range = make_shared<op::v4::Range>(start, stop, step, element::i32);
|
||||
auto f = make_shared<Function>(range, ParameterVector{start, stop, step});
|
||||
|
||||
std::vector<float> start_vect{1.2};
|
||||
std::vector<float> stop_vect{11.3};
|
||||
std::vector<float> step_vect{1.6f};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine, TestCaseType::DYNAMIC>(f);
|
||||
test_case.add_input<float>(Shape{}, start_vect);
|
||||
test_case.add_input<float>(Shape{}, stop_vect);
|
||||
test_case.add_input<float>(Shape{}, step_vect);
|
||||
test_case.add_expected_output<int32_t>(Shape{10}, std::vector<int32_t>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, range_v4_int32) {
|
||||
element::Type_t et = element::i32;
|
||||
std::vector<RangeTest<int32_t>> int32_tests = {
|
||||
RangeTest<int32_t>{0, 10, 1, Shape{10}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}},
|
||||
RangeTest<int32_t>{-5, 6, 3, Shape{4}, {-5, -2, 1, 4}},
|
||||
RangeTest<int32_t>{10, 0, 1, Shape{0}, {}},
|
||||
RangeTest<int32_t>{10, 5, -3, Shape{2}, {10, 7}}};
|
||||
|
||||
for (auto& test : int32_tests) {
|
||||
auto start = make_shared<op::Constant>(et, Shape{}, std::vector<int32_t>{test.start});
|
||||
auto stop = make_shared<op::Constant>(et, Shape{}, std::vector<int32_t>{test.stop});
|
||||
auto step = make_shared<op::Constant>(et, Shape{}, std::vector<int32_t>{test.step});
|
||||
auto range = make_shared<op::v4::Range>(start, stop, step, et);
|
||||
auto pshape_out = range->get_output_partial_shape(0);
|
||||
ASSERT_TRUE(pshape_out.rank().is_static() && pshape_out.rank() == Dimension{1});
|
||||
auto f = make_shared<Function>(NodeVector{range}, ParameterVector{});
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
|
||||
test_case.add_expected_output<int32_t>(test.expected_result_shape, test.expected_result);
|
||||
test_case.run();
|
||||
}
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, range_v4_float32) {
|
||||
element::Type_t et = element::f32;
|
||||
std::vector<RangeTest<float>> float32_tests = {
|
||||
RangeTest<float>{0, 1, 0.25, Shape{4}, {0.0f, 0.25f, 0.5f, 0.75f}},
|
||||
RangeTest<float>{-1, 0.875, 0.2, Shape{10}, {-1.0f, -0.8f, -0.6f, -0.4f, -0.2f, 0.0f, 0.2f, 0.4f, 0.6f, 0.8f}},
|
||||
RangeTest<float>{10, 0, 1, Shape{0}, {}},
|
||||
RangeTest<float>{2, 0, -0.25, Shape{8}, {2.0f, 1.75f, 1.5f, 1.25f, 1.0f, 0.75f, 0.5f, 0.25f}}};
|
||||
|
||||
for (auto& test : float32_tests) {
|
||||
auto start = make_shared<op::Constant>(et, Shape{}, std::vector<float>{test.start});
|
||||
auto stop = make_shared<op::Constant>(et, Shape{}, std::vector<float>{test.stop});
|
||||
auto step = make_shared<op::Constant>(et, Shape{}, std::vector<float>{test.step});
|
||||
auto range = make_shared<op::v4::Range>(start, stop, step, et);
|
||||
auto pshape_out = range->get_output_partial_shape(0);
|
||||
ASSERT_TRUE(pshape_out.rank().is_static() && pshape_out.rank() == Dimension{1});
|
||||
auto f = make_shared<Function>(NodeVector{range}, ParameterVector{});
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
|
||||
test_case.add_expected_output<float>(test.expected_result_shape, test.expected_result);
|
||||
test_case.run_with_tolerance_as_fp(1.0e-4f);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user