1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief A header file that provides Allocator interface
7 * @file ie_allocator.hpp
11 #include <details/ie_irelease.hpp>
14 namespace InferenceEngine {
17 * @brief Allocator handle mapping type
25 * @brief Allocator concept to be used for memory management and is used as part of the Blob.
27 class IAllocator : public details::IRelease {
30 * @brief Maps handle to heap memory accessible by any memory manipulation routines.
31 * @return Generic pointer to memory
33 virtual void * lock(void * handle, LockOp = LOCK_FOR_WRITE) noexcept = 0;
35 * @brief Unmaps memory by handle with multiple sequential mappings of the same handle.
36 * The multiple sequential mappings of the same handle are suppose to get the same
37 * result while there isn't a ref counter supported.
39 virtual void unlock(void * handle) noexcept = 0;
41 * @brief Allocates memory
42 * @param size The size in bytes to allocate
43 * @return Handle to the allocated resource
45 virtual void * alloc(size_t size) noexcept = 0;
47 * @brief Releases handle and all associated memory resources which invalidates the handle.
48 * @return false if handle cannot be released, otherwise - true.
50 virtual bool free(void* handle) noexcept = 0;
54 * @brief Disables the ability of deleting the object without release.
56 ~IAllocator()override = default;
60 * @brief Creates the default implementation of the Inference Engine allocator per plugin.
61 * @return The Inference Engine IAllocator* instance
63 INFERENCE_ENGINE_API(InferenceEngine::IAllocator*)CreateDefaultAllocator() noexcept;
65 } // namespace InferenceEngine