Fixed Minimum op if u8/16/32/64 data type is used (#6665)

This commit is contained in:
Egor Shulman
2021-09-15 07:52:46 +03:00
committed by GitHub
parent 0d76993429
commit bdaa44d0be
10 changed files with 205 additions and 123 deletions

View File

@@ -0,0 +1,112 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include <ie_core.hpp>
#include <ie_ngraph_utils.hpp>
#include <ngraph/ngraph.hpp>
#include <shared_test_classes/base/layer_test_utils.hpp>
#include <tuple>
#include "base_reference_test.hpp"
using namespace ngraph;
using namespace InferenceEngine;
using namespace reference_tests;
struct MinimumParams {
template <class IT, class OT>
MinimumParams(const PartialShape& s,
const element::Type& iType, const element::Type& oType,
const std::vector<IT>& iValues1, const std::vector<IT>& iValues2,
const std::vector<OT>& oValues)
: pshape(s),
inType(iType),
outType(oType),
inputData1(CreateBlob(iType, iValues1)),
inputData2(CreateBlob(iType, iValues2)),
refData(CreateBlob(oType, oValues)) {}
PartialShape pshape;
element::Type inType;
element::Type outType;
Blob::Ptr inputData1;
Blob::Ptr inputData2;
Blob::Ptr refData;
};
class ReferenceMinimumLayerTest : public testing::TestWithParam<MinimumParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params.pshape, params.inType);
inputData = {params.inputData1, params.inputData2};
refOutData = {params.refData};
}
static std::string getTestCaseName(const testing::TestParamInfo<MinimumParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "shape=" << param.pshape << "_";
result << "iType=" << param.inType << "_";
result << "oType=" << param.outType;
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const PartialShape& shape, const element::Type& data_type) {
auto A = std::make_shared<op::Parameter>(data_type, shape);
auto B = std::make_shared<op::Parameter>(data_type, shape);
return std::make_shared<Function>(std::make_shared<op::v1::Minimum>(A, B), ParameterVector{A, B});
}
};
TEST_P(ReferenceMinimumLayerTest, CompareWithHardcodedRefs) {
Exec();
}
INSTANTIATE_TEST_SUITE_P(
smoke_Minimum, ReferenceMinimumLayerTest, ::testing::Values(
MinimumParams(PartialShape {8},
element::u8,
element::u8,
std::vector<uint8_t> {1, 8, 8, 17, 5, 5, 2, 3},
std::vector<uint8_t> {1, 2, 4, 8, 0, 2, 1, 200},
std::vector<uint8_t> {1, 2, 4, 8, 0, 2, 1, 3}),
MinimumParams(PartialShape {8},
element::u16,
element::u16,
std::vector<uint16_t> {1, 8, 8, 17, 5, 7, 123, 3},
std::vector<uint16_t> {1, 2, 4, 8, 0, 2, 1, 1037},
std::vector<uint16_t> {1, 2, 4, 8, 0, 2, 1, 3}),
MinimumParams(PartialShape {8},
element::u32,
element::u32,
std::vector<uint32_t> {1, 8, 8, 17, 5, 5, 2, 1},
std::vector<uint32_t> {1, 2, 4, 8, 0, 2, 1, 222},
std::vector<uint32_t> {1, 2, 4, 8, 0, 2, 1, 1}),
MinimumParams(PartialShape {8},
element::u64,
element::u64,
std::vector<uint64_t> {1, 8, 8, 17, 5, 5, 2, 13},
std::vector<uint64_t> {1, 2, 4, 8, 0, 2, 1, 2222},
std::vector<uint64_t> {1, 2, 4, 8, 0, 2, 1, 13}),
MinimumParams(PartialShape {8},
element::f32,
element::f32,
std::vector<float> {1, 8, -8, 17, -0.5, 0.5, 2, 1},
std::vector<float> {1, 2, 4, 8, 0, 0, 1, 1.5},
std::vector<float> {1, 2, -8, 8, -.5, 0, 1, 1}),
MinimumParams(PartialShape {8},
element::i32,
element::i32,
std::vector<int32_t> {1, 8, -8, 17, -5, 67635216, 2, 1},
std::vector<int32_t> {1, 2, 4, 8, 0, 18448, 1, 6},
std::vector<int32_t> {1, 2, -8, 8, -5, 18448, 1, 1}),
MinimumParams(PartialShape {8},
element::i64,
element::i64,
std::vector<int64_t> {1, 8, -8, 17, -5, 67635216, 2, 17179887632},
std::vector<int64_t> {1, 2, 4, 8, 0, 18448, 1, 280592},
std::vector<int64_t> {1, 2, -8, 8, -5, 18448, 1, 280592})),
ReferenceMinimumLayerTest::getTestCaseName);