blob: b9f5f5cc9bb922f2892d44cbc041eef02bc65300 (
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
62
63
64
65
|
// Copyright (C) 2018 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
/**
* @brief A header file that provides Allocator interface
* @file ie_allocator.hpp
*/
#pragma once
#include <details/ie_irelease.hpp>
#include <ie_api.h>
namespace InferenceEngine {
/**
* @brief Allocator handle mapping type
*/
enum LockOp {
LOCK_FOR_READ = 0,
LOCK_FOR_WRITE
};
/**
* @brief Allocator concept to be used for memory management and is used as part of the Blob.
*/
class IAllocator : public details::IRelease {
public:
/**
* @brief Maps handle to heap memory accessible by any memory manipulation routines.
* @return Generic pointer to memory
*/
virtual void * lock(void * handle, LockOp = LOCK_FOR_WRITE) noexcept = 0;
/**
* @brief Unmaps memory by handle with multiple sequential mappings of the same handle.
* The multiple sequential mappings of the same handle are suppose to get the same
* result while there isn't a ref counter supported.
*/
virtual void unlock(void * handle) noexcept = 0;
/**
* @brief Allocates memory
* @param size The size in bytes to allocate
* @return Handle to the allocated resource
*/
virtual void * alloc(size_t size) noexcept = 0;
/**
* @brief Releases handle and all associated memory resources which invalidates the handle.
* @return false if handle cannot be released, otherwise - true.
*/
virtual bool free(void* handle) noexcept = 0;
protected:
/**
* @brief Disables the ability of deleting the object without release.
*/
~IAllocator()override = default;
};
/**
* @brief Creates the default implementation of the Inference Engine allocator per plugin.
* @return The Inference Engine IAllocator* instance
*/
INFERENCE_ENGINE_API(InferenceEngine::IAllocator*)CreateDefaultAllocator() noexcept;
} // namespace InferenceEngine
|