Imported Upstream version 1.4.0
[platform/core/ml/nnfw.git] / runtime / onert / backend / cpu_common / Allocator.h
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file        Allocator.h
19  * @brief       This file contains Allocator related classes
20  */
21
22 #ifndef __ONERT_BACKEND_CPU_COMMON_ALLOCATOR_H__
23 #define __ONERT_BACKEND_CPU_COMMON_ALLOCATOR_H__
24
25 #include <memory>
26
27 namespace onert
28 {
29 namespace backend
30 {
31 namespace cpu_common
32 {
33
34 /**
35  * @brief Class to allocate memory
36  */
37 class Allocator
38 {
39 public:
40   Allocator(uint32_t capacity);
41   /**
42    * @brief Get memory base pointer
43    * @return base pointer
44    */
45   uint8_t *base() const { return _base.get(); }
46   void release() { _base.reset(); }
47
48 private:
49   std::unique_ptr<uint8_t[]> _base;
50 };
51
52 } // namespace cpu_common
53 } // namespace backend
54 } // namespace onert
55
56 #endif // __ONERT_BACKEND_CPU_COMMON_ALLOCATOR_H__