1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief A header file that provides interface for network reader that is used to build networks from a given IR
8 * @file ie_icnn_net_reader.h
15 #include "details/ie_no_copy.hpp"
18 #include "ie_common.h"
19 #include "ie_icnn_network.hpp"
21 namespace InferenceEngine {
23 * @brief This class is the main interface to build and parse a network from a given IR
25 * All methods here do not throw exceptions and return a StatusCode and ResponseDesc object.
26 * Alternatively, to use methods that throw exceptions, refer to the CNNNetReader wrapper class.
28 class INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::Core::ReadNetwork() method this API will be removed in 2020 R2")
29 ICNNNetReader : public details::IRelease {
32 * @brief Parses the topology part of the IR (.xml)
34 * This method can be called once only to read network. If you need to read another network instance then create new
37 * @param filepath The full path to the .xml file of the IR
38 * @param resp Response message
41 virtual StatusCode ReadNetwork(const char* filepath, ResponseDesc* resp) noexcept = 0;
44 * @brief Parses the topology part of the IR (.xml) given the xml as a buffer
46 * This method can be called once only to read network. If you need to read another network instance then create new
49 * @param model Pointer to a char array with the IR
50 * @param resp Response message
51 * @param size Size of the char array in bytes
54 virtual StatusCode ReadNetwork(const void* model, size_t size, ResponseDesc* resp) noexcept = 0;
57 * @brief Sets the weights buffer (.bin part) from the IR.
59 * Weights Blob must always be of bytes - the casting to precision is done per-layer to support mixed
60 * networks and to ease of use.
61 * This method can be called more than once to reflect updates in the .bin.
63 * @param weights Blob of bytes that holds all the IR binary data
64 * @param resp Response message
67 virtual StatusCode SetWeights(const TBlob<uint8_t>::Ptr& weights, ResponseDesc* resp) noexcept = 0;
70 * @brief Loads and sets the weights buffer directly from the IR .bin file.
72 * This method can be called more than once to reflect updates in the .bin.
74 * @param filepath Full path to the .bin file
75 * @param resp Response message
78 virtual StatusCode ReadWeights(const char* filepath, ResponseDesc* resp) noexcept = 0;
81 * @brief Returns a pointer to the built network
83 * @param resp Response message
85 virtual ICNNNetwork* getNetwork(ResponseDesc* resp) noexcept = 0;
88 * @brief Retrieves the last building status
90 * @param resp Response message
92 virtual bool isParseSuccess(ResponseDesc* resp) noexcept = 0;
95 * @brief Retrieves the last building failure message if failed
97 * @param resp Response message
98 * @return StatusCode that indicates the network status
100 virtual StatusCode getDescription(ResponseDesc* resp) noexcept = 0;
103 * @brief Gets network name
105 * @param name Pointer to preallocated buffer that receives network name
106 * @param len Length of the preallocated buffer, network name will be trimmed by this lenght
107 * @param resp Response message
108 * @return Result code
110 virtual StatusCode getName(char* name, size_t len, ResponseDesc* resp) noexcept = 0;
113 * @brief Returns a version of IR
115 * @param resp Response message
116 * @return IR version number: 1 or 2
118 virtual int getVersion(ResponseDesc* resp) noexcept = 0;
122 * @brief Creates a CNNNetReader instance
124 * @return An object that implements the ICNNNetReader interface
126 IE_SUPPRESS_DEPRECATED_START
127 INFERENCE_ENGINE_API(ICNNNetReader*) CreateCNNNetReader() noexcept;
128 IE_SUPPRESS_DEPRECATED_END
129 } // namespace InferenceEngine