Revise Squeeze op - tests (#5336)
This commit is contained in:
parent
6c9387d603
commit
66b3efbb6c
@ -0,0 +1,46 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "shared_test_classes/single_layer/squeeze_unsqueeze.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
|
||||
namespace {
|
||||
TEST_P(SqueezeUnsqueezeLayerTest, Serialize) {
|
||||
Serialize();
|
||||
}
|
||||
|
||||
std::map<std::vector<size_t>, std::vector<std::vector<int>>> axesVectors = {
|
||||
{{1, 1, 1, 1}, {{}, {-1}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {2, 3}, {0, 1, 2}, {0, 2, 3}, {1, 2, 3}, {0, 1, 2, 3}}},
|
||||
{{1, 2, 3, 4}, {{}, {0}}},
|
||||
{{2, 1, 3, 4}, {{}, {1}}},
|
||||
{{1}, {{}, {-1}, {0}}},
|
||||
{{1, 2}, {{}, {0}}},
|
||||
{{2, 1}, {{}, {1}, {-1}}},
|
||||
};
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32,
|
||||
InferenceEngine::Precision::FP16,
|
||||
InferenceEngine::Precision::I32,
|
||||
InferenceEngine::Precision::U32};
|
||||
|
||||
const std::vector<ngraph::helpers::SqueezeOpType> opTypes = {
|
||||
ngraph::helpers::SqueezeOpType::SQUEEZE};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(smoke_Squeeze_Basic, SqueezeUnsqueezeLayerTest,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(CommonTestUtils::combineParams(axesVectors)),
|
||||
::testing::ValuesIn(opTypes),
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
SqueezeUnsqueezeLayerTest::getTestCaseName);
|
||||
} // namespace
|
@ -11,12 +11,12 @@ using namespace LayerTestsDefinitions;
|
||||
|
||||
namespace {
|
||||
std::map<std::vector<size_t>, std::vector<std::vector<int>>> axesVectors = {
|
||||
{{1, 1, 1, 1}, {{-1}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {2, 3}, {0, 1, 2}, {0, 2, 3}, {1, 2, 3}, {0, 1, 2, 3}}},
|
||||
{{1, 2, 3, 4}, {{0}}},
|
||||
{{2, 1, 3, 4}, {{1}}},
|
||||
{{1}, {{-1}, {0}}},
|
||||
{{1, 2}, {{0}}},
|
||||
{{2, 1}, {{1}, {-1}}},
|
||||
{{1, 1, 1, 1}, {{}, {-1}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {2, 3}, {0, 1, 2}, {0, 2, 3}, {1, 2, 3}, {0, 1, 2, 3}}},
|
||||
{{1, 2, 3, 4}, {{}, {0}}},
|
||||
{{2, 1, 3, 4}, {{}, {1}}},
|
||||
{{1}, {{}, {-1}, {0}}},
|
||||
{{1, 2}, {{}, {0}}},
|
||||
{{2, 1}, {{}, {1}, {-1}}},
|
||||
};
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
|
@ -11,12 +11,12 @@ using namespace LayerTestsDefinitions;
|
||||
|
||||
namespace {
|
||||
std::map<std::vector<size_t>, std::vector<std::vector<int>>> axesVectors = {
|
||||
{{1, 1, 1, 1}, {{-1}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {2, 3}} },
|
||||
{{1, 2, 3, 4}, {{0}}},
|
||||
{{2, 1, 3, 4}, {{1}}},
|
||||
{{1}, {{-1}, {0}}},
|
||||
{{1, 2}, {{0}}},
|
||||
{{2, 1}, {{1}, {-1}}},
|
||||
{{1, 1, 1, 1}, {{}, {-1}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {2, 3}}},
|
||||
{{1, 2, 3, 4}, {{}, {0}}},
|
||||
{{2, 1, 3, 4}, {{}, {1}}},
|
||||
{{1}, {{}, {-1}, {0}}},
|
||||
{{1, 2}, {{}, {0}}},
|
||||
{{2, 1}, {{}, {1}, {-1}}},
|
||||
};
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
|
@ -16,7 +16,7 @@ namespace LayerTestsDefinitions {
|
||||
using ShapeAxesTuple = std::pair<std::vector<size_t>, std::vector<int>>;
|
||||
|
||||
typedef std::tuple<
|
||||
ShapeAxesTuple, // InputShape, Squeeze indexes
|
||||
ShapeAxesTuple, // InputShape (required), Squeeze indexes (if empty treated as non-existent)
|
||||
ngraph::helpers::SqueezeOpType, // OpType
|
||||
InferenceEngine::Precision, // Net precision
|
||||
InferenceEngine::Precision, // Input precision
|
||||
|
@ -18,7 +18,7 @@ std::string SqueezeUnsqueezeLayerTest::getTestCaseName(testing::TestParamInfo<sq
|
||||
const char separator = '_';
|
||||
result << "OpType=" << opType << separator;
|
||||
result << "IS=" << CommonTestUtils::vec2str(shapeItem.first) << separator;
|
||||
result << "Axes=" << CommonTestUtils::vec2str(shapeItem.second) << separator;
|
||||
result << "Axes=" << (shapeItem.second.empty() ? "default" : CommonTestUtils::vec2str(shapeItem.second)) << separator;
|
||||
result << "netPRC=" << netPrecision.name() << separator;
|
||||
result << "inPRC=" << inPrc.name() << separator;
|
||||
result << "outPRC=" << outPrc.name() << separator;
|
||||
@ -37,8 +37,15 @@ void SqueezeUnsqueezeLayerTest::SetUp() {
|
||||
std::tie(shapeItem, opType, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = GetParam();
|
||||
std::tie(inputShapes, axesVector) = shapeItem;
|
||||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
|
||||
|
||||
auto params = ngraph::builder::makeParams(ngPrc, {inputShapes});
|
||||
auto squeeze = ngraph::builder::makeSqueezeUnsqueeze(params.front(), ngraph::element::i64, axesVector, opType);
|
||||
std::shared_ptr<ngraph::Node> squeeze;
|
||||
|
||||
if (!axesVector.empty()) {
|
||||
squeeze = ngraph::builder::makeSqueezeUnsqueeze(params.front(), ngraph::element::i64, axesVector, opType);
|
||||
} else {
|
||||
squeeze = std::make_shared<ngraph::opset1::Squeeze>(params.front());
|
||||
}
|
||||
const ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(squeeze)};
|
||||
function = std::make_shared<ngraph::Function>(results, params, "Squeeze");
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ VERIFIED_OP_REFERENCES = [
|
||||
'SoftPlus-4',
|
||||
'Softmax-1',
|
||||
'Split-1',
|
||||
'Squeeze-1',
|
||||
'StridedSlice-1',
|
||||
'Subtract-1',
|
||||
'Swish-4',
|
||||
|
@ -255,6 +255,7 @@ set(SRC
|
||||
visitors/op/space_to_depth.cpp
|
||||
visitors/op/split.cpp
|
||||
visitors/op/squared_difference.cpp
|
||||
visitors/op/squeeze.cpp
|
||||
visitors/op/sqrt.cpp
|
||||
visitors/op/strided_slice.cpp
|
||||
visitors/op/topk.cpp
|
||||
|
28
ngraph/test/visitors/op/squeeze.cpp
Normal file
28
ngraph/test/visitors/op/squeeze.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "ngraph/op/util/attr_types.hpp"
|
||||
#include "ngraph/opsets/opset1.hpp"
|
||||
|
||||
#include "util/visitor.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
using ngraph::test::NodeBuilder;
|
||||
using ngraph::test::ValueMap;
|
||||
|
||||
TEST(attributes, squeeze_op)
|
||||
{
|
||||
NodeBuilder::get_ops().register_factory<opset1::Squeeze>();
|
||||
const auto data_node = make_shared<op::Parameter>(element::f32, Shape{1});
|
||||
const auto squeeze = make_shared<op::Squeeze>(data_node);
|
||||
|
||||
NodeBuilder builder(squeeze);
|
||||
const auto expected_attr_count = 0;
|
||||
|
||||
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
|
||||
}
|
Loading…
Reference in New Issue
Block a user