ONE - On-device Neural Engine
Loading...
Searching...
No Matches
StaticMemoryManager.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 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#ifdef USE_STATIC_ALLOC
18
19#include "StaticMemoryManager.h"
20
21namespace luci_interpreter
22{
23
25{
26 assert(_buffer_ptr != nullptr);
27 return _buffer_ptr + offset;
28}
29
30uint8_t *StaticMemoryManager::allocate_memory_for_input(int32_t offset)
31{
32 assert(_input_buffer_ptr != nullptr);
33 return _input_buffer_ptr + offset;
34}
35
36uint8_t *StaticMemoryManager::allocate_memory_for_output(int32_t offset)
37{
38 assert(_output_buffer_ptr != nullptr);
39 return _output_buffer_ptr + offset;
40}
41
42void StaticMemoryManager::allocate_input_buf()
43{
44 assert(_input_req_size > 0);
45 if (_input_buffer_ptr == nullptr)
46 _input_buffer_ptr = new uint8_t[_input_req_size];
47}
48
49void StaticMemoryManager::allocate_output_buf()
50{
51 assert(_output_req_size > 0);
52 if (_output_buffer_ptr == nullptr)
53 _output_buffer_ptr = new uint8_t[_output_req_size];
54}
55
56void StaticMemoryManager::allocate_computing_buf()
57{
58 assert(_buffer_req_size > 0);
59 if (_buffer_ptr == nullptr)
60 _buffer_ptr = new uint8_t[_buffer_req_size];
61}
62
63void StaticMemoryManager::release_computing_buf()
64{
65 delete[] _buffer_ptr;
66 _buffer_ptr = nullptr;
67}
68
69void StaticMemoryManager::release_input_buf()
70{
71 delete[] _input_buffer_ptr;
72 _input_buffer_ptr = nullptr;
73}
74
75void StaticMemoryManager::release_output_buf()
76{
77 delete[] _output_buffer_ptr;
78 _output_buffer_ptr = nullptr;
79}
80
81} // namespace luci_interpreter
82
83#endif // USE_STATIC_ALLOC
void allocate_memory(luci_interpreter::Tensor &tensor) final
__global uchar * offset(const Image *img, int x, int y)
Definition helpers.h:540