::testing::Values(CommonTestUtils::DEVICE_CPU)),
LoopTest::getTestCaseName);
- static const std::vector<std::tuple<bool, int64_t, int64_t, int64_t>> static_loop_types = {
- // static_trip_count | max | dynamic_exit | axis
- { true , 5, -1, -1 }, // n_iter 5, no dynamic exit
- { true , 5, 3, -1 }, // n_iter 3, dynamic exit on 3
- { true , 5, 7, -1 }, // n_iter 5, dynamic exit not reached
- { true , -1, 5, -1 }, // n_iter 5, inf loop with dynamic exit on 5
- { true , 5, -1, 1 }, // n_iter 5, const for loop with auto concatenated out
- { false , 5, -1, -1 }, // |
- { false , 5, 3, -1 }, // | same with dynamic trip count
- { false , 5, 7, -1 }, // |
- { false , -1, 5, -1 }, // |
+ static const std::vector<std::tuple<bool, int64_t, int64_t, int64_t>> static_loop_types {
+ // GCC4.8 limitation: have to specify type of each element in list
+ // static_trip_count | max | dynamic_exit | axis
+ std::tuple<bool, int64_t, int64_t, int64_t>{ true , 5, -1, -1 }, // n_iter 5, no dynamic exit
+ std::tuple<bool, int64_t, int64_t, int64_t>{ true , 5, 3, -1 }, // n_iter 3, dynamic exit on 3
+ std::tuple<bool, int64_t, int64_t, int64_t>{ true , 5, 7, -1 }, // n_iter 5, dynamic exit not reached
+ std::tuple<bool, int64_t, int64_t, int64_t>{ true , -1, 5, -1 }, // n_iter 5, inf loop with dynamic exit on 5
+ std::tuple<bool, int64_t, int64_t, int64_t>{ true , 5, -1, 1 }, // n_iter 5, const for loop with auto concatenated out
+ std::tuple<bool, int64_t, int64_t, int64_t>{ false , 5, -1, -1 }, // |
+ std::tuple<bool, int64_t, int64_t, int64_t>{ false , 5, 3, -1 }, // | same with dynamic trip count
+ std::tuple<bool, int64_t, int64_t, int64_t>{ false , 5, 7, -1 }, // |
+ std::tuple<bool, int64_t, int64_t, int64_t>{ false , -1, 5, -1 } // |
};
using namespace testing;
+ using namespace InferenceEngine;
+
INSTANTIATE_TEST_CASE_P(smoke_StaticShapeLoop, StaticShapeLoopTest,
Combine(
Values(true),
ValuesIn(static_loop_types),
Values<int64_t>(7),
Values<InferenceEngine::SizeVector>({2, 1, 4}),
- Values<InferenceEngine::Precision>(InferenceEngine::Precision::FP32, InferenceEngine::Precision::I32),
+ Values<InferenceEngine::Precision>(Precision::FP32, Precision::I32),
Values(CommonTestUtils::DEVICE_CPU)));
+ using namespace testing;
+ INSTANTIATE_TEST_CASE_P(smoke_TrivialLoop, TrivialLoopTest,
+ Combine(
+ Values<InferenceEngine::Precision>(Precision::FP32, Precision::I32),
+ Values<InferenceEngine::SizeVector>({2, 3, 4}),
+ Values(CommonTestUtils::DEVICE_CPU)));
+
} // namespace
void SetUp() override;
};
+
+class TrivialLoopTest : public testing::WithParamInterface<LayerTestsUtils::basicParams>,
+ virtual public LayerTestsUtils::LayerTestsCommon {
+protected:
+ using RefBlobGenerator = std::function<InferenceEngine::Blob::Ptr (const InferenceEngine::TensorDesc &info)>;
+ std::map<std::string, RefBlobGenerator> inputGens, outputGens;
+
+ InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override {
+ auto found = inputGens.find(info.name());
+ if (found != inputGens.end()) {
+ return found->second(info.getTensorDesc());
+ }
+
+ found = inputGens.find("");
+ if (found != inputGens.end()) {
+ return found->second(info.getTensorDesc());
+ }
+
+ return LayerTestsCommon::GenerateInput(info);
+ }
+
+ std::vector<std::vector<std::uint8_t>> CalculateRefs() override {
+ if (outputGens.empty())
+ return LayerTestsCommon::CalculateRefs();
+
+ const auto results = function->get_results();
+ const auto outs_info = cnnNetwork.getOutputsInfo();
+ const auto num_out_blob = results.size();
+
+ std::vector<std::vector<std::uint8_t>> res_collection(num_out_blob);
+
+ for (int i = 0; i < num_out_blob; i++) {
+ // TODO: name of original NG result doesn't match with outs after conversion.
+ // Expected : auto name = results[i]->get_friendly_name();
+ auto name = results[i]->get_input_node_ptr(0)->get_friendly_name();
+ auto data = outs_info.at(name);
+ IE_ASSERT(data != nullptr);
+
+ RefBlobGenerator generator;
+ auto found = outputGens.find(name);
+ if (found != outputGens.end()) {
+ generator = found->second;
+ } else {
+ found = outputGens.find("");
+ if (found != outputGens.end()) {
+ generator = found->second;
+ }
+ }
+
+ IE_ASSERT(generator != nullptr) << "Test output generator is not specified";
+ auto blob = generator(data->getTensorDesc());
+ auto blob_size = blob->byteSize();
+ auto blob_ptr = blob->buffer().as<uint8_t*>();
+
+ auto &res = res_collection[i];
+ res.resize(blob_size);
+ std::copy(blob_ptr, blob_ptr + blob_size, res.begin());
+ }
+ return res_collection;
+ }
+};
+
} // namespace LayerTestsDefinitions
if (auto_concat_out)
fill_data_with_broadcast(out, axis, vals);
else
- fill_data_with_broadcast(out, 0, {val});
+ fill_data_with_broadcast(out, 0, {val}); // broadcast scalar data
return {res};
}
TEST_P(StaticShapeLoopTest, CompareWithRefs) {
Run();
}
+
+ TEST_P(TrivialLoopTest, CheckLoad) {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED()
+ InferenceEngine::Precision iePrc;
+ InferenceEngine::SizeVector ieShape;
+ std::tie(iePrc, ieShape, targetDevice) = GetParam();
+
+ const auto prc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(iePrc);
+ const auto shape = ngraph::Shape{ieShape};
+ const auto scalarShape = ngraph::Shape{};
+
+ auto start = std::make_shared<ngraph::op::Parameter>(prc, shape);
+ auto count = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, scalarShape, 5);
+ auto icond = std::make_shared<ngraph::op::Constant>(ngraph::element::boolean, scalarShape, true);
+
+ // Loop body
+ auto b_data = std::make_shared<ngraph::op::Parameter>(prc, shape);
+ auto b_cond = std::make_shared<ngraph::op::Parameter>(ngraph::element::boolean, scalarShape);
+
+ auto body = std::make_shared<ngraph::Function>(
+ ngraph::OutputVector {b_cond, b_data}, // | passthrough body, no data changes
+ ngraph::ParameterVector {b_cond, b_data}); // | input -> output
+
+ auto loop = std::make_shared<ngraph::opset5::Loop>(count, icond);
+ loop->set_function(body);
+ loop->set_special_body_ports({-1, 0});
+ loop->set_invariant_input(b_cond, icond);
+ loop->set_invariant_input(b_data, start);
+ loop->get_iter_value(b_data, -1);
+
+ function = std::make_shared<ngraph::Function>(
+ ngraph::OutputVector {loop},
+ ngraph::ParameterVector {start});
+
+ // Precalculated ref blobs
+ auto blob = make_blob_with_precision({iePrc, ieShape, InferenceEngine::TensorDesc::getLayoutByDims(ieShape)});
+ blob->allocate();
+ CommonTestUtils::fill_data_with_broadcast(blob, 0, {10});
+
+ inputGens[""] = [&] (InferenceEngine::TensorDesc tdesc) { return blob; };
+ outputGens[""] = [&] (InferenceEngine::TensorDesc tdesc) { return blob; };
+
+ Run();
+ }
+
} // namespace LayerTestsDefinitions