summaryrefslogtreecommitdiff
path: root/inference-engine/include/ie_imemory_state.hpp
blob: f2bfbf811dc28ffd9b3db659ff420577981a80f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (C) 2018 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//

/**
 * @brief a header file for IMemoryState interface
 * @file ie_imemory_state.hpp
 */

#pragma once
#include <memory>
#include "details/ie_no_copy.hpp"
#include "ie_common.h"
#include "ie_blob.h"

namespace InferenceEngine {

/**
 * @brief manages data for reset operations
 */
class IMemoryState : public details::no_copy {
 public:
    using Ptr = std::shared_ptr<IMemoryState>;

    /**
     * @brief Gets name of current memory state, if length of array is not enough name is truncated by len, null terminator is inserted as well.
     * @param name preallocated buffer for receiving name
     * @param len Length of the buffer
     * @param  resp Optional: pointer to an already allocated object to contain information in case of failure
     * @return Status code of the operation: OK (0) for success
     */
    virtual StatusCode GetName(char *name, size_t len, ResponseDesc *resp) const noexcept = 0;

    /**
     * @brief reset internal memory state for relevant iexecutable network, to a value specified in SetState
     * @param  resp Optional: pointer to an already allocated object to contain information in case of failure
     * @return Status code of the operation: OK (0) for success*
     */
    virtual StatusCode Reset(ResponseDesc *resp) noexcept = 0;

    /**
     * @brief  Sets the new state that is used for all future Reset() operations as a base.
     * This method can fail if Blob size does not match the internal state size or precision
     * @param  newState is the data to use as base state
     * @param  resp Optional: pointer to an already allocated object to contain information in case of failure
     * @return Status code of the operation: OK (0) for success
    */
    virtual StatusCode SetState(Blob::Ptr newState, ResponseDesc *resp) noexcept = 0;

    /**
     * @brief returns the value of the last memory state.
     * @details Since we roll memory after each infer, we can query the input state always and still get the last state.
     * @param lastState
     * @param  resp Optional: pointer to an already allocated object to contain information in case of failure
     * @return Status code of the operation: OK (0) for success
     * */
    virtual StatusCode GetLastState(Blob::CPtr & lastState, ResponseDesc *resp) const noexcept = 0;
};

}  // namespace InferenceEngine