Imported Upstream version 1.9.0
[platform/core/ml/nnfw.git] / runtime / onert / backend / acl_cl / TensorManager.h
1 /*
2  * Copyright (c) 2019 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 #ifndef __ONERT_BACKEND_ACL_CL_TENSOR_MANAGER_H__
18 #define __ONERT_BACKEND_ACL_CL_TENSOR_MANAGER_H__
19
20 #include <arm_compute/runtime/CL/CLBufferAllocator.h>
21 #include <arm_compute/runtime/PoolManager.h>
22 #include <arm_compute/runtime/BlobLifetimeManager.h>
23 #include <arm_compute/runtime/MemoryManagerOnDemand.h>
24 #include <arm_compute/runtime/MemoryGroup.h>
25
26 #include <AclMemoryManager.h>
27 #include <AclLinearMemoryManager.h>
28 #include <AclInternalBufferManager.h>
29 #include <AclTensorManager.h>
30
31 #include "operand/CLTensor.h"
32 #include "operand/CLSubTensor.h"
33
34 #include "util/logging.h"
35
36 namespace onert
37 {
38 namespace backend
39 {
40 namespace acl_cl
41 {
42
43 using MemoryManager =
44     acl_common::AclMemoryManager<operand::ICLTensor, operand::CLTensor, operand::CLSubTensor>;
45
46 using LinearMemoryManager = acl_common::AclLinearMemoryManager<
47     operand::ICLTensor, operand::CLTensor, operand::CLSubTensor,
48     ::arm_compute::MemoryManagerOnDemand, ::arm_compute::PoolManager,
49     ::arm_compute::BlobLifetimeManager, ::arm_compute::CLBufferAllocator,
50     ::arm_compute::MemoryGroup>;
51
52 using InternalBufferManager = acl_common::AclInternalBufferManager<
53     ::arm_compute::MemoryManagerOnDemand, ::arm_compute::PoolManager,
54     ::arm_compute::BlobLifetimeManager, ::arm_compute::CLBufferAllocator>;
55
56 using TensorManager =
57     acl_common::AclTensorManager<operand::ICLTensor, operand::CLTensor, operand::CLSubTensor>;
58
59 inline TensorManager *createTensorManager(bool is_linear_executor)
60 {
61   if (is_linear_executor)
62   {
63     VERBOSE(acl_cl_createTensorManager) << "AclTensorManager as Linear" << std::endl;
64     return new TensorManager(new MemoryManager(), new LinearMemoryManager(),
65                              new InternalBufferManager());
66   }
67   else
68   {
69     VERBOSE(acl_cl_createTensorManager) << "AclTensorManager" << std::endl;
70     return new TensorManager(new MemoryManager(), new MemoryManager(), new InternalBufferManager());
71   }
72 }
73
74 } // namespace acl_cl
75 } // namespace backend
76 } // namespace onert
77
78 #endif // __ONERT_BACKEND_ACL_CL_TENSOR_MANAGER_H__