Add slt in template plugin/region yolo (#8886)
* Remove fp16 of Convert layer test from skip_tests.config.cpp as it works now * update repo * add op reference test of region_tolo * add type_prop test and remove backend test of region_yolo * apply type conversion for loading file test and add bf16 test case in skip_test_config * change location of compile definition under target and use path_join from file_util * add dependency of test_model_zoo * apply ov::Model * remove unnecessary * changed compile definition of TEST_FILES * skip test cases of external test file * remove test cases of importing data file
This commit is contained in:
1 parent
42309d1a65
commit
22fae50229
4 files changed
+229
-106
No files matched your search
@@ -0,0 +1,155 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
#include "openvino/op/region_yolo.hpp"
|
||||
#include "base_reference_test.hpp"
|
||||
#include "openvino/util/file_util.hpp"
|
||||
|
||||
using namespace reference_tests;
|
||||
using namespace ov;
|
||||
|
||||
namespace {
|
||||
struct RegionYoloParams {
|
||||
template <class IT>
|
||||
RegionYoloParams(const size_t num,
|
||||
const size_t coords,
|
||||
const size_t classes,
|
||||
const bool do_softmax,
|
||||
const int axis,
|
||||
const int end_axis,
|
||||
const size_t batch,
|
||||
const size_t channels,
|
||||
const size_t width,
|
||||
const size_t height,
|
||||
const std::vector<int64_t>& mask,
|
||||
const ov::element::Type& iType,
|
||||
const std::vector<IT>& iValues,
|
||||
const std::vector<IT>& oValues,
|
||||
const std::string& testcaseName = "")
|
||||
: num(num),
|
||||
coords(coords),
|
||||
classes(classes),
|
||||
do_softmax(do_softmax),
|
||||
axis(axis),
|
||||
end_axis(end_axis),
|
||||
batch(batch),
|
||||
channels(channels),
|
||||
width(width),
|
||||
height(height),
|
||||
mask(mask),
|
||||
inType(iType),
|
||||
outType(iType),
|
||||
inputData(CreateTensor(iType, iValues)),
|
||||
refData(CreateTensor(iType, oValues)),
|
||||
testcaseName(testcaseName) {
|
||||
inputShape = Shape{batch, channels, height, width};
|
||||
}
|
||||
|
||||
size_t num;
|
||||
size_t coords;
|
||||
size_t classes;
|
||||
bool do_softmax;
|
||||
int axis;
|
||||
int end_axis;
|
||||
size_t batch;
|
||||
size_t channels;
|
||||
size_t width;
|
||||
size_t height;
|
||||
std::vector<int64_t> mask;
|
||||
ov::PartialShape inputShape;
|
||||
ov::element::Type inType;
|
||||
ov::element::Type outType;
|
||||
ov::runtime::Tensor inputData;
|
||||
ov::runtime::Tensor refData;
|
||||
std::string testcaseName;
|
||||
};
|
||||
|
||||
class ReferenceRegionYoloLayerTest : public testing::TestWithParam<RegionYoloParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.inputData};
|
||||
refOutData = {params.refData};
|
||||
}
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<RegionYoloParams>& obj) {
|
||||
auto param = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "inputShape=" << param.inputShape << "_";
|
||||
result << "iType=" << param.inType << "_";
|
||||
result << "oType=" << param.outType << "_";
|
||||
result << "coords=" << param.coords << "_";
|
||||
result << "classes=" << param.classes << "_";
|
||||
result << "num=" << param.num << "_";
|
||||
result << "do_softmax=" << param.do_softmax << "_";
|
||||
result << "mask=" << param.mask << "_";
|
||||
result << "axis=" << param.axis << "_";
|
||||
result << "end_axis=" << param.end_axis;
|
||||
if (param.testcaseName != "")
|
||||
result << "_" << param.testcaseName;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<Model> CreateFunction(const RegionYoloParams& params) {
|
||||
const auto p = std::make_shared<op::v0::Parameter>(params.inType, params.inputShape);
|
||||
const auto RegionYolo = std::make_shared<op::v0::RegionYolo>(p,
|
||||
params.coords,
|
||||
params.classes,
|
||||
params.num,
|
||||
params.do_softmax,
|
||||
params.mask,
|
||||
params.axis,
|
||||
params.end_axis);
|
||||
return std::make_shared<ov::Model>(NodeVector {RegionYolo}, ParameterVector {p});
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceRegionYoloLayerTest, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
template <element::Type_t IN_ET>
|
||||
std::vector<RegionYoloParams> generateRegionYoloParams() {
|
||||
using T = typename element_type_traits<IN_ET>::value_type;
|
||||
|
||||
std::vector<RegionYoloParams> regionYoloParams {
|
||||
RegionYoloParams(1, 4, 1, false, 1, 3,
|
||||
1, 8, 2, 2,
|
||||
std::vector<int64_t>{0},
|
||||
IN_ET,
|
||||
std::vector<T>{0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.1f, 0.2f, 0.3f,
|
||||
0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f,
|
||||
0.7f, 0.8f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f},
|
||||
std::vector<T>{0.52497f, 0.54983f, 0.57444f, 0.59868f, 0.62245f, 0.64565f, 0.66818f, 0.68997f,
|
||||
0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f,
|
||||
0.52497f, 0.54983f, 0.57444f, 0.59868f, 0.62245f, 0.64565f, 0.66818f, 0.68997f}),
|
||||
};
|
||||
return regionYoloParams;
|
||||
}
|
||||
|
||||
std::vector<RegionYoloParams> generateRegionYoloCombinedParams() {
|
||||
const std::vector<std::vector<RegionYoloParams>> regionYoloTypeParams {
|
||||
generateRegionYoloParams<element::Type_t::f64>(),
|
||||
generateRegionYoloParams<element::Type_t::f32>(),
|
||||
generateRegionYoloParams<element::Type_t::f16>(),
|
||||
generateRegionYoloParams<element::Type_t::bf16>()
|
||||
};
|
||||
std::vector<RegionYoloParams> combinedParams;
|
||||
|
||||
for (const auto& params : regionYoloTypeParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_RegionYolo_With_Hardcoded_Refs, ReferenceRegionYoloLayerTest,
|
||||
testing::ValuesIn(generateRegionYoloCombinedParams()), ReferenceRegionYoloLayerTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
||||
@@ -204,6 +204,7 @@ set(SRC
|
||||
type_prop/reduce_min.cpp
|
||||
type_prop/reduce_prod.cpp
|
||||
type_prop/reduce_sum.cpp
|
||||
type_prop/region_yolo.cpp
|
||||
type_prop/relu.cpp
|
||||
type_prop/reorg_yolo.cpp
|
||||
type_prop/reshape.cpp
|
||||
@@ -461,7 +462,6 @@ endif()
|
||||
set(MULTI_TEST_SRC
|
||||
backend/abc.in.cpp
|
||||
backend/interpolate.in.cpp
|
||||
backend/region_yolo.in.cpp
|
||||
backend/sqrt.in.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
// Copyright (C) 2018-2022 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#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"
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
|
||||
static string s_manifest = "${MANIFEST}";
|
||||
static string s_device = test::backend_name_to_device("${BACKEND_NAME}");
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, region_yolo_v2_caffe) {
|
||||
const size_t num = 5;
|
||||
const size_t coords = 4;
|
||||
const size_t classes = 20;
|
||||
const size_t batch = 1;
|
||||
const size_t channels = 125;
|
||||
const size_t width = 13;
|
||||
const size_t height = 13;
|
||||
const std::vector<int64_t> mask{0, 1, 2};
|
||||
|
||||
Shape input_shape{batch, channels, height, width};
|
||||
Shape output_shape{batch, channels * height * width};
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, input_shape);
|
||||
auto R = make_shared<op::v0::RegionYolo>(A, coords, classes, num, true, mask, 1, 3);
|
||||
auto f = make_shared<Function>(R, ParameterVector{A});
|
||||
|
||||
auto test_case = test::TestCase(f, s_device);
|
||||
|
||||
test_case.add_input_from_file<float>(input_shape, TEST_FILES, "region_in_yolov2_caffe.data");
|
||||
test_case.add_expected_output_from_file<float>(output_shape, TEST_FILES, "region_out_yolov2_caffe.data");
|
||||
test_case.run_with_tolerance_as_fp(1.0e-4f);
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, region_yolo_v3_mxnet) {
|
||||
const size_t num = 9;
|
||||
const size_t coords = 4;
|
||||
const size_t classes = 20;
|
||||
const size_t batch = 1;
|
||||
const size_t channels = 75;
|
||||
const size_t width = 32;
|
||||
const size_t height = 32;
|
||||
const std::vector<int64_t> mask{0, 1, 2};
|
||||
|
||||
Shape shape{batch, channels, height, width};
|
||||
|
||||
const auto A = make_shared<op::Parameter>(element::f32, shape);
|
||||
const auto R = make_shared<op::v0::RegionYolo>(A, coords, classes, num, false, mask, 1, 3);
|
||||
const auto f = make_shared<Function>(R, ParameterVector{A});
|
||||
|
||||
EXPECT_EQ(R->get_output_shape(0), shape);
|
||||
|
||||
auto test_case = test::TestCase(f, s_device);
|
||||
|
||||
test_case.add_input_from_file<float>(shape, TEST_FILES, "region_in_yolov3_mxnet.data");
|
||||
test_case.add_expected_output_from_file<float>(shape, TEST_FILES, "region_out_yolov3_mxnet.data");
|
||||
test_case.run_with_tolerance_as_fp(1.0e-4f);
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, region_yolo_v3_mxnet_2) {
|
||||
const size_t num = 1;
|
||||
const size_t coords = 4;
|
||||
const size_t classes = 1;
|
||||
const size_t batch = 1;
|
||||
const size_t channels = 8;
|
||||
const size_t width = 2;
|
||||
const size_t height = 2;
|
||||
const std::vector<int64_t> mask{0};
|
||||
const int axis = 1;
|
||||
const int end_axis = 3;
|
||||
|
||||
Shape input_shape{batch, channels, height, width};
|
||||
Shape output_shape{batch, (classes + coords + 1) * mask.size(), height, width};
|
||||
|
||||
const auto A = make_shared<op::Parameter>(element::f32, input_shape);
|
||||
const auto R = make_shared<op::v0::RegionYolo>(A, coords, classes, num, false, mask, axis, end_axis);
|
||||
const auto f = make_shared<Function>(R, ParameterVector{A});
|
||||
|
||||
EXPECT_EQ(R->get_output_shape(0), output_shape);
|
||||
|
||||
auto test_case = test::TestCase(f, s_device);
|
||||
std::vector<float> input{0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.1f, 0.2f, 0.3f,
|
||||
0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f,
|
||||
0.7f, 0.8f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f};
|
||||
|
||||
std::vector<float> output{
|
||||
0.52497f, 0.54983f, 0.57444f, 0.59868f, 0.62245f, 0.64565f, 0.66818f, 0.68997f,
|
||||
0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f,
|
||||
0.52497f, 0.54983f, 0.57444f, 0.59868f, 0.62245f, 0.64565f, 0.66818f, 0.68997f,
|
||||
};
|
||||
|
||||
test_case.add_input<float>(input);
|
||||
test_case.add_expected_output<float>(output);
|
||||
test_case.run_with_tolerance_as_fp(1.0e-4f);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "util/type_prop.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
|
||||
TEST(type_prop, region_yolo_v2) {
|
||||
const size_t num = 5;
|
||||
const size_t coords = 4;
|
||||
const size_t classes = 20;
|
||||
const size_t batch = 1;
|
||||
const size_t channels = 125;
|
||||
const size_t width = 13;
|
||||
const size_t height = 13;
|
||||
const std::vector<int64_t> mask{0, 1, 2};
|
||||
const int axis = 1;
|
||||
const int end_axis = 3;
|
||||
const auto in_shape = Shape{batch, channels, width, height};
|
||||
auto data_param = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto region_yolo = make_shared<op::v0::RegionYolo>(data_param, coords, classes, num, true, mask, axis, end_axis);
|
||||
|
||||
// in_shape [N,C,H,W] -> out_shape [N, C*stride*stride, H/stride, W/stride]
|
||||
Shape expected_shape = Shape{batch, channels * height * width};
|
||||
|
||||
EXPECT_EQ(region_yolo->get_output_shape(0), expected_shape);
|
||||
}
|
||||
|
||||
TEST(type_prop, region_yolo_v3_1) {
|
||||
const size_t num = 9;
|
||||
const size_t coords = 4;
|
||||
const size_t classes = 20;
|
||||
const size_t batch = 1;
|
||||
const size_t channels = 75;
|
||||
const size_t width = 32;
|
||||
const size_t height = 32;
|
||||
const std::vector<int64_t> mask{0, 1, 2};
|
||||
const int axis = 1;
|
||||
const int end_axis = 3;
|
||||
const auto in_shape = Shape{batch, channels, width, height};
|
||||
auto data_param = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto region_yolo = make_shared<op::v0::RegionYolo>(data_param, coords, classes, num, false, mask, axis, end_axis);
|
||||
|
||||
// in_shape [N,C,H,W] -> out_shape [N, C*stride*stride, H/stride, W/stride]
|
||||
Shape expected_shape = Shape{batch, channels, height, width};
|
||||
|
||||
EXPECT_EQ(region_yolo->get_output_shape(0), expected_shape);
|
||||
}
|
||||
|
||||
TEST(type_prop, region_yolo_v3_2) {
|
||||
const size_t num = 1;
|
||||
const size_t coords = 4;
|
||||
const size_t classes = 1;
|
||||
const size_t batch = 1;
|
||||
const size_t channels = 8;
|
||||
const size_t width = 2;
|
||||
const size_t height = 2;
|
||||
const std::vector<int64_t> mask{0};
|
||||
const int axis = 1;
|
||||
const int end_axis = 3;
|
||||
const auto in_shape = Shape{batch, channels, width, height};
|
||||
auto data_param = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto region_yolo = make_shared<op::v0::RegionYolo>(data_param, coords, classes, num, false, mask, axis, end_axis);
|
||||
|
||||
// in_shape [N,C,H,W] -> out_shape [N, C*stride*stride, H/stride, W/stride]
|
||||
Shape expected_shape = Shape{batch, (classes + coords + 1) * mask.size(), height, width};
|
||||
|
||||
EXPECT_EQ(region_yolo->get_output_shape(0), expected_shape);
|
||||
}
|
||||
Reference in new issue
Block a user