1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
9 #include <ie_icnn_network.hpp>
10 #include "ie_common.h"
11 #include "gna_plugin_log.hpp"
13 namespace GNAPluginNS {
15 using CNNNetworkPtr = std::shared_ptr<InferenceEngine::ICNNNetwork>;
18 InferenceEngine::TargetDevice device;
19 InferenceEngine::Precision networkPrec;
20 std::function<CNNNetworkPtr(InferenceEngine::ICNNNetwork &network)> convert;
22 Endpoint(InferenceEngine::TargetDevice device,
23 InferenceEngine::Precision networkPrec,
24 std::function<CNNNetworkPtr(InferenceEngine::ICNNNetwork &network)> converter = [](InferenceEngine::ICNNNetwork &network) {
25 return CNNNetworkPtr(&network, [](InferenceEngine::ICNNNetwork *nodelete) {});
26 }) : device(device), networkPrec(networkPrec), convert(converter) {
32 using Desc = std::vector<Endpoint>;
34 InferenceEngine::TargetDevice _defaultDevice = InferenceEngine::TargetDevice::eDefault;
37 explicit Config(std::vector<Endpoint> &&config)
38 : supported(std::move(config)) {
42 * @brief default device value is plugin dependent, so it should be also set, to allow fallback
44 void setDefaultDevice(InferenceEngine::TargetDevice d) {
48 inline Endpoint find_configuration(InferenceEngine::ICNNNetwork &network) {
49 auto device = network.getTargetDevice();
50 auto targetDevice = device == InferenceEngine::TargetDevice::eDefault ? _defaultDevice : device;
52 auto res = std::find_if(std::begin(supported), std::end(supported), [&](Endpoint &e) {
53 return e.networkPrec == network.getPrecision() && (
55 e.device == targetDevice);
58 if (res == std::end(supported)) {
59 THROW_GNA_EXCEPTION << "\"The plugin doesn't support target device: "
60 << InferenceEngine::TargetDeviceInfo::name(network.getTargetDevice())
61 << ".\nSupported target device: " << InferenceEngine::TargetDeviceInfo::name(InferenceEngine::TargetDevice::eGNA);
67 } // namespace GNAPluginNS