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
17c33415
Unverified
Commit
17c33415
authored
6 years ago
by
Jayaram Bobba
Committed by
GitHub
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make temp memory pools static to avoid memory allocation overheads (#941)
parent
cd0f4fbd
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
20 deletions
+26
-20
cpu_external_function.cpp
src/ngraph/runtime/cpu/cpu_external_function.cpp
+26
-20
No files found.
src/ngraph/runtime/cpu/cpu_external_function.cpp
View file @
17c33415
...
...
@@ -551,6 +551,30 @@ using namespace ngraph::runtime;
}
}
bool
temporaries_used
=
false
;
size_t
worst_case_tmp_size
=
0
;
for
(
shared_ptr
<
Node
>
node
:
ordered_ops
)
{
if
(
node
->
liveness_new_list
.
size
()
>
0
)
{
temporaries_used
=
true
;
for
(
descriptor
::
Tensor
*
tensor
:
node
->
liveness_new_list
)
{
worst_case_tmp_size
+=
tensor
->
size
();
}
}
}
if
(
temporaries_used
)
{
size_t
temp_pool_size
=
current_function
->
get_temporary_pool_size
();
writer
<<
"// Allocate the memory pool
\n
"
;
writer
<<
"// Memory pool size is "
<<
temp_pool_size
<<
" bytes
\n
"
;
writer
<<
"// Worst case size is "
<<
worst_case_tmp_size
<<
" bytes
\n
"
;
writer
<<
"ngraph::runtime::AlignedBuffer "
<<
current_function
->
get_name
()
<<
"_memory_handler("
<<
temp_pool_size
<<
", "
<<
s_memory_pool_alignment
<<
");
\n
"
;
}
writer
<<
"extern
\"
C
\"
void "
<<
current_function
->
get_name
();
writer
<<
"(void** inputs, void** outputs, cpu::CPURuntimeContext* ctx)
\n
"
;
writer
<<
"{
\n
"
;
...
...
@@ -569,28 +593,10 @@ using namespace ngraph::runtime;
<<
"int profiler_count = 0;
\n\n
"
;
}
bool
temporaries_used
=
false
;
size_t
worst_case_tmp_size
=
0
;
for
(
shared_ptr
<
Node
>
node
:
ordered_ops
)
{
if
(
node
->
liveness_new_list
.
size
()
>
0
)
{
temporaries_used
=
true
;
for
(
descriptor
::
Tensor
*
tensor
:
node
->
liveness_new_list
)
{
worst_case_tmp_size
+=
tensor
->
size
();
}
}
}
if
(
temporaries_used
)
{
size_t
temp_pool_size
=
current_function
->
get_temporary_pool_size
();
writer
<<
"// Allocate the memory pool
\n
"
;
writer
<<
"// Memory pool size is "
<<
temp_pool_size
<<
" bytes
\n
"
;
writer
<<
"// Worst case size is "
<<
worst_case_tmp_size
<<
" bytes
\n
"
;
writer
<<
"ngraph::runtime::AlignedBuffer memory_handler("
<<
temp_pool_size
<<
", "
<<
s_memory_pool_alignment
<<
");
\n
"
;
writer
<<
"size_t pool_base_ptr = (size_t)memory_handler.get_ptr();
\n
"
;
writer
<<
"size_t pool_base_ptr = (size_t)"
<<
current_function
->
get_name
()
<<
"_memory_handler.get_ptr();
\n
"
;
writer
<<
"
\n
"
;
// Add temporaries to the variable name map
...
...
This diff is collapsed.
Click to expand it.
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