Publishing 2020.1 content
[platform/upstream/dldt.git] / inference-engine / include / ie_imemory_state.hpp
1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 /**
6  * @brief a header file for IMemoryState interface
7  *
8  * @file ie_imemory_state.hpp
9  */
10
11 #pragma once
12 #include <memory>
13
14 #include "details/ie_no_copy.hpp"
15 #include "ie_blob.h"
16 #include "ie_common.h"
17
18 namespace InferenceEngine {
19
20 /**
21  * @brief manages data for reset operations
22  */
23 class IMemoryState : public details::no_copy {
24 public:
25     using Ptr = std::shared_ptr<IMemoryState>;
26
27     /**
28      * @brief Gets name of current memory state, if length of array is not enough name is truncated by len, null
29      * terminator is inserted as well.
30      *
31      * @param name preallocated buffer for receiving name
32      * @param len Length of the buffer
33      * @param  resp Optional: pointer to an already allocated object to contain information in case of failure
34      * @return Status code of the operation: InferenceEngine::OK (0) for success
35      */
36     virtual StatusCode GetName(char* name, size_t len, ResponseDesc* resp) const noexcept = 0;
37
38     /**
39      * @brief reset internal memory state for relevant iexecutable network, to a value specified in SetState
40      *
41      * @param  resp Optional: pointer to an already allocated object to contain information in case of failure
42      * @return Status code of the operation: InferenceEngine::OK (0) for success*
43      */
44     virtual StatusCode Reset(ResponseDesc* resp) noexcept = 0;
45
46     /**
47      * @brief  Sets the new state that is used for all future Reset() operations as a base.
48      *
49      * This method can fail if Blob size does not match the internal state size or precision
50      *
51      * @param  newState is the data to use as base state
52      * @param  resp Optional: pointer to an already allocated object to contain information in case of failure
53      * @return Status code of the operation: InferenceEngine::OK (0) for success
54      */
55     virtual StatusCode SetState(Blob::Ptr newState, ResponseDesc* resp) noexcept = 0;
56
57     /**
58      * @brief returns the value of the last memory state.
59      *
60      * @details Since we roll memory after each infer, we can query the input state always and still get the last state.
61      * @param lastState
62      * @param  resp Optional: pointer to an already allocated object to contain information in case of failure
63      * @return Status code of the operation: InferenceEngine::OK (0) for success
64      * */
65     virtual StatusCode GetLastState(Blob::CPtr& lastState, ResponseDesc* resp) const noexcept = 0;
66 };
67
68 }  // namespace InferenceEngine