ie_imemory_state.hpp
Go to the documentation of this file.
1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 /**
6  * @brief a header file for IVariableState interface
7  *
8  * @file ie_imemory_state.hpp
9  */
10 
11 #pragma once
12 
13 #include <memory>
14 
15 #include "ie_blob.h"
16 #include "ie_common.h"
17 #include "details/ie_no_copy.hpp"
18 
19 namespace InferenceEngine {
20 
21 /**
22  * @interface IVariableState
23  * @brief Manages data for reset operations
24  */
25 class IVariableState : public details::no_copy {
26 public:
27  /**
28  * @brief A shared pointer to the IVariableState interface
29  */
30  using Ptr = std::shared_ptr<IVariableState>;
31 
32  /**
33  * @brief Gets name of current variable state, if length of array is not enough name is truncated by len, null
34  * terminator is inserted as well. As variable state name `variable_id` from according `ReadValue` used.
35  *
36  * @param name preallocated buffer for receiving name
37  * @param len Length of the buffer
38  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
39  * @return Status code of the operation: InferenceEngine::OK (0) for success
40  */
41  virtual StatusCode GetName(char* name, size_t len, ResponseDesc* resp) const noexcept = 0;
42 
43  /**
44  * @brief Reset internal variable state for relevant infer request, to a value specified as default for according ReadValue node
45  *
46  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
47  * @return Status code of the operation: InferenceEngine::OK (0) for success*
48  */
49  virtual StatusCode Reset(ResponseDesc* resp) noexcept = 0;
50 
51  /**
52  * @brief Sets the new state for the next inference.
53  *
54  * This method can fail if Blob size does not match the internal state size or precision
55  *
56  * @param newState The data to use as new state
57  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
58  * @return Status code of the operation: InferenceEngine::OK (0) for success
59  */
60  virtual StatusCode SetState(Blob::Ptr newState, ResponseDesc* resp) noexcept = 0;
61 
62  /**
63  * @brief Returns the value of the variable state.
64  *
65  * @param state A reference to a blob containing a variable state
66  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
67  * @return Status code of the operation: InferenceEngine::OK (0) for success
68  */
69  INFERENCE_ENGINE_DEPRECATED("Use GetState function instead")
70  virtual StatusCode GetLastState(Blob::CPtr& state, ResponseDesc* resp) const noexcept {
71  return GetState(state, resp);
72  }
73 
74  /**
75  * @brief Returns the value of the variable state.
76  *
77  * @param state A reference to a blob containing a variable state
78  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
79  * @return Status code of the operation: InferenceEngine::OK (0) for success
80  */
81  virtual StatusCode GetState(Blob::CPtr& state, ResponseDesc* resp) const noexcept = 0;
82 };
83 
84 /**
85  * @brief For compatibility reasons.
86  */
88 
89 } // namespace InferenceEngine
This class represents a universal container in the Inference Engine.
Definition: ie_blob.h:38
std::shared_ptr< const Blob > CPtr
A smart pointer to the const Blob object.
Definition: ie_blob.h:48
std::shared_ptr< Blob > Ptr
A smart pointer containing Blob object.
Definition: ie_blob.h:43
Manages data for reset operations.
Definition: ie_imemory_state.hpp:25
virtual StatusCode GetLastState(Blob::CPtr &state, ResponseDesc *resp) const noexcept
Returns the value of the variable state.
Definition: ie_imemory_state.hpp:70
virtual StatusCode GetState(Blob::CPtr &state, ResponseDesc *resp) const noexcept=0
Returns the value of the variable state.
virtual StatusCode GetName(char *name, size_t len, ResponseDesc *resp) const noexcept=0
Gets name of current variable state, if length of array is not enough name is truncated by len,...
std::shared_ptr< IVariableState > Ptr
A shared pointer to the IVariableState interface.
Definition: ie_imemory_state.hpp:30
virtual StatusCode SetState(Blob::Ptr newState, ResponseDesc *resp) noexcept=0
Sets the new state for the next inference.
virtual StatusCode Reset(ResponseDesc *resp) noexcept=0
Reset internal variable state for relevant infer request, to a value specified as default for accordi...
A header file for Blob and generic TBlob<>
This is a header file with common inference engine definitions.
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:222
header file for no_copy class
Represents detailed information for an error.
Definition: ie_common.h:245