[Tmpl test] PriorBox(Clustered): enable whole Tensor comparison (#24022)

### Details:
 - Added actual shape to expected output tensor,
 - for PriorBox and PriorBoxClustered tests.

### Tickets:
 - CVS-137192, CVS-137193
This commit is contained in:
Tomasz Jankowski 2024-04-16 08:19:38 +02:00 committed by GitHub
parent 53a4b731f7
commit 778e26ed2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 67 deletions

View File

@ -18,20 +18,17 @@ struct PriorBoxParams {
PriorBoxParams(const std::vector<float>& min_size,
const std::vector<float>& aspect_ratio,
const bool scale_all_size,
const ov::Shape& layerShapeShape,
const ov::Shape& imageShapeShape,
const ov::element::Type& iType,
const std::vector<IT>& layerShapeValues,
const std::vector<IT>& imageShapeValues,
const Shape& output_shape,
const std::vector<float>& oValues,
const std::string& testcaseName = "")
: layerShapeShape(layerShapeShape),
imageShapeShape(imageShapeShape),
inType(iType),
: inType(iType),
outType(ov::element::Type_t::f32),
layerShapeData(CreateTensor(iType, layerShapeValues)),
imageShapeData(CreateTensor(iType, imageShapeValues)),
refData(CreateTensor(outType, oValues)),
layerShapeData(CreateTensor(Shape{2}, iType, layerShapeValues)),
imageShapeData(CreateTensor(Shape{2}, iType, imageShapeValues)),
refData(CreateTensor(output_shape, outType, oValues)),
testcaseName(testcaseName) {
attrs.min_size = min_size;
attrs.aspect_ratio = aspect_ratio;
@ -39,8 +36,6 @@ struct PriorBoxParams {
}
ov::op::v0::PriorBox::Attributes attrs;
ov::Shape layerShapeShape;
ov::Shape imageShapeShape;
ov::element::Type inType;
ov::element::Type outType;
ov::Tensor layerShapeData;
@ -56,20 +51,17 @@ struct PriorBoxV8Params {
const std::vector<float>& aspect_ratio,
const bool scale_all_size,
const bool min_max_aspect_ratios_order,
const ov::Shape& layerShapeShape,
const ov::Shape& imageShapeShape,
const ov::element::Type& iType,
const std::vector<IT>& layerShapeValues,
const std::vector<IT>& imageShapeValues,
const Shape& output_shape,
const std::vector<float>& oValues,
const std::string& testcaseName = "")
: layerShapeShape(layerShapeShape),
imageShapeShape(imageShapeShape),
inType(iType),
: inType(iType),
outType(ov::element::Type_t::f32),
layerShapeData(CreateTensor(iType, layerShapeValues)),
imageShapeData(CreateTensor(iType, imageShapeValues)),
refData(CreateTensor(outType, oValues)),
layerShapeData(CreateTensor(Shape{2}, iType, layerShapeValues)),
imageShapeData(CreateTensor(Shape{2}, iType, imageShapeValues)),
refData(CreateTensor(output_shape, outType, oValues)),
testcaseName(testcaseName) {
attrs.min_size = min_size;
attrs.max_size = max_size;
@ -79,8 +71,6 @@ struct PriorBoxV8Params {
}
ov::op::v8::PriorBox::Attributes attrs;
ov::Shape layerShapeShape;
ov::Shape imageShapeShape;
ov::element::Type inType;
ov::element::Type outType;
ov::Tensor layerShapeData;
@ -92,30 +82,25 @@ struct PriorBoxV8Params {
class ReferencePriorBoxLayerTest : public testing::TestWithParam<PriorBoxParams>, public CommonReferenceTest {
public:
void SetUp() override {
legacy_compare = true;
auto params = GetParam();
const auto& params = GetParam();
function = CreateFunction(params);
inputData = {};
refOutData = {params.refData};
}
static std::string getTestCaseName(const testing::TestParamInfo<PriorBoxParams>& obj) {
auto param = obj.param;
const auto& param = obj.param;
std::ostringstream result;
result << "layerShapeShape=" << param.layerShapeShape << "_";
result << "imageShapeShape=" << param.imageShapeShape << "_";
result << "iType=" << param.inType << "_";
result << "oType=" << param.outType;
if (param.testcaseName != "")
if (!param.testcaseName.empty())
result << "_" << param.testcaseName;
return result.str();
}
private:
static std::shared_ptr<Model> CreateFunction(const PriorBoxParams& params) {
auto LS =
std::make_shared<op::v0::Constant>(params.inType, params.layerShapeShape, params.layerShapeData.data());
auto IS =
std::make_shared<op::v0::Constant>(params.inType, params.imageShapeShape, params.imageShapeData.data());
const auto LS = std::make_shared<op::v0::Constant>(params.layerShapeData);
const auto IS = std::make_shared<op::v0::Constant>(params.imageShapeData);
const auto PriorBox = std::make_shared<op::v0::PriorBox>(LS, IS, params.attrs);
return std::make_shared<ov::Model>(NodeVector{PriorBox}, ParameterVector{});
}
@ -124,30 +109,25 @@ private:
class ReferencePriorBoxV8LayerTest : public testing::TestWithParam<PriorBoxV8Params>, public CommonReferenceTest {
public:
void SetUp() override {
legacy_compare = true;
auto params = GetParam();
const auto& params = GetParam();
function = CreateFunction(params);
inputData = {};
refOutData = {params.refData};
}
static std::string getTestCaseName(const testing::TestParamInfo<PriorBoxV8Params>& obj) {
auto param = obj.param;
const auto& param = obj.param;
std::ostringstream result;
result << "layerShapeShape=" << param.layerShapeShape << "_";
result << "imageShapeShape=" << param.imageShapeShape << "_";
result << "iType=" << param.inType << "_";
result << "oType=" << param.outType;
if (param.testcaseName != "")
if (!param.testcaseName.empty())
result << "_" << param.testcaseName;
return result.str();
}
private:
static std::shared_ptr<Model> CreateFunction(const PriorBoxV8Params& params) {
auto LS =
std::make_shared<op::v0::Constant>(params.inType, params.layerShapeShape, params.layerShapeData.data());
auto IS =
std::make_shared<op::v0::Constant>(params.inType, params.imageShapeShape, params.imageShapeData.data());
const auto LS = std::make_shared<op::v0::Constant>(params.layerShapeData);
const auto IS = std::make_shared<op::v0::Constant>(params.imageShapeData);
const auto PriorBoxV8 = std::make_shared<op::v8::PriorBox>(LS, IS, params.attrs);
return std::make_shared<ov::Model>(NodeVector{PriorBoxV8}, ParameterVector{});
}
@ -169,11 +149,10 @@ std::vector<PriorBoxParams> generatePriorBoxFloatParams() {
PriorBoxParams({2.0f},
{1.5f},
false,
{2},
{2},
IN_ET,
std::vector<T>{2, 2},
std::vector<T>{10, 10},
Shape{2, 32},
std::vector<float>{-0.75, -0.75, 1.25, 1.25, -0.974745, -0.566497, 1.47474, 1.0665,
-0.25, -0.75, 1.75, 1.25, -0.474745, -0.566497, 1.97474, 1.0665,
-0.75, -0.25, 1.25, 1.75, -0.974745, -0.0664966, 1.47474, 1.5665,
@ -197,11 +176,10 @@ std::vector<PriorBoxV8Params> generatePriorBoxV8FloatParams() {
{1.5f},
true,
false,
{2},
{2},
IN_ET,
std::vector<T>{2, 2},
std::vector<T>{10, 10},
Shape{2, 48},
std::vector<float>{
0.15, 0.15, 0.35, 0.35, 0.127526, 0.16835, 0.372474, 0.33165, 0.0918861, 0.0918861, 0.408114, 0.408114,
0.65, 0.15, 0.85, 0.35, 0.627526, 0.16835, 0.872474, 0.33165, 0.591886, 0.0918861, 0.908114, 0.408114,

View File

@ -19,21 +19,18 @@ struct PriorBoxClusteredParams {
PriorBoxClusteredParams(const std::vector<float>& widths,
const std::vector<float>& heights,
const bool clip,
const ov::Shape& layerShapeShape,
const ov::Shape& imageShapeShape,
const ov::element::Type& iType,
const std::vector<IT>& layerShapeValues,
const std::vector<IT>& imageShapeValues,
const Shape& output_shape,
const std::vector<float>& oValues,
const std::vector<float>& variances = {},
const std::string& testcaseName = "")
: layerShapeShape(layerShapeShape),
imageShapeShape(imageShapeShape),
inType(iType),
: inType(iType),
outType(ov::element::Type_t::f32),
layerShapeData(CreateTensor(iType, layerShapeValues)),
imageShapeData(CreateTensor(iType, imageShapeValues)),
refData(CreateTensor(outType, oValues)),
layerShapeData(CreateTensor(Shape{2}, iType, layerShapeValues)),
imageShapeData(CreateTensor(Shape{2}, iType, imageShapeValues)),
refData(CreateTensor(output_shape, outType, oValues)),
testcaseName(testcaseName) {
attrs.widths = widths;
attrs.heights = heights;
@ -43,8 +40,6 @@ struct PriorBoxClusteredParams {
}
ov::op::v0::PriorBoxClustered::Attributes attrs;
ov::Shape layerShapeShape;
ov::Shape imageShapeShape;
ov::element::Type inType;
ov::element::Type outType;
ov::Tensor layerShapeData;
@ -57,17 +52,14 @@ class ReferencePriorBoxClusteredLayerTest : public testing::TestWithParam<PriorB
public CommonReferenceTest {
public:
void SetUp() override {
legacy_compare = true;
auto params = GetParam();
const auto& params = GetParam();
function = CreateFunction(params);
inputData = {};
refOutData = {params.refData};
}
static std::string getTestCaseName(const testing::TestParamInfo<PriorBoxClusteredParams>& obj) {
auto param = obj.param;
const auto& param = obj.param;
std::ostringstream result;
result << "layerShapeShape=" << param.layerShapeShape << "_";
result << "imageShapeShape=" << param.imageShapeShape << "_";
result << "variancesSize=" << param.attrs.variances.size() << "_";
result << "iType=" << param.inType << "_";
result << "oType=" << param.outType;
@ -78,10 +70,8 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PriorBoxClusteredParams& params) {
auto LS =
std::make_shared<op::v0::Constant>(params.inType, params.layerShapeShape, params.layerShapeData.data());
auto IS =
std::make_shared<op::v0::Constant>(params.inType, params.imageShapeShape, params.imageShapeData.data());
auto LS = std::make_shared<op::v0::Constant>(params.layerShapeData);
auto IS = std::make_shared<op::v0::Constant>(params.imageShapeData);
const auto PriorBoxClustered = std::make_shared<op::v0::PriorBoxClustered>(LS, IS, params.attrs);
return std::make_shared<ov::Model>(NodeVector{PriorBoxClustered}, ParameterVector{});
}
@ -100,11 +90,10 @@ std::vector<PriorBoxClusteredParams> generatePriorBoxClusteredFloatParams() {
{3.0f},
{3.0f},
true,
{2},
{2},
IN_ET,
std::vector<T>{2, 2},
std::vector<T>{10, 10},
Shape{2, 16},
std::vector<float>{0, 0, 0.15f, 0.15f, 0.34999f, 0, 0.64999f, 0.15f,
0, 0.34999f, 0.15f, 0.64999f, 0.34999f, 0.34999f, 0.64999f, 0.64999f,
0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f,
@ -113,11 +102,10 @@ std::vector<PriorBoxClusteredParams> generatePriorBoxClusteredFloatParams() {
{3.0f},
{3.0f},
true,
{2},
{2},
IN_ET,
std::vector<T>{2, 2},
std::vector<T>{10, 10},
Shape{2, 16},
std::vector<float>{0, 0, 0.15f, 0.15f, 0.34999f, 0, 0.64999f, 0.15f,
0, 0.34999f, 0.15f, 0.64999f, 0.34999f, 0.34999f, 0.64999f, 0.64999f,
0.1f, 0.2f, 0.3f, 0.4f, 0.1f, 0.2f, 0.3f, 0.4f,