Moved deprecated network iterator to legacy (#913)

* Removed deprecated iterator API

* Applied comments
This commit is contained in:
Ilya Lavrenov authored and GitHub committed 2020-06-24 11:55:17 +03:00
1 parent 94c8b9e5a7
commit 447f69c84e
33 files changed
+138 -229

No files matched your search

@@ -18,10 +18,10 @@ elseif(ARCH STREQUAL "i386")
endif()
if(DEFINED IE_MAIN_SOURCE_DIR)
set(InferenceEngine_LIBRARIES inference_engine)
set(InferenceEngine_LIBRARIES inference_engine inference_engine_plugin_api)
else()
find_package(InferenceEngineDeveloperPackage REQUIRED)
set(InferenceEngine_LIBRARIES IE::inference_engine)
set(InferenceEngine_LIBRARIES IE::inference_engine IE::inference_engine_plugin_api)
endif()
if(UNIX)
@@ -12,6 +12,7 @@
#include <map>
#include <vector>
#include <set>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
@@ -9,7 +9,6 @@
*/
#pragma once
#include <details/ie_cnn_network_iterator.hpp>
#include <details/ie_exception_conversion.hpp>
#include <ie_icnn_network.hpp>
#include <map>
@@ -210,37 +209,6 @@ public:
INFERENCE_ENGINE_DEPRECATED("Migrate to IR v10 and work with ngraph::Function directly. The method will be removed in 2021.1")
CNNLayerPtr getLayerByName(const char* layerName) const;
/**
* @deprecated Use CNNNetwork::getFunction() and work with ngraph::Function directly. The method will be removed in 2021.1
* @brief Begin layer iterator
*
* Order of layers is implementation specific,
* and can be changed in future
*
* @return Iterator pointing to a layer
*/
IE_SUPPRESS_DEPRECATED_START
INFERENCE_ENGINE_DEPRECATED("Use CNNNetwork::getFunction() and work with ngraph::Function directly. The method will be removed in 2021.1")
details::CNNNetworkIterator begin() const;
/**
* @deprecated Use CNNNetwork::getFunction() and work with ngraph::Function directly. The method will be removed in 2021.1
* @brief End layer iterator
* @return Iterator pointing to a layer
*/
INFERENCE_ENGINE_DEPRECATED("Use CNNNetwork::getFunction() and work with ngraph::Function directly. The method will be removed in 2021.1")
details::CNNNetworkIterator end() const;
IE_SUPPRESS_DEPRECATED_END
/**
* @deprecated Use CNNNetwork::layerCount() instead. The method will be removed in 2021.1
* @brief Number of layers in network object
*
* @return Number of layers.
*/
INFERENCE_ENGINE_DEPRECATED("Use CNNNetwork::layerCount() instead. The method will be removed in 2021.1")
size_t size() const;
/**
* @brief Helper method to get collect all input shapes with names of corresponding Data objects
*
@@ -5,6 +5,7 @@
#pragma once
#include <cpp/ie_cnn_network.h>
#include "details/ie_cnn_network_iterator.hpp"
#include <ie_icnn_network.hpp>
#include <cnn_network_impl.hpp>
@@ -18,18 +18,6 @@ CNNLayerPtr CNNNetwork::getLayerByName(const char* layerName) const {
return layer;
}
details::CNNNetworkIterator CNNNetwork::begin() const {
return details::CNNNetworkIterator(actual);
}
details::CNNNetworkIterator CNNNetwork::end() const {
return details::CNNNetworkIterator();
}
size_t CNNNetwork::size() const {
return std::distance(std::begin(*this), std::end(*this));
}
CNNLayer::CNNLayer(const LayerParams& prms)
: node(nullptr), name(prms.name), type(prms.type), precision(prms.precision), userValue({0}) {}
@@ -3,6 +3,7 @@
//
#include "ie_util_internal.hpp"
#include "details/ie_cnn_network_iterator.hpp"
#include <ie_layers.h>
@@ -3,6 +3,7 @@
//
#include "low_precision_transformations/transformation_context.hpp"
#include "details/ie_cnn_network_iterator.hpp"
using namespace InferenceEngine;
using namespace InferenceEngine::details;
@@ -7,6 +7,7 @@
#include <string>
#include <net_pass.h>
#include <details/ie_cnn_network_iterator.hpp>
#include <details/caseless.hpp>
#include <vpu/compile_env.hpp>
@@ -5,6 +5,7 @@
#include <gtest/gtest.h>
#include <cnn_network_impl.hpp>
#include <details/ie_cnn_network_iterator.hpp>
#include <string>
#include <sstream>
#include <fstream>
@@ -126,7 +127,8 @@ TEST(CNNNGraphImplTests, TestGetOutputAfterConvertNetwork) {
}
InferenceEngine::CNNNetwork cnnNet(ngraph);
cnnNet.begin();
// convert to old representation
cnnNet.getInputsInfo().begin()->second->getInputData()->getCreatorLayer();
cnnNet.addOutput(testLayerName);
InferenceEngine::OutputsDataMap outs = cnnNet.getOutputsInfo();
@@ -266,7 +268,8 @@ TEST(CNNNGraphImplTests, TestAddOutputFromConvertedNetwork) {
cnnNet.addOutput(testLayerName);
ASSERT_NE(nullptr, cnnNet.getFunction());
ASSERT_EQ(5, cnnNet.layerCount());
cnnNet.begin();
// convert to old representation
cnnNet.getInputsInfo().begin()->second->getInputData()->getCreatorLayer();
auto outputs = cnnNet.getOutputsInfo();
ASSERT_EQ(2, outputs.size());
ASSERT_TRUE(outputs.find("relu2") != outputs.end());
@@ -291,7 +294,8 @@ TEST(CNNNGraphImplTests, ConstantAsInternalAndExternalLayer) {
}
InferenceEngine::CNNNetwork cnnNet(ngraph);
cnnNet.begin();
// convert to old representation
cnnNet.getInputsInfo().begin()->second->getInputData()->getCreatorLayer();
ASSERT_EQ(4, cnnNet.layerCount());
}
@@ -409,15 +413,15 @@ TEST(CNNNGraphImplTests, SavePrimitivesPriority) {
</edges>
</net>
)V0G0N";
const Core ie;
Blob::Ptr weights;
const Core ie;
Blob::Ptr weights;
auto network = ie.ReadNetwork(model, weights);
auto inputInfo = network.getInputsInfo();
auto cnnLayer = inputInfo.begin()->second->getInputData()->getCreatorLayer().lock();
ASSERT_TRUE(cnnLayer);
ASSERT_NE(cnnLayer->params.find("PrimitivesPriority"), cnnLayer->params.end());
ASSERT_EQ("cpu:avx2", cnnLayer->params["PrimitivesPriority"]);
auto network = ie.ReadNetwork(model, weights);
auto inputInfo = network.getInputsInfo();
auto cnnLayer = inputInfo.begin()->second->getInputData()->getCreatorLayer().lock();
ASSERT_TRUE(cnnLayer);
ASSERT_NE(cnnLayer->params.find("PrimitivesPriority"), cnnLayer->params.end());
ASSERT_EQ("cpu:avx2", cnnLayer->params["PrimitivesPriority"]);
}
TEST(CNNNGraphImplTests, ReadFromCNNNetReader) {
@@ -472,8 +476,7 @@ TEST(CNNNGraphImplTests, ReadFromCNNNetReader) {
)V0G0N";
InferenceEngine::Core core;
CNNNetwork network = core.ReadNetwork(model, InferenceEngine::Blob::CPtr());
network.begin();
ASSERT_EQ(2, network.layerCount());
ASSERT_EQ(3, network.layerCount());
}
TEST(CNNNGraphImplTests, CanChangeInputPrecision) {
@@ -510,7 +513,8 @@ TEST(CNNNGraphImplTests, CanChangeInputPrecision) {
{
SCOPED_TRACE("Convert to old format");
cnnNet.begin();
// convert to old representation
cnnNet.getInputsInfo().begin()->second->getInputData()->getCreatorLayer();
}
{
SCOPED_TRACE("After conversion");
@@ -556,7 +560,8 @@ TEST(CNNNGraphImplTests, CanChangeInputLayout) {
{
SCOPED_TRACE("Convert to old format");
cnnNet.begin();
// convert to old representation
cnnNet.getInputsInfo().begin()->second->getInputData()->getCreatorLayer();
}
{
SCOPED_TRACE("After conversion");
@@ -602,7 +607,8 @@ TEST(CNNNGraphImplTests, CanChangeOutputPrecision) {
{
SCOPED_TRACE("Convert to old format");
cnnNet.begin();
// convert to old representation
cnnNet.getInputsInfo().begin()->second->getInputData()->getCreatorLayer();
}
{
SCOPED_TRACE("After conversion");
@@ -648,7 +654,8 @@ TEST(CNNNGraphImplTests, CanChangeOutputLayout) {
{
SCOPED_TRACE("Convert to old format");
cnnNet.begin();
// convert to old representation
cnnNet.getInputsInfo().begin()->second->getInputData()->getCreatorLayer();
}
{
SCOPED_TRACE("After conversion");
@@ -39,9 +39,12 @@ TEST_P(CNNNetworkSerializerTest, SerializeEmptyFilePathsThrowsException) {
TEST_P(CNNNetworkSerializerTest, Serialize) {
InferenceEngine::Core ie;
InferenceEngine::CNNNetwork originalNetwork = ie.ReadNetwork(_modelPath, _weightsPath);
IE_SUPPRESS_DEPRECATED_START
originalNetwork.begin();
IE_SUPPRESS_DEPRECATED_END
{
IE_SUPPRESS_DEPRECATED_START
// convert to old representation
originalNetwork.getInputsInfo().begin()->second->getInputData()->getCreatorLayer();
IE_SUPPRESS_DEPRECATED_END
}
originalNetwork.getInputsInfo().begin()->second->setPrecision(_netPrc);
originalNetwork.getOutputsInfo().begin()->second->setPrecision(_netPrc);
@@ -254,9 +254,10 @@ TEST_F(NGraphReaderTests, ReadFQNetwork) {
CommonTestUtils::fill_data(weights->buffer().as<float *>(), weights->size() / sizeof(float));
Core reader;
auto nGraph = reader.ReadNetwork(model, weights);
CNNNetwork cnn(nGraph);
auto cnn = reader.ReadNetwork(model, weights);
IE_SUPPRESS_DEPRECATED_START
cnn.begin();
// convert to old representation
cnn.getInputsInfo().begin()->second->getInputData()->getCreatorLayer();
IE_SUPPRESS_DEPRECATED_END
}
@@ -77,90 +77,3 @@ TEST_F(NGraphReaderTests, DISABLED_ReadIncorrectNetwork) {
Core reader;
ASSERT_THROW(reader.ReadNetwork(model, blob), InferenceEngine::details::InferenceEngineException);
}
TEST_F(NGraphReaderTests, ConvertNGraphFromIterator) {
std::string model = R"V0G0N(
<net name="Network" version="10">
<layers>
<layer id="0" name="data" type="Parameter" version="opset1">
<data element_type="f32" shape="1,3,227,227"/>
<output>
<port id="0" precision="FP32">
<dim>1</dim>
<dim>3</dim>
<dim>227</dim>
<dim>227</dim>
</port>
</output>
</layer>
<layer id="1" name="embedded_input__const" type="Const" version="opset1">
<data offset="0" size="139392"/>
<output>
<port id="1" precision="FP32">
<dim>96</dim>
<dim>3</dim>
<dim>11</dim>
<dim>11</dim>
</port>
</output>
</layer>
<layer id="3" name="conv1" type="Convolution" version="opset1">
<data dilations="1,1" group="1" kernel="11,11" output="96" pads_begin="0,0" pads_end="0,0" strides="4,4"/>
<input>
<port id="0" precision="FP32">
<dim>1</dim>
<dim>3</dim>
<dim>227</dim>
<dim>227</dim>
</port>
<port id="1" precision="FP32">
<dim>96</dim>
<dim>3</dim>
<dim>11</dim>
<dim>11</dim>
</port>
</input>
<output>
<port id="3" precision="FP32">
<dim>1</dim>
<dim>96</dim>
<dim>55</dim>
<dim>55</dim>
</port>
</output>
</layer>
<layer name="output" type="Result" id="2" version="opset1">
<input>
<port id="0" precision="FP32">
<dim>1</dim>
<dim>96</dim>
<dim>55</dim>
<dim>55</dim>
</port>
</input>
</layer>
</layers>
<edges>
<edge from-layer="0" from-port="0" to-layer="3" to-port="0"/>
<edge from-layer="1" from-port="1" to-layer="3" to-port="1"/>
<edge from-layer="3" from-port="3" to-layer="2" to-port="0"/>
</edges>
</net>
)V0G0N";
Blob::Ptr weights;
weights = make_shared_blob<uint8_t>(TensorDesc(Precision::U8, {139392}, Layout::C));
weights->allocate();
CommonTestUtils::fill_data(weights->buffer().as<float *>(), weights->size() / sizeof(float));
Core reader;
auto nGraph = reader.ReadNetwork(model, weights);
CNNNetwork network(nGraph);
size_t layersCount = 0;
IE_SUPPRESS_DEPRECATED_START
for (auto it = network.begin(); it != network.end(); it++, layersCount++) {}
IE_SUPPRESS_DEPRECATED_END
ASSERT_EQ(layersCount, 2);
}
@@ -9,6 +9,7 @@
#include <sstream>
#include <ie_core.hpp>
#include <details/ie_cnn_network_iterator.hpp>
#include "common_test_utils/test_common.hpp"
#include "common_test_utils/file_utils.hpp"
@@ -40,12 +41,14 @@ protected:
FuncTestUtils::compareCNNNetworks(network, cnnNetwork, false);
IE_SUPPRESS_DEPRECATED_START
for (auto it = network.begin(); it != network.end(); it++) {
auto & inetwork = static_cast<const ICNNNetwork&>(network);
for (auto it = details::CNNNetworkIterator(&inetwork); it != details::CNNNetworkIterator(); it++) {
InferenceEngine::CNNLayerPtr layer = *it;
ASSERT_NE(nullptr, layer->getNode());
}
for (auto it = cnnNetwork.begin(); it != cnnNetwork.end(); it++) {
auto & icnnnetwork = static_cast<const ICNNNetwork&>(cnnNetwork);
for (auto it = details::CNNNetworkIterator(&icnnnetwork); it != details::CNNNetworkIterator(); it++) {
InferenceEngine::CNNLayerPtr layer = *it;
ASSERT_EQ(nullptr, layer->getNode());
}
@@ -219,9 +219,10 @@ TEST_F(NGraphReaderTests, ReadReLUScalarNetwork) {
Blob::CPtr blob;
Core reader;
auto nGraph = reader.ReadNetwork(model, blob);
CNNNetwork cnetwork(nGraph);
auto cnn = reader.ReadNetwork(model, blob);
IE_SUPPRESS_DEPRECATED_START
cnetwork.begin();
// convert to old representation
cnn.getInputsInfo().begin()->second->getInputData()->getCreatorLayer();
IE_SUPPRESS_DEPRECATED_END
}
@@ -416,7 +416,6 @@ TEST_F(NGraphReshapeTests, TestInterpParameters) {
ngraph::ParameterVector{inp});
CNNNetwork cnn(ngraph_function);
cnn.begin();
std::map<std::string, InferenceEngine::SizeVector> inShape;
inShape["test"] = {1, 3, 4, 5};
cnn.reshape(inShape);
@@ -11,6 +11,7 @@
#include "ie_common.h"
#include "common_test_utils/test_common.hpp"
#include "details/ie_cnn_network_iterator.hpp"
#include <gtest/gtest.h>
@@ -41,7 +42,8 @@ protected:
private:
void triggerConversionToCNNNetwork() {
cnnNetwork.begin();
// convert to old representation
cnnNetwork.getInputsInfo().begin()->second->getInputData()->getCreatorLayer();
}
static const char s_FriendlyName[];
@@ -4,7 +4,8 @@
set(TARGET_NAME funcTestUtils)
list(APPEND EXPORT_DEPENDENCIES commonTestUtils inference_engine inference_engine_lp_transformations)
list(APPEND EXPORT_DEPENDENCIES commonTestUtils inference_engine inference_engine_legacy
inference_engine_lp_transformations)
addIeTarget(
NAME ${TARGET_NAME}
@@ -305,13 +305,6 @@ namespace FuncTestUtils {
void compareCNNNetworks(const InferenceEngine::CNNNetwork &network, const InferenceEngine::CNNNetwork &refNetwork,
bool sameNetVersions) {
if (!sameNetVersions) {
IE_SUPPRESS_DEPRECATED_START
/* call conversion of the networks to CNNNetImpl to compare CNNLayers one by one */
network.begin();
refNetwork.begin();
IE_SUPPRESS_DEPRECATED_END
}
if (network.getName() != refNetwork.getName())
THROW_IE_EXCEPTION << "CNNNetworks have different names! " << network.getName()
<< " and " << refNetwork.getName();
@@ -320,11 +313,6 @@ namespace FuncTestUtils {
THROW_IE_EXCEPTION << "CNNNetworks have different batch size! " << std::to_string(network.getBatchSize())
<< " and " << std::to_string(refNetwork.getBatchSize());
if (network.layerCount() != refNetwork.layerCount())
THROW_IE_EXCEPTION << "CNNNetworks have different numbers of layers! "
<< std::to_string(network.layerCount())
<< " and " << std::to_string(refNetwork.layerCount());
compareLayerByLayer<InferenceEngine::CNNNetwork>(network, refNetwork, sameNetVersions);
InferenceEngine::InputsDataMap newInput = network.getInputsInfo();
InferenceEngine::InputsDataMap oldInput = refNetwork.getInputsInfo();
@@ -5,6 +5,7 @@
#pragma once
#include "cpp/ie_cnn_network.h"
#include "details/ie_cnn_network_iterator.hpp"
namespace FuncTestUtils {
@@ -15,16 +16,36 @@ void compareCNNNLayers(const InferenceEngine::CNNLayerPtr &layer, const Inferenc
IE_SUPPRESS_DEPRECATED_START
template <class T>
inline void compareLayerByLayer(const T& network, const T& refNetwork, bool sameNetVersions = true) {
auto & inetwork = static_cast<const InferenceEngine::ICNNNetwork&>(network);
auto iterator = InferenceEngine::details::CNNNetworkIterator(&inetwork);
auto & irefNetwork = static_cast<const InferenceEngine::ICNNNetwork&>(refNetwork);
auto refIterator = InferenceEngine::details::CNNNetworkIterator(&irefNetwork);
auto end = InferenceEngine::details::CNNNetworkIterator();
if (network.layerCount() != refNetwork.layerCount())
THROW_IE_EXCEPTION << "CNNNetworks have different number of layers: " << network.layerCount() << " vs " << refNetwork.layerCount();
for (; iterator != end && refIterator != end; iterator++, refIterator++) {
InferenceEngine::CNNLayerPtr layer = *iterator;
InferenceEngine::CNNLayerPtr refLayer = *refIterator;
compareCNNNLayers(layer, refLayer, sameNetVersions);
}
}
template <>
inline void compareLayerByLayer(const std::vector<InferenceEngine::CNNLayerPtr>& network,
const std::vector<InferenceEngine::CNNLayerPtr>& refNetwork,
bool sameNetVersions) {
auto iterator = network.begin();
auto refIterator = refNetwork.begin();
if (network.size() != refNetwork.size())
THROW_IE_EXCEPTION << "CNNNetworks have different number of layers: " << network.size() << " vs " << refNetwork.size();
THROW_IE_EXCEPTION << "CNNNetworks have different number of layers: " <<
network.size() << " vs " << refNetwork.size();
for (; iterator != network.end() && refIterator != refNetwork.end(); iterator++, refIterator++) {
InferenceEngine::CNNLayerPtr layer = *iterator;
InferenceEngine::CNNLayerPtr refLayer = *refIterator;
compareCNNNLayers(layer, refLayer, sameNetVersions);
}
}
IE_SUPPRESS_DEPRECATED_END
} // namespace FuncTestUtils
@@ -4,6 +4,7 @@
#pragma once
#include <list>
#include <limits>
#include <gtest/gtest.h>
#include "base_matcher.hpp"
@@ -5,11 +5,11 @@
#include "classification_matcher.hpp"
#include <gtest/gtest.h>
#include <xml_helper.hpp>
#include "details/ie_cnn_network_iterator.hpp"
using namespace Regression ;
using namespace Regression :: Matchers ;
IE_SUPPRESS_DEPRECATED_START
ClassificationMatcher::ClassificationMatcher(RegressionConfig &config)
: BaseMatcher(config) {
// Get file names for files with weights and labels
@@ -67,7 +67,6 @@ ClassificationMatcher::ClassificationMatcher(RegressionConfig &config)
top = (-1 == config.topKNumbers) ? 5 : config.topKNumbers;
}
IE_SUPPRESS_DEPRECATED_END
void ClassificationMatcher::to(const std::vector <Regression::Reference::ClassificationScoringResultsForTests> &expected) {
checkResultNumber = 0;
@@ -4,6 +4,7 @@
#include <xml_helper.hpp>
#include "object_detection_matcher.hpp"
#include "details/ie_cnn_network_iterator.hpp"
#include <algorithm>
@@ -306,10 +306,12 @@ protected:
}
void updatePaddings(const CNNNetwork &network, conv_test_params& p) {
auto found = std::find_if(network.begin(), network.end(), [](const CNNLayer::Ptr& layer) {
auto & inetwork = (const ICNNNetwork &)network;
details::CNNNetworkIterator i(&inetwork), end;
auto found = std::find_if(i, end, [](const CNNLayer::Ptr& layer) {
return layer->type == "Convolution";
});
ASSERT_NE(found, network.end());
ASSERT_NE(found, end);
auto convLayer = std::dynamic_pointer_cast<ConvolutionLayer>(*found);
auto allPad = getPaddings(*convLayer.get());
p.pads_begin[X_AXIS] = allPad.begin[X_AXIS];
@@ -9,7 +9,7 @@
#include <tests_common.hpp>
#include <ie_format_parser.h>
#include <ie_layers_internal.hpp>
#include <ie_layers_internal.hpp>
#include <details/ie_cnn_network_iterator.hpp>
#include <functional_test_utils/plugin_cache.hpp>
#include "conv_ref.hpp"
@@ -186,10 +186,12 @@ std::string LayerTestHelper::propertyToString(const PropertyVector<unsigned int>
ConvolutionTestHelper::ConvolutionTestHelper(const CommonTestUtils::conv_common_params &_convParams) : LayerTestHelper("Convolution"), convParams(_convParams) {}
void ConvolutionTestHelper::updatePaddingValues(const CNNNetwork &network) {
auto found = std::find_if(network.begin(), network.end(), [this](const CNNLayer::Ptr &layer) {
auto & inetwork = (const ICNNNetwork &)network;
details::CNNNetworkIterator i(&inetwork), end;
auto found = std::find_if(i, end, [this](const CNNLayer::Ptr &layer) {
return layer->type == type;
});
ASSERT_NE(found, network.end());
ASSERT_NE(found, end);
auto castedLayer = std::dynamic_pointer_cast<ConvolutionLayer>(*found);
auto allPad = getPaddings(*castedLayer.get());
@@ -279,10 +281,12 @@ void DeformableConvolutionTestHelper::ref_fp16(const std::vector<InferenceEngine
}
void DeformableConvolutionTestHelper::updatePaddingValues(const CNNNetwork &network) {
auto found = std::find_if(network.begin(), network.end(), [this](const CNNLayer::Ptr &layer) {
auto & inetwork = (const ICNNNetwork &)network;
details::CNNNetworkIterator i(&inetwork), end;
auto found = std::find_if(i, end, [this](const CNNLayer::Ptr &layer) {
return layer->type == type;
});
ASSERT_NE(found, network.end());
ASSERT_NE(found, end);
auto castedLayer = std::dynamic_pointer_cast<ConvolutionLayer>(*found);
auto allPad = getPaddings(*castedLayer.get());
@@ -349,10 +353,12 @@ void PoolingTestHelper::ref_fp16(const std::vector<InferenceEngine::Blob::Ptr> s
}
void PoolingTestHelper::updatePaddingValues(const InferenceEngine::CNNNetwork &network) {
auto found = std::find_if(network.begin(), network.end(), [this](const CNNLayer::Ptr &layer) {
auto & inetwork = (const ICNNNetwork &)network;
details::CNNNetworkIterator i(&inetwork), end;
auto found = std::find_if(i, end, [this](const CNNLayer::Ptr &layer) {
return layer->type == type;
});
ASSERT_NE(found, network.end());
ASSERT_NE(found, end);
auto castedLayer = std::dynamic_pointer_cast<PoolingLayer>(*found);
auto allPad = getPaddings(*castedLayer.get());
@@ -6,6 +6,7 @@
#include <gtest/gtest.h>
#include <details/ie_cnn_network_tools.h>
#include <details/ie_cnn_network_iterator.hpp>
#include <ie_core.hpp>
#include <ie_plugin_config.hpp>
#include <tests_common.hpp>
@@ -35,15 +36,6 @@ using namespace InferenceEngine;
using namespace InferenceEngine::details;
using namespace InferenceEngine::PluginConfigParams;
#define CHECK_MULTI() do { \
try { \
Core ie; \
ie.GetVersions("MULTI"); \
} catch (...) { \
GTEST_SKIP(); \
} \
} while(false)\
class IEClassBasicTest : public TestsCommon {
public:
void SetUp() override {
@@ -341,7 +333,6 @@ TEST_F(IEClassBasicTest, smoke_ImportNetworkHeteroThrows) {
}
TEST_F(IEClassBasicTest, smoke_ImportNetworkMultiThrows) {
CHECK_MULTI();
InferenceEngine::Core ie;
ASSERT_THROW(ie.ImportNetwork("model", "MULTI"), InferenceEngineException);
}
@@ -462,7 +453,6 @@ TEST_P(IEClassNetworkTestP, QueryNetworkHeteroActualNoThrow) {
}
TEST_P(IEClassNetworkTestP, QueryNetworkMultiThrows) {
CHECK_MULTI();
Core ie;
ASSERT_THROW(ie.QueryNetwork(actualNetwork, "MULTI"), InferenceEngineException);
}
@@ -1240,8 +1230,6 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROAndDeviceIDThrows) {
//
TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROwithMULTINoThrow) {
CHECK_MULTI();
Core ie;
if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) {
std::string devices;
@@ -1262,7 +1250,6 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROwithMULTINoThrow) {
}
TEST_P(IEClassLoadNetworkTest, LoadNetworkMULTIwithHETERONoThrow) {
CHECK_MULTI();
Core ie;
if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) {
@@ -1287,7 +1274,6 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkMULTIwithHETERONoThrow) {
//
TEST_P(IEClassLoadNetworkTest, QueryNetworkHETEROwithMULTINoThrowv7) {
CHECK_MULTI();
Core ie;
if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) {
@@ -1316,7 +1302,6 @@ TEST_P(IEClassLoadNetworkTest, QueryNetworkHETEROwithMULTINoThrowv7) {
}
TEST_P(IEClassLoadNetworkTest, QueryNetworkMULTIwithHETERONoThrowv7) {
CHECK_MULTI();
Core ie;
if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) {
@@ -1345,7 +1330,6 @@ TEST_P(IEClassLoadNetworkTest, QueryNetworkMULTIwithHETERONoThrowv7) {
}
TEST_P(IEClassLoadNetworkTest, DISABLED_QueryNetworkHETEROWithMULTINoThrowV10) {
CHECK_MULTI();
Core ie;
if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) {
@@ -1381,7 +1365,6 @@ TEST_P(IEClassLoadNetworkTest, DISABLED_QueryNetworkHETEROWithMULTINoThrowV10) {
}
TEST_P(IEClassLoadNetworkTest, DISABLED_QueryNetworkMULTIWithHETERONoThrowV10) {
CHECK_MULTI();
Core ie;
if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) {
@@ -1419,7 +1402,6 @@ TEST_P(IEClassLoadNetworkTest, DISABLED_QueryNetworkMULTIWithHETERONoThrowV10) {
using IEClassLoadNetworkAfterCoreRecreateTest = IEClassLoadNetworkTest;
TEST_P(IEClassLoadNetworkAfterCoreRecreateTest, LoadAfterRecreateCoresAndPlugins) {
CHECK_MULTI();
Core ie;
{
auto versions = ie.GetVersions("MULTI:" + deviceName + ",CPU");
@@ -4,6 +4,7 @@
#include <gtest/gtest.h>
#include <ie_core.hpp>
#include <details/ie_cnn_network_iterator.hpp>
#include "tests_common.hpp"
#include "single_layer_common.hpp"
@@ -492,10 +493,12 @@ protected:
}
void updatePaddings(const CNNNetwork &network, conv_test_params& p) {
auto found = std::find_if(network.begin(), network.end(), [](const CNNLayer::Ptr& layer) {
auto & inetwork = static_cast<const ICNNNetwork &>(network);
details::CNNNetworkIterator i(&inetwork), end;
auto found = std::find_if(i, end, [](const CNNLayer::Ptr& layer) {
return layer->type == "Convolution";
});
ASSERT_NE(found, network.end());
ASSERT_NE(found, end);
auto convLayer = std::dynamic_pointer_cast<ConvolutionLayer>(*found);
auto allPad = getPaddings(*convLayer.get());
p.pads_begin[X_AXIS] = allPad.begin[X_AXIS];
@@ -27,6 +27,7 @@
#include <details/ie_cnn_network_tools.h>
#include "unit_test_utils/mocks/mock_icnn_network.hpp"
#include "details/ie_cnn_network_iterator.hpp"
using namespace std;
using namespace InferenceEngine;
@@ -92,7 +93,10 @@ void GNAPropagateMatcher :: match() {
std::vector<InferenceEngine::CNNLayerPtr> tiBodies;
for (auto &layer : net_original) {
const auto & inetwork = static_cast<const ICNNNetwork&>(net_original);
for (auto layerIt = details::CNNNetworkIterator(&inetwork), end = details::CNNNetworkIterator();
layerIt != end; ++layerIt) {
auto layer = *layerIt;
if (layer->type == "TensorIterator") {
auto tiBody = NetPass::TIBodySortTopologically(std::dynamic_pointer_cast<InferenceEngine::TensorIterator>(layer)->body);
tiBodies.insert(tiBodies.end(), tiBody.begin(), tiBody.end());
@@ -8,6 +8,7 @@
#include "tests_common.hpp"
#include "ir_gen_helper.hpp"
#include <ie_core.hpp>
#include "details/ie_cnn_network_iterator.hpp"
using namespace ::testing;
using namespace std;
@@ -210,8 +211,10 @@ protected:
graph.Infer(srcs, outputBlobs);
for (auto& layer : network) {
layer->params["PrimitivesPriority"] = "cpu:ref,cpu:ref_any";
const auto & inetwork = static_cast<const ICNNNetwork&>(network);
details::CNNNetworkIterator l(&inetwork), end;
for ( ; l != end; ++l) {
(*l)->params["PrimitivesPriority"] = "cpu:ref,cpu:ref_any";
}
MKLDNNGraphTestClass graph2;
graph2.CreateGraph(network);
@@ -7,6 +7,7 @@
#include "tests_common.hpp"
#include <ie_core.hpp>
#include "details/ie_cnn_network_iterator.hpp"
#include <ngraph/ngraph.hpp>
@@ -5139,7 +5140,9 @@ TEST_F(MKLDNNGraphStructureTests, TestGemmConvolutionWithConcat) {
auto graphInfer = [](InferenceEngine::CNNNetwork network, InferenceEngine::BlobMap& inBlobs,
InferenceEngine::BlobMap& outBlobs, std::string primitivesPriority) {
for (auto it = network.begin(); !primitivesPriority.empty() && it !=network.end(); it++) {
const auto & inetwork = static_cast<const InferenceEngine::ICNNNetwork&>(network);
for (auto it = InferenceEngine::details::CNNNetworkIterator(&inetwork); !primitivesPriority.empty() &&
it != InferenceEngine::details::CNNNetworkIterator(); it++) {
(*it)->params["PrimitivesPriority"] = primitivesPriority;
}
@@ -5423,7 +5426,9 @@ TEST_F(MKLDNNGraphStructureTests, TestRefPoolingWithConcat) {
auto graphInfer = [](InferenceEngine::CNNNetwork network, InferenceEngine::BlobMap& inBlobs,
InferenceEngine::BlobMap& outBlobs, std::string primitivesPriority) {
for (auto it = network.begin(); !primitivesPriority.empty() && it !=network.end(); it++) {
const auto & inetwork = static_cast<const InferenceEngine::ICNNNetwork&>(network);
for (auto it = InferenceEngine::details::CNNNetworkIterator(&inetwork); !primitivesPriority.empty() &&
it != InferenceEngine::details::CNNNetworkIterator(); it++) {
(*it)->params["PrimitivesPriority"] = primitivesPriority;
}
@@ -84,7 +84,6 @@ protected:
InferenceEngine::Core ie;
auto network = ie.ReadNetwork(model, getConvWeightsBlob(p.in1, p.conv));
network.begin(); // Call conversion from CNNNetwork NgraphImpl to CNNNetwork
std::shared_ptr<MKLDNNPlugin::Engine> score_engine(new MKLDNNPlugin::Engine());
InferenceEngine::IExecutableNetwork::Ptr exeNetwork1;
ASSERT_NO_THROW(score_engine->LoadNetwork(exeNetwork1, network, {}));
@@ -144,7 +143,6 @@ protected:
Core ie;
auto network = ie.ReadNetwork(model, getConvWeightsBlob(p.in1, p.conv));
network.begin(); // Call conversion from CNNNetwork NgraphImpl to CNNNetwork
std::shared_ptr<MKLDNNPlugin::Engine> score_engine(new MKLDNNPlugin::Engine());
InferenceEngine::IExecutableNetwork::Ptr exeNetwork1;
@@ -206,7 +204,6 @@ protected:
Core ie;
auto network = ie.ReadNetwork(model, getConvWeightsBlob(p.in1, p.conv));
network.begin(); // Call conversion from CNNNetwork NgraphImpl to CNNNetwork
std::shared_ptr<MKLDNNPlugin::Engine> score_engine(new MKLDNNPlugin::Engine());
InferenceEngine::IExecutableNetwork::Ptr exeNetwork1;
@@ -266,7 +263,6 @@ protected:
size_t weight_size = getConvWeightsSize(p.in1, p.conv1, "FP32") + getConvBiasesSize(p.conv1, "FP32") +
getConvWeightsSize(p.in2, p.conv2, "FP32") + getConvBiasesSize(p.conv2, "FP32");
auto network = ie.ReadNetwork(model, CommonTestUtils::getWeightsBlob(weight_size));
network.begin(); // Call conversion from CNNNetwork NgraphImpl to CNNNetwork
std::shared_ptr<MKLDNNPlugin::Engine> score_engine(new MKLDNNPlugin::Engine());
InferenceEngine::IExecutableNetwork::Ptr exeNetwork1;
@@ -343,7 +339,6 @@ protected:
getConvWeightsSize(p.in2, p.conv2, "FP32") + getConvBiasesSize(p.conv2, "FP32") +
getConvWeightsSize(convOutShape3, p.conv3, "FP32") + getConvBiasesSize(p.conv3, "FP32");
auto network = ie.ReadNetwork(model, CommonTestUtils::getWeightsBlob(weight_size));
network.begin(); // Call conversion from CNNNetwork NgraphImpl to CNNNetwork
std::shared_ptr<MKLDNNPlugin::Engine> score_engine(new MKLDNNPlugin::Engine());
InferenceEngine::IExecutableNetwork::Ptr exeNetwork1;
@@ -13,6 +13,7 @@
#include "ie_common.h"
#include <memory>
#include "details/ie_cnn_network_tools.h"
#include "details/ie_cnn_network_iterator.hpp"
using namespace testing;
using namespace InferenceEngine;
@@ -254,12 +255,14 @@ TEST_F(GraphToolsTest, canIterateOverCNNNetwork) {
prepareInputs(maps);
})));
std::vector<CNNLayerPtr>resultedOrder;
for (auto l : wrap) {
resultedOrder.push_back(l);
std::vector<CNNLayerPtr> resultedOrder;
const auto & inetwork = static_cast<const ICNNNetwork&>(wrap);
details::CNNNetworkIterator l(&inetwork), end;
for ( ; l != end; ++l) {
resultedOrder.push_back(*l);
}
ASSERT_EQ(wrap.size(), 8);
ASSERT_EQ(resultedOrder.size(), 8);
ASSERT_STREQ(resultedOrder[0]->name.c_str(), "2");
ASSERT_STREQ(resultedOrder[1]->name.c_str(), "6");
ASSERT_STREQ(resultedOrder[2]->name.c_str(), "1");
@@ -280,12 +283,14 @@ TEST_F(GraphToolsTest, canIterateOverCNNNetworkWithCycle) {
prepareInputs(maps);
})));
std::vector<CNNLayerPtr>resultedOrder;
for (auto l : wrap) {
resultedOrder.push_back(l);
std::vector<CNNLayerPtr> resultedOrder;
const auto & inetwork = static_cast<const ICNNNetwork&>(wrap);
details::CNNNetworkIterator l(&inetwork), end;
for (; l != end; ++l) {
resultedOrder.push_back(*l);
}
ASSERT_EQ(wrap.size(), 4);
ASSERT_EQ(resultedOrder.size(), 4);
ASSERT_STREQ(resultedOrder[0]->name.c_str(), "2");
ASSERT_STREQ(resultedOrder[1]->name.c_str(), "3");
ASSERT_STREQ(resultedOrder[2]->name.c_str(), "1");
@@ -300,7 +305,8 @@ TEST_F(GraphToolsTest, canCompareCNNNetworkIterators) {
prepareInputs(maps);
})));
auto i = std::begin(wrap);
const auto & inetwork = static_cast<const ICNNNetwork&>(wrap);
details::CNNNetworkIterator i(&inetwork);
auto i2 = i;
i2++;
@@ -317,7 +323,9 @@ TEST_F(GraphToolsTest, canIterateOverEmptyNetwork) {
prepareInputs(maps);
})));
ASSERT_EQ(std::begin(wrap), std::end(wrap));
const auto & inetwork = static_cast<const ICNNNetwork&>(wrap);
details::CNNNetworkIterator beg(&inetwork), end;
ASSERT_EQ(beg, end);
}
TEST_F(GraphToolsTest, CNNNetSwapLayersThrowsForNullPointers) {