[GNA] add 3D shape input support for StridedSlice (#10818)

* add 3D shape to test and rename crop4d to strided_slice

* remove ConvertStridedSliceToCropNegative2 since 3D is now supported

* add myriad functional tests to skip-list
This commit is contained in:
Evgeny Kotov 2022-03-21 10:15:59 +03:00 committed by GitHub
parent c18030207c
commit d7005af4a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 59 deletions

View File

@ -202,8 +202,7 @@ ngraph::pass::ConvertStridedSliceToCropMatcher::ConvertStridedSliceToCropMatcher
}
auto data_node_shape = data_output.get_shape();
// Crop supports only 2d, 4d and 5d blobs
if (data_node_shape.size() != 2 && data_node_shape.size() != 4 && data_node_shape.size() != 5) {
if (data_node_shape.size() < 2 || data_node_shape.size() > 5) {
return false;
}

View File

@ -150,51 +150,6 @@ TEST_F(TransformationTestsF, ConvertStridedSliceToCropNegative) {
}
}
// in this test the Crop will get 3D input which is not supported so the transformation will not be applied
TEST_F(TransformationTestsF, ConvertStridedSliceToCropNegative2) {
{
auto input = std::make_shared<ngraph::opset1::Parameter>(ngraph::element::f32, ngraph::Shape{128, 1});
auto slice_begin = ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{3}, {0, 0, 0});
auto slice_end = ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{3}, {0, 0, 0});
auto slice_stride = ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{3}, {1, 1, 1});
std::vector<int64_t> begin_mask = {0, 1, 1};
std::vector<int64_t> end_mask = {0, 1, 1};
std::vector<int64_t> new_axis_mask = {1, 0, 0};
std::vector<int64_t> shrink_axis_mask = {0, 0, 0};
std::vector<int64_t> ellipsis_mask = {0, 0, 0};
auto sslice = std::make_shared<ngraph::opset1::StridedSlice>(input, slice_begin, slice_end, slice_stride,
begin_mask, end_mask,
new_axis_mask, shrink_axis_mask, ellipsis_mask);
sslice->set_friendly_name("strided_slice");
function = std::make_shared<ngraph::Function>(ngraph::NodeVector{sslice}, ngraph::ParameterVector{input});
manager.register_pass<ngraph::pass::ConvertStridedSliceToCropMatcher>();
}
{
auto input = std::make_shared<ngraph::opset1::Parameter>(ngraph::element::f32, ngraph::Shape{128, 1});
auto slice_begin = ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{3}, {0, 0, 0});
auto slice_end = ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{3}, {0, 0, 0});
auto slice_stride = ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{3}, {1, 1, 1});
std::vector<int64_t> begin_mask = {0, 1, 1};
std::vector<int64_t> end_mask = {0, 1, 1};
std::vector<int64_t> new_axis_mask = {1, 0, 0};
std::vector<int64_t> shrink_axis_mask = {0, 0, 0};
std::vector<int64_t> ellipsis_mask = {0, 0, 0};
auto sslice = std::make_shared<ngraph::opset1::StridedSlice>(input, slice_begin, slice_end, slice_stride,
begin_mask, end_mask,
new_axis_mask, shrink_axis_mask, ellipsis_mask);
sslice->set_friendly_name("strided_slice");
function_ref = std::make_shared<ngraph::Function>(ngraph::NodeVector{sslice}, ngraph::ParameterVector{input});
}
}
TEST_F(TransformationTestsF, ConvertStridedSliceToCropNoneZeroBeginValuesWithMask) {
// when begin_mask/end_mask are present begin/end values should not affect output shape
{

View File

@ -4,7 +4,7 @@
#include <vector>
#include "subgraph_tests/crop4d.hpp"
#include "subgraph_tests/strided_slice.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace SubgraphTestsDefinitions;
@ -16,6 +16,10 @@ std::vector<StridedSliceSpecificParams> ss_only_test_cases = {
{ 0, 0, 0, 0 },
{ 1, 1, 1, 1 }, { 1, 1, 1, 1 },
{ 1, 1, 1, 1 }, { 1, 0, 1, 1 }, { 0, 0, 0, 0 }, { 1, 0, 0, 0 }, { 0, 0, 0, 0 } },
StridedSliceSpecificParams{ { 1, 2, 100 },
{ 0, 0, 0 },
{ 1, 1, 1 }, { 1, 1, 1 },
{ 1, 1, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 1, 0, 0 }, { 0, 0, 0 } },
};
const std::vector<InferenceEngine::Precision> netPrecisions = {
@ -31,7 +35,7 @@ const std::vector<std::map<std::string, std::string>> configs = {
};
INSTANTIATE_TEST_SUITE_P(
smoke_crop4d_gna, Crop4dTest,
smoke_stridedslice_gna, StridedSliceTest,
::testing::Combine(
::testing::ValuesIn(ss_only_test_cases),
::testing::ValuesIn(netPrecisions),
@ -41,6 +45,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_GNA),
::testing::ValuesIn(configs)),
Crop4dTest::getTestCaseName);
StridedSliceTest::getTestCaseName);
} // namespace

View File

@ -85,5 +85,7 @@ std::vector<std::string> disabledTestPatterns() {
// TODO: Issue 76209
R"(.*MultithreadingTests.*canRun.*RequestsConsistentlyFromThreads.*MYRIAD.*)",
// TODO: CVS-82012
R"(.*StridedSliceLayerTest\.CompareWithRefs/inShape=\(1\.12\.100\).*)",
};
}

View File

@ -4,11 +4,11 @@
#pragma once
#include "shared_test_classes/subgraph/crop4d.hpp"
#include "shared_test_classes/subgraph/strided_slice.hpp"
namespace SubgraphTestsDefinitions {
TEST_P(Crop4dTest, CompareWithRefs){
TEST_P(StridedSliceTest, CompareWithRefs){
Run();
};
} // namespace SubgraphTestsDefinitions

View File

@ -25,7 +25,7 @@ struct StridedSliceSpecificParams {
std::vector<int64_t> ellipsisAxisMask;
};
using Crop4dParams = std::tuple<
using StridedSliceParams = std::tuple<
StridedSliceSpecificParams,
InferenceEngine::Precision, // Net precision
InferenceEngine::Precision, // Input precision
@ -36,10 +36,10 @@ using Crop4dParams = std::tuple<
std::map<std::string, std::string> // Additional network configuration
>;
class Crop4dTest : public testing::WithParamInterface<Crop4dParams>,
class StridedSliceTest : public testing::WithParamInterface<StridedSliceParams>,
virtual public LayerTestsUtils::LayerTestsCommon {
public:
static std::string getTestCaseName(const testing::TestParamInfo<Crop4dParams> &obj);
static std::string getTestCaseName(const testing::TestParamInfo<StridedSliceParams> &obj);
protected:
void SetUp() override;

View File

@ -4,11 +4,11 @@
#include "ngraph_functions/builders.hpp"
#include "shared_test_classes/subgraph/crop4d.hpp"
#include "shared_test_classes/subgraph/strided_slice.hpp"
namespace SubgraphTestsDefinitions {
std::string Crop4dTest::getTestCaseName(const testing::TestParamInfo<Crop4dParams> &obj) {
std::string StridedSliceTest::getTestCaseName(const testing::TestParamInfo<StridedSliceParams> &obj) {
StridedSliceSpecificParams params;
InferenceEngine::Precision netPrc;
InferenceEngine::Precision inPrc, outPrc;
@ -35,7 +35,7 @@ std::string Crop4dTest::getTestCaseName(const testing::TestParamInfo<Crop4dParam
return result.str();
}
void Crop4dTest::SetUp() {
void StridedSliceTest::SetUp() {
StridedSliceSpecificParams ssParams;
InferenceEngine::Precision netPrecision;
std::map<std::string, std::string> additionalConfig;
@ -50,7 +50,7 @@ void Crop4dTest::SetUp() {
auto ss = ngraph::builder::makeStridedSlice(relu, ssParams.begin, ssParams.end, ssParams.strides, ngPrc, ssParams.beginMask,
ssParams.endMask, ssParams.newAxisMask, ssParams.shrinkAxisMask, ssParams.ellipsisAxisMask);
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(ss)};
function = std::make_shared<ngraph::Function>(results, params, "crop4d");
function = std::make_shared<ngraph::Function>(results, params, "strided_slice");
}
} // namespace SubgraphTestsDefinitions