1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief This is a header file for the Network reader class (wrapper) used to build networks from a given IR
7 * @file ie_cnn_net_reader.h
16 #include "ie_cnn_network.h"
17 #include "ie_common.h"
18 #include "ie_icnn_net_reader.h"
19 #include "details/ie_exception_conversion.hpp"
21 namespace InferenceEngine {
23 * @brief This is a wrapper class used to build and parse a network from the given IR.
24 * All the methods here can throw exceptions.
29 * @brief A smart pointer to this class
31 using Ptr = std::shared_ptr<CNNNetReader>;
34 * @brief A default constructor
36 CNNNetReader() : actual(shared_from_irelease(InferenceEngine::CreateCNNNetReader())) {}
39 * @brief Wraps original method
40 * ICNNNetReader::ReadNetwork
42 void ReadNetwork(const std::string &filepath) {
43 CALL_STATUS_FNC(ReadNetwork, filepath.c_str());
47 * @brief Wraps original method
48 * ICNNNetReader::ReadNetwork(const void*, size_t, ResponseDesc*)
50 void ReadNetwork(const void *model, size_t size) {
51 CALL_STATUS_FNC(ReadNetwork, model, size);
55 * @brief Wraps original method
56 * ICNNNetReader::SetWeights
58 void SetWeights(const TBlob<uint8_t>::Ptr &weights) const {
59 CALL_STATUS_FNC(SetWeights, weights);
63 * @brief Wraps original method
64 * ICNNNetReader::ReadWeights
66 void ReadWeights(const std::string &filepath) const {
67 CALL_STATUS_FNC(ReadWeights, filepath.c_str());
71 * @brief Gets a copy of built network object
72 * @return A copy of the CNNNetwork object to be loaded
74 CNNNetwork getNetwork() {
75 // network obj are to be updated upon this call
76 if (network.get() == nullptr) {
78 network.reset(new CNNNetwork(actual));
80 THROW_IE_EXCEPTION << "Could not allocate memory";
83 return *network.get();
87 * @brief Wraps original method
88 * ICNNNetReader::isParseSuccess
90 bool isParseSuccess() const {
91 CALL_FNC_NO_ARGS(isParseSuccess);
95 * @brief Wraps original method
96 * ICNNNetReader::getDescription
98 std::string getDescription() const {
99 CALL_STATUS_FNC_NO_ARGS(getDescription);
104 * @brief Wraps original method
105 * ICNNNetReader::getName
107 std::string getName() const {
109 CALL_STATUS_FNC(getName, name, sizeof(name) / sizeof(*name));
114 * @brief Wraps original method
115 * ICNNNetReader::getVersion
117 int getVersion() const {
118 CALL_FNC_NO_ARGS(getVersion);
122 std::shared_ptr<ICNNNetReader> actual;
123 std::shared_ptr<CNNNetwork> network;
125 } // namespace InferenceEngine