Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
0165b27e
Unverified
Commit
0165b27e
authored
Jul 08, 2018
by
Robert Kimball
Committed by
GitHub
Jul 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Memory Layout pass optimizations (#1212)
* Memory Layout pass optimizations * rename SIMPLE memory allocator
parent
e3d95453
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
memory_layout.cpp
src/ngraph/pass/memory_layout.cpp
+11
-5
memory_layout.hpp
src/ngraph/pass/memory_layout.hpp
+4
-2
No files found.
src/ngraph/pass/memory_layout.cpp
View file @
0165b27e
...
...
@@ -35,7 +35,7 @@ pass::MemoryLayout::MemoryLayout(size_t alignment, bool disable_memory_sharing)
bool
pass
::
MemoryLayout
::
run_on_function
(
shared_ptr
<
ngraph
::
Function
>
function
)
{
MemoryManager
mm
(
m_alignment
);
MemoryManager
mm
(
m_alignment
,
m_disable_memory_sharing
);
for
(
shared_ptr
<
Node
>
node
:
function
->
get_ordered_ops
())
{
std
::
map
<
descriptor
::
Tensor
*
,
descriptor
::
Tensor
*>
in_place_outputs
;
...
...
@@ -53,8 +53,6 @@ bool pass::MemoryLayout::run_on_function(shared_ptr<ngraph::Function> function)
if
(
node
->
liveness_free_list
.
count
(
input
)
!=
0
&&
node
->
liveness_new_list
.
count
(
output
)
!=
0
)
{
NGRAPH_DEBUG
<<
input
->
get_name
()
<<
" will be reused for "
<<
output
->
get_name
();
in_place_outputs
.
insert
({
output
,
input
});
reused_inputs
.
insert
(
input
);
}
...
...
@@ -93,9 +91,9 @@ pass::MemoryManager::node::node(size_t size, block_state state)
{
}
pass
::
MemoryManager
::
MemoryManager
(
size_t
alignment
)
pass
::
MemoryManager
::
MemoryManager
(
size_t
alignment
,
bool
disable_memory_reuse
)
:
m_alignment
{
alignment
}
,
m_scheme
{
allocation_scheme
::
BE
ST_FIT
}
,
m_scheme
{
disable_memory_reuse
?
allocation_scheme
::
NO_REUSE
:
allocation_scheme
::
FIR
ST_FIT
}
,
m_max_allocated
{
0
}
{
// assert(m_base_offset % m_alignment == 0);
...
...
@@ -109,10 +107,18 @@ size_t pass::MemoryManager::allocate(size_t size)
{
case
allocation_scheme
:
:
FIRST_FIT
:
rc
=
first_fit
(
size
);
break
;
case
allocation_scheme
:
:
BEST_FIT
:
rc
=
best_fit
(
size
);
break
;
case
allocation_scheme
:
:
NO_REUSE
:
rc
=
no_reuse_allocator
(
size
);
break
;
}
return
rc
;
}
size_t
pass
::
MemoryManager
::
no_reuse_allocator
(
size_t
size
)
{
size_t
offset
=
m_max_allocated
;
m_max_allocated
+=
align
(
size
,
m_alignment
);
return
offset
;
}
size_t
pass
::
MemoryManager
::
best_fit
(
size_t
size
)
{
size
=
align
(
size
,
m_alignment
);
...
...
src/ngraph/pass/memory_layout.hpp
View file @
0165b27e
...
...
@@ -55,7 +55,8 @@ public:
enum
class
allocation_scheme
{
FIRST_FIT
,
BEST_FIT
BEST_FIT
,
NO_REUSE
};
class
node
...
...
@@ -68,7 +69,7 @@ public:
block_state
m_state
;
};
MemoryManager
(
size_t
alignment
=
1
);
MemoryManager
(
size_t
alignment
=
1
,
bool
disable_reuse
=
false
);
// memory_manager& alignment(size_t a);
size_t
allocate
(
size_t
size
);
...
...
@@ -87,6 +88,7 @@ public:
private
:
size_t
first_fit
(
size_t
size
);
size_t
best_fit
(
size_t
size
);
size_t
no_reuse_allocator
(
size_t
size
);
std
::
list
<
node
>
m_node_list
;
size_t
m_alignment
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment