1 // Copyright (C) 2018-2019 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
7 * @file ie_icnn_net_reader.h
15 #include "ie_common.h"
16 #include "ie_icnn_network.hpp"
17 #include "details/ie_no_copy.hpp"
20 namespace InferenceEngine {
22 * @brief This class is the main interface to build and parse a network from a given IR
24 * All methods here do not throw exceptions and return a StatusCode and ResponseDesc object.
25 * Alternatively, to use methods that throw exceptions, refer to the CNNNetReader wrapper class.
27 class ICNNNetReader : public details::IRelease {
30 * @brief Parses the topology part of the IR (.xml)
31 * This method can be called once only to read network. If you need to read another network instance then create new reader instance.
32 * @param filepath The full path to the .xml file of the IR
33 * @param resp Response message
36 virtual StatusCode ReadNetwork(const char *filepath, ResponseDesc *resp) noexcept = 0;
39 * @brief Parses the topology part of the IR (.xml) given the xml as a buffer
40 * This method can be called once only to read network. If you need to read another network instance then create new reader instance.
41 * @param model Pointer to a char array with the IR
42 * @param resp Response message
43 * @param size Size of the char array in bytes
46 virtual StatusCode ReadNetwork(const void *model, size_t size, ResponseDesc *resp) noexcept = 0;
49 * @brief Sets the weights buffer (.bin part) from the IR.
50 * Weights Blob must always be of bytes - the casting to precision is done per-layer to support mixed
51 * networks and to ease of use.
52 * This method can be called more than once to reflect updates in the .bin.
53 * @param weights Blob of bytes that holds all the IR binary data
54 * @param resp Response message
57 virtual StatusCode SetWeights(const TBlob<uint8_t>::Ptr &weights, ResponseDesc *resp) noexcept = 0;
60 * @brief Loads and sets the weights buffer directly from the IR .bin file.
61 * This method can be called more than once to reflect updates in the .bin.
62 * @param filepath Full path to the .bin file
63 * @param resp Response message
66 virtual StatusCode ReadWeights(const char *filepath, ResponseDesc *resp) noexcept = 0;
69 * @brief Returns a pointer to the built network
70 * @param resp Response message
72 virtual ICNNNetwork *getNetwork(ResponseDesc *resp) noexcept = 0;
75 * @brief Retrieves the last building status
76 * @param resp Response message
78 virtual bool isParseSuccess(ResponseDesc *resp) noexcept = 0;
81 * @brief Retrieves the last building failure message if failed
82 * @param resp Response message
83 * @return StatusCode that indicates the network status
85 virtual StatusCode getDescription(ResponseDesc *resp) noexcept = 0;
88 * @brief Gets network name
89 * @param name Pointer to preallocated buffer that receives network name
90 * @param len Length of the preallocated buffer, network name will be trimmed by this lenght
91 * @param resp Response message
94 virtual StatusCode getName(char *name, size_t len, ResponseDesc *resp) noexcept = 0;
97 * @brief Returns a version of IR
98 * @param resp Response message
99 * @return IR version number: 1 or 2
101 virtual int getVersion(ResponseDesc *resp) noexcept = 0;
105 * @brief Creates a CNNNetReader instance
106 * @return An object that implements the ICNNNetReader interface
108 INFERENCE_ENGINE_API(ICNNNetReader*)CreateCNNNetReader() noexcept;
109 } // namespace InferenceEngine