Skip to content

Commit

Permalink
[IE TEST] LRN tests fixed params (#743)
Browse files Browse the repository at this point in the history
* LRN tests fixed params

* Fix comment

* Swiched to opset3
  • Loading branch information
Liubov Batanina authored Jul 1, 2020
1 parent c9749ce commit cff39c3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::
InferenceEngine::Precision::FP16};

const double alpha = 9.9e-05;
const size_t beta = 2;
const size_t bias = 1.0f;
const double beta = 2;
const double bias = 1.0;
const size_t size = 5;

INSTANTIATE_TEST_CASE_P(LrnCheck, LrnLayerTest,
::testing::Combine(::testing::Values(alpha),
::testing::Values(beta),
::testing::Values(bias),
::testing::Values(size),
::testing::Values(std::vector<size_t>({1})),
::testing::ValuesIn(netPrecisions),
::testing::Values(std::vector<size_t>({10, 10, 3, 2})),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::
InferenceEngine::Precision::FP16};

const double alpha = 9.9e-05;
const size_t beta = 2;
const size_t bias = 1.0f;
const double beta = 2;
const double bias = 1.0;
const size_t size = 5;

INSTANTIATE_TEST_CASE_P(LrnCheck, LrnLayerTest,
::testing::Combine(::testing::Values(alpha),
::testing::Values(beta),
::testing::Values(bias),
::testing::Values(size),
::testing::Values(std::vector<size_t>({1})),
::testing::ValuesIn(netPrecisions),
::testing::Values(std::vector<size_t>({10, 10, 3, 2})),
::testing::Values(CommonTestUtils::DEVICE_GPU)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ namespace LayerTestsDefinitions {

typedef std::tuple<
double, // Alpha
size_t, // Beta
size_t, // Bias
size_t, // Size,
double, // Beta
double, // Bias
size_t, // Size
std::vector<size_t>, // Reduction axes
InferenceEngine::Precision, // Network precision
InferenceEngine::SizeVector, // Input shapes
std::string // Device name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
namespace LayerTestsDefinitions {

std::string LrnLayerTest::getTestCaseName(testing::TestParamInfo<lrnLayerTestParamsSet> obj) {
double alpha;
size_t beta, bias, size;
double alpha, beta, bias;
size_t size;
std::vector<size_t> axes;
InferenceEngine::Precision netPrecision;
std::vector<size_t> inputShapes;
std::string targetDevice;
std::tie(alpha, beta, bias, size, netPrecision, inputShapes, targetDevice) = obj.param;
std::tie(alpha, beta, bias, size, axes, netPrecision, inputShapes, targetDevice) = obj.param;

std::ostringstream result;
const char separator = '_';
Expand All @@ -27,6 +28,7 @@ std::string LrnLayerTest::getTestCaseName(testing::TestParamInfo<lrnLayerTestPar
result << "Beta=" << beta << separator;
result << "Bias=" << bias << separator;
result << "Size=" << size << separator;
result << "Axes=" << CommonTestUtils::vec2str(axes) << separator;
result << "netPRC=" << netPrecision.name() << separator;
result << "targetDevice=" << targetDevice;

Expand All @@ -36,16 +38,19 @@ std::string LrnLayerTest::getTestCaseName(testing::TestParamInfo<lrnLayerTestPar
void LrnLayerTest::SetUp() {
std::vector<size_t> inputShapes;
auto netPrecision = InferenceEngine::Precision::UNSPECIFIED;
size_t alpha, beta, bias, size;
std::tie(alpha, beta, bias, size, netPrecision, inputShapes, targetDevice) = GetParam();
double alpha, beta, bias;
size_t size;
std::vector<size_t> axes;
std::tie(alpha, beta, bias, size, axes, netPrecision, inputShapes, targetDevice) = GetParam();

auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
auto params = ngraph::builder::makeParams(ngPrc, {inputShapes});
auto paramIn =
ngraph::helpers::convert2OutputVector(ngraph::helpers::castOps2Nodes<ngraph::op::Parameter>(params));

auto lrn = std::make_shared<ngraph::opset1::LRN>(paramIn[0], alpha, beta, bias, size);
ngraph::ResultVector results {std::make_shared<ngraph::opset1::Result>(lrn)};
auto axes_node = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{axes.size()}, axes.data());
auto lrn = std::make_shared<ngraph::opset3::LRN>(paramIn[0], axes_node, alpha, beta, bias, size);
ngraph::ResultVector results {std::make_shared<ngraph::opset3::Result>(lrn)};
function = std::make_shared<ngraph::Function>(results, params, "lrn");
}

Expand Down

0 comments on commit cff39c3

Please sign in to comment.