1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 #include <unordered_set>
7 #include <ie_icnn_network.hpp>
8 #include <graph_tools.hpp>
9 #include "gna_layer_type.hpp"
10 #include "gna_layer_info.hpp"
12 GNAPluginNS::LayerType GNAPluginNS::LayerTypeFromStr(const std::string &str) {
13 auto it = LayerNameToType.find(str);
14 if (it != LayerNameToType.end())
20 bool GNAPluginNS::AreLayersSupported(InferenceEngine::ICNNNetwork& network, std::string& errMessage) {
21 IE_SUPPRESS_DEPRECATED_START
22 InferenceEngine::CNNLayerSet inputLayers;
23 InferenceEngine::InputsDataMap inputs;
24 std::unordered_set<InferenceEngine::CNNLayer *> allLayers;
25 network.getInputsInfo(inputs);
26 IE_ASSERT(!inputs.empty());
27 auto network_input_precision = inputs.begin()->second->getPrecision();
28 auto batch_size = network.getBatchSize();
30 if (network_input_precision != InferenceEngine::Precision::FP32 &&
31 network_input_precision != InferenceEngine::Precision::I16 &&
32 network_input_precision != InferenceEngine::Precision::U8) {
33 errMessage = "The plugin does not support input precision with " + std::string(network_input_precision.name()) + " format. Supported input precisions "
39 errMessage = "Network is empty (GNA)\n";
43 auto & secondLayers = inputs.begin()->second->getInputData()->getInputTo();
44 if (secondLayers.empty()) {
45 errMessage = "Network consists of input layer only (GNA)\n";
49 bool check_result = true;
50 InferenceEngine::details::UnorderedDFS(allLayers,
51 secondLayers.begin()->second,
52 [&](const InferenceEngine::CNNLayerPtr layer) {
53 if (LayerTypeFromStr(layer->type) == LayerType::NO_TYPE) {
54 errMessage = "The plugin does not support layer: " + layer->name + ":" + layer->type + "\n";
57 if (batch_size != 1 && LayerInfo::isBatchSizeConstrained(layer->type)) {
58 errMessage = "topology with layer: " + layer->name + ", type: " + layer->type +
59 ", and batch size(" + std::to_string(batch_size) + ") != 1 not supported";
63 IE_SUPPRESS_DEPRECATED_END