forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed crash related to loading model with fq and sigmoid (openvinotoo…
…lkit#6644) * fixed crash related with loading model with fq and sigmoid * renamed multiple_input.* to multiple_input_fq.*; removed two unnecessary FQ layers from smoke_fq_fusion_with_sigmoid test; moved FQ params to test params
- Loading branch information
1 parent
d4db8a2
commit 47dc594
Showing
7 changed files
with
223 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
inference-engine/tests/functional/plugin/gna/pass_tests/fq_fusion_with_sigmoid.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include <ie_core.hpp> | ||
#include "ngraph_functions/builders.hpp" | ||
#include "common_test_utils/test_constants.hpp" | ||
#include "shared_test_classes/base/layer_test_utils.hpp" | ||
|
||
namespace LayerTestsDefinitions { | ||
|
||
typedef std::tuple< | ||
std::string, // Target device name | ||
InferenceEngine::Precision, // Network precision | ||
size_t, // level | ||
std::pair<float, float>, // min, max | ||
size_t, // Input size | ||
std::map<std::string, std::string> // Configuration | ||
> fqFusionWithSigmoidParams; | ||
|
||
class FqFusionWithSigmoidTest : public LayerTestsUtils::LayerTestsCommon, | ||
public testing::WithParamInterface<fqFusionWithSigmoidParams> { | ||
protected: | ||
void SetUp() override { | ||
InferenceEngine::Precision netPrecision; | ||
std::map<std::string, std::string> config; | ||
size_t levelFq; | ||
std::pair<float, float> minMaxFq; | ||
size_t inputSize; | ||
std::tie(targetDevice, netPrecision, levelFq, minMaxFq, inputSize, config) = this->GetParam(); | ||
configuration.insert(config.begin(), config.end()); | ||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); | ||
|
||
auto input = ngraph::builder::makeParams(ngPrc, {{1, inputSize}}); | ||
auto constant = ngraph::builder::makeConstant(ngPrc, {1, inputSize}, std::vector<size_t>{1}); | ||
auto mul1 = ngraph::builder::makeEltwise(input[0], constant, ngraph::helpers::EltwiseTypes::ADD); | ||
auto sigmoid1 = std::make_shared<ngraph::opset1::Sigmoid>(mul1); | ||
auto mul2 = ngraph::builder::makeEltwise(input[0], sigmoid1, ngraph::helpers::EltwiseTypes::MULTIPLY); | ||
auto fake3 = ngraph::builder::makeFakeQuantize(sigmoid1, ngPrc, levelFq, | ||
{ 1 }, { minMaxFq.first }, { minMaxFq.second }, { minMaxFq.first }, { minMaxFq.second }); | ||
auto mul3 = ngraph::builder::makeEltwise(mul2, fake3, ngraph::helpers::EltwiseTypes::ADD); | ||
auto result = std::make_shared<ngraph::opset7::Result>(mul3); | ||
function = std::make_shared<ngraph::Function>(ngraph::ResultVector{result}, input, "fq_fusion_with_sigmoid"); | ||
} | ||
public: | ||
static std::string getTestCaseName(const testing::TestParamInfo<fqFusionWithSigmoidParams> &obj) { | ||
std::string targetDevice; | ||
InferenceEngine::Precision netPrecision; | ||
size_t levelFq; | ||
std::pair<float, float> minMaxFq; | ||
size_t inputSize; | ||
std::map<std::string, std::string> config; | ||
std::tie(targetDevice, netPrecision, levelFq, minMaxFq, inputSize, config) = obj.param; | ||
std::ostringstream result; | ||
result << "netPrecision=" << netPrecision.name() << "_"; | ||
result << "IS=" << inputSize << "_"; | ||
result << "targetDevice=" << targetDevice << "_"; | ||
result << "levelFq=" << levelFq << "_"; | ||
result << "(minFq,maxFq)=" << std::to_string(minMaxFq.first) << "_" << std::to_string(minMaxFq.first) << "_"; | ||
result << "inputSize=" << std::to_string(inputSize); | ||
return result.str(); | ||
} | ||
}; // class FqFusionWithSigmoidTest | ||
|
||
TEST_P(FqFusionWithSigmoidTest, CompareWithRefs) { | ||
Run(); | ||
}; | ||
|
||
const std::vector<InferenceEngine::Precision> netPrecisions = { | ||
InferenceEngine::Precision::FP32, | ||
InferenceEngine::Precision::FP16 | ||
}; | ||
|
||
std::vector<size_t> levelFq = { | ||
65535 | ||
}; | ||
|
||
std::vector<std::pair<float, float>> minMaxFq = { | ||
{-1, 1}, | ||
{-5, 5} | ||
}; | ||
|
||
std::vector<size_t> input = { | ||
64, | ||
}; | ||
|
||
std::map<std::string, std::string> additional_config = { | ||
{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, | ||
}; | ||
|
||
INSTANTIATE_TEST_SUITE_P(smoke_fq_fusion_with_sigmoid, FqFusionWithSigmoidTest, | ||
::testing::Combine( | ||
::testing::Values(CommonTestUtils::DEVICE_GNA), | ||
::testing::ValuesIn(netPrecisions), | ||
::testing::ValuesIn(levelFq), | ||
::testing::ValuesIn(minMaxFq), | ||
::testing::ValuesIn(input), | ||
::testing::Values(additional_config)), | ||
FqFusionWithSigmoidTest::getTestCaseName); | ||
|
||
} // namespace LayerTestsDefinitions |
26 changes: 26 additions & 0 deletions
26
...e/tests/functional/plugin/gna/shared_tests_instances/subgraph_tests/multiple_input_fq.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include <subgraph_tests/multiple_input_fq.hpp> | ||
#include "common_test_utils/test_constants.hpp" | ||
|
||
namespace SubgraphTestsDefinitions { | ||
namespace { | ||
std::vector<size_t> input = { | ||
64, | ||
}; | ||
|
||
std::map<std::string, std::string> additional_config = { | ||
{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, | ||
}; | ||
} // namespace | ||
|
||
INSTANTIATE_TEST_SUITE_P(smoke_multiple_input, MultipleInputTest, | ||
::testing::Combine( | ||
::testing::Values(CommonTestUtils::DEVICE_GNA), | ||
::testing::Values(InferenceEngine::Precision::FP32), | ||
::testing::ValuesIn(input), | ||
::testing::Values(additional_config)), | ||
MultipleInputTest::getTestCaseName); | ||
} // namespace SubgraphTestsDefinitions |
18 changes: 18 additions & 0 deletions
18
inference-engine/tests/functional/plugin/shared/include/subgraph_tests/multiple_input_fq.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#ifndef MULTIPLE_INPUT_HPP | ||
#define MULTIPLE_INPUT_HPP | ||
|
||
#include "shared_test_classes/subgraph/multiple_input_fq.hpp" | ||
|
||
namespace SubgraphTestsDefinitions { | ||
|
||
TEST_P(MultipleInputTest, CompareWithRefs) { | ||
Run(); | ||
}; | ||
|
||
} // namespace SubgraphTestsDefinitions | ||
|
||
#endif // MULTIPLE_INPUT_HPP |
29 changes: 29 additions & 0 deletions
29
...functional/shared_test_classes/include/shared_test_classes/subgraph/multiple_input_fq.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#ifndef SUBGRAPH_MULTIPLE_INPUT_HPP | ||
#define SUBGRAPH_MULTIPLE_INPUT_HPP | ||
|
||
#include "common_test_utils/test_common.hpp" | ||
#include "shared_test_classes/base/layer_test_utils.hpp" | ||
#include <ie_core.hpp> | ||
|
||
namespace SubgraphTestsDefinitions { | ||
typedef std::tuple< | ||
std::string, // Target device name | ||
InferenceEngine::Precision, // Network precision | ||
size_t, // Input size | ||
std::map<std::string, std::string> // Configuration | ||
> multipleInputParams; | ||
|
||
class MultipleInputTest : public LayerTestsUtils::LayerTestsCommon, | ||
public testing::WithParamInterface<multipleInputParams> { | ||
protected: | ||
void SetUp() override; | ||
public: | ||
static std::string getTestCaseName(const testing::TestParamInfo<multipleInputParams> &obj); | ||
}; | ||
} // namespace SubgraphTestsDefinitions | ||
|
||
#endif // SUBGRAPH_MULTIPLE_INPUT_HPP |
43 changes: 43 additions & 0 deletions
43
inference-engine/tests/functional/shared_test_classes/src/subgraph/multiple_input_fq.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "ngraph_functions/builders.hpp" | ||
#include "shared_test_classes/subgraph/multiple_input_fq.hpp" | ||
|
||
namespace SubgraphTestsDefinitions { | ||
|
||
std::string MultipleInputTest::getTestCaseName(const testing::TestParamInfo<multipleInputParams> &obj) { | ||
std::string targetDevice; | ||
InferenceEngine::Precision netPrecision; | ||
size_t inputSize; | ||
std::map<std::string, std::string> config; | ||
std::tie(targetDevice, netPrecision, inputSize, config) = obj.param; | ||
std::ostringstream result; | ||
result << "netPrecision=" << netPrecision.name() << "_"; | ||
result << "IS=" << inputSize << "_"; | ||
result << "targetDevice=" << targetDevice; | ||
return result.str(); | ||
} | ||
|
||
void MultipleInputTest::SetUp() { | ||
InferenceEngine::Precision netPrecision; | ||
std::map<std::string, std::string> config; | ||
size_t inputSize; | ||
std::tie(targetDevice, netPrecision, inputSize, config) = this->GetParam(); | ||
configuration.insert(config.begin(), config.end()); | ||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); | ||
auto input = ngraph::builder::makeParams(ngPrc, {{1, inputSize}, {1, inputSize}, {1, inputSize}}); | ||
auto fake1 = ngraph::builder::makeFakeQuantize(input[0], ngPrc, 255, { 1 }, { -0.5 }, { 0.5 }, { -0.5 }, { 0.5 }); | ||
auto mul1 = ngraph::builder::makeEltwise(input[0], fake1, ngraph::helpers::EltwiseTypes::ADD); | ||
auto fake2 = ngraph::builder::makeFakeQuantize(input[1], ngPrc, 255, { 1 }, { -0.5 }, { 0.5 }, { -0.5 }, { 0.5 }); | ||
auto mul2 = ngraph::builder::makeEltwise(input[1], fake2, ngraph::helpers::EltwiseTypes::ADD); | ||
auto mul3 = ngraph::builder::makeEltwise(mul1, mul2, ngraph::helpers::EltwiseTypes::ADD); | ||
auto fake3 = ngraph::builder::makeFakeQuantize(input[2], ngPrc, 255, { 1 }, { -0.5 }, { 0.5 }, { -0.5 }, { 0.5 }); | ||
auto mul4 = ngraph::builder::makeEltwise(fake3, mul3, ngraph::helpers::EltwiseTypes::ADD); | ||
auto result = std::make_shared<ngraph::opset7::Result>(mul4); | ||
function = std::make_shared<ngraph::Function>(ngraph::ResultVector{result}, input, "multiple_input"); | ||
} | ||
|
||
} // namespace SubgraphTestsDefinitions | ||
|