ONE - On-device Neural Engine
Loading...
Searching...
No Matches
StaticMemoryManager.h
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
#ifndef LUCI_INTERPRETER_STATIC_MEMORY_MANAGER_H
20
#define LUCI_INTERPRETER_STATIC_MEMORY_MANAGER_H
21
22
#include "luci_interpreter/core/DataType.h"
23
#include "luci_interpreter/core/Tensor.h"
24
25
#include <cassert>
26
27
namespace
luci_interpreter
28
{
29
30
// Used for allocations in static buffer, using offsets defined in luci model.
31
class
StaticMemoryManager
32
{
33
public
:
34
StaticMemoryManager
() =
delete
;
35
36
// To initialize static memory manager with precalculating required buffers size for input,
37
// output and for intermediate computations buffers.
38
// Using Static Memory Manager with common buffer for input, output, and for intermediate
39
// computations
40
// TODO remove this *_req_size to read it from circle file
41
explicit
StaticMemoryManager
(int32_t
input_req_size
, int32_t
buffer_req_size
,
42
int32_t
output_req_size
)
43
:
_input_buffer_ptr
(
nullptr
), _buffer_ptr(
nullptr
),
_output_buffer_ptr
(
nullptr
),
44
_input_req_size
(
input_req_size
),
_buffer_req_size
(
buffer_req_size
),
45
_output_req_size
(
output_req_size
)
46
{
/* Do nothing */
47
}
48
49
// To set a pointer for tensor in _buffer_ptr with right offset
50
uint8_t
*
allocate_memory
(int32_t
offset
);
51
// To set a pointer for tensor in input_buffer with right offset
52
uint8_t
*
allocate_memory_for_input
(int32_t
offset
);
53
// To set a pointer for tensor in output_buffer with right offset
54
uint8_t
*
allocate_memory_for_output
(int32_t
offset
);
55
56
// Methods to set data pointer for tensor
57
// To allocate input memory buffer with _input_req_size * size_type bytes. Result pointer -
58
// _input_buffer_ptr
59
void
allocate_input_buf
();
60
// To allocate input memory buffer with _output_req_size * size_type bytes. Result pointer -
61
// _output_buffer_ptr
62
void
allocate_output_buf
();
63
// To allocate intermediate computing memory buffer with _buffer_req_size * size_type bytes.
64
// Result pointer - _buffer_ptr
65
void
allocate_computing_buf
();
66
67
// To delete memory for intermediate computing buffer
68
void
release_computing_buf
();
69
// To delete memory for input buffer
70
void
release_input_buf
();
71
// To delete memory for output buffer
72
void
release_output_buf
();
73
74
private
:
75
// Stores a pointer to the beginning of the allocated memory buffer.
76
uint8_t
*_buffer_ptr;
77
uint8_t
*
_input_buffer_ptr
;
78
uint8_t
*
_output_buffer_ptr
;
79
80
// TODO remove this fields to read it from circle file
81
int32_t
_input_req_size
{};
82
int32_t
_buffer_req_size
{};
83
int32_t
_output_req_size
{};
84
};
85
86
}
// namespace luci_interpreter
87
88
#endif
// LUCI_INTERPRETER_STATIC_MEMORY_MANAGER_H
89
90
#endif
// USE_STATIC_ALLOC
luci_interpreter::StaticMemoryManager::allocate_memory
void allocate_memory(luci_interpreter::Tensor &tensor) final
Definition
StaticMemoryManager.cpp:22
luci_interpreter::StaticMemoryManager::StaticMemoryManager
StaticMemoryManager()=delete
offset
__global uchar * offset(const Image *img, int x, int y)
Definition
helpers.h:540
luci_interpreter
Definition
BuddyMemoryManager.h:22
luci::must_cast
T must_cast(loco::Node *node)
Definition
CircleNodeDecl.h:95
onert-micro
luci-interpreter
src
memory_managers
StaticMemoryManager.h
Generated by
1.9.8