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
e762262e
Commit
e762262e
authored
Mar 21, 2019
by
pruthvi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change CPU allocator to accept the framework allocators
parent
e8ebfa27
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
23 deletions
+29
-23
cpu_allocator.cpp
src/ngraph/runtime/cpu/cpu_allocator.cpp
+6
-20
cpu_allocator.hpp
src/ngraph/runtime/cpu/cpu_allocator.hpp
+21
-2
cpu_call_frame.cpp
src/ngraph/runtime/cpu/cpu_call_frame.cpp
+2
-1
No files found.
src/ngraph/runtime/cpu/cpu_allocator.cpp
View file @
e762262e
...
...
@@ -22,31 +22,17 @@ namespace ngraph
{
namespace
cpu
{
CPUAllocator
::
CPUAllocator
()
{}
CPUAllocator
::
CPUAllocator
(
runtime
::
AllocateFunc
alloc
,
runtime
::
DestroyFunc
dealloc
)
:
m_alloc
(
alloc
)
,
m_dealloc
(
dealloc
)
{
}
CPUAllocator
::~
CPUAllocator
()
{}
CPUAllocator
&
GetCPUAllocator
()
{
static
CPUAllocator
cpu_allocator
;
static
CPUAllocator
cpu_allocator
(
nullptr
,
nullptr
)
;
return
cpu_allocator
;
}
}
}
}
/*ngraph::runtime::SystemAllocator::SystemAllocator()
{
}
ngraph::runtime::SystemAllocator::~SystemAllocator()
{
}
ngraph::runtime::FrameworkAllocator::~FrameworkAllocator()
{
}
ngraph::runtime::FrameworkAllocator::FrameworkAllocator(AllocateFunc& allocator,
DestroyFunc& deallocator)
: m_allocator(allocator)
, m_deallocator(deallocator)
{
}*/
src/ngraph/runtime/cpu/cpu_allocator.hpp
View file @
e762262e
...
...
@@ -56,12 +56,20 @@ namespace ngraph
class
ngraph
::
runtime
::
cpu
::
CPUAllocator
:
public
ngraph
::
runtime
::
Allocator
{
public
:
CPUAllocator
();
CPUAllocator
(
runtime
::
AllocateFunc
alloc
,
runtime
::
DestroyFunc
dealloc
);
~
CPUAllocator
();
void
*
Malloc
(
void
*
handle
,
size_t
size
,
size_t
alignment
)
{
void
*
ptr
=
malloc
(
size
);
void
*
ptr
;
if
(
m_alloc
)
{
ptr
=
m_alloc
(
handle
,
size
,
alignment
);
}
else
{
ptr
=
malloc
(
size
);
}
// check for exception
if
(
size
!=
0
&&
!
ptr
)
{
...
...
@@ -73,8 +81,19 @@ public:
void
Free
(
void
*
handle
,
void
*
ptr
)
{
if
(
ptr
)
{
if
(
m_dealloc
)
{
m_dealloc
(
handle
,
ptr
);
}
else
{
free
(
ptr
);
}
}
}
private
:
runtime
::
AllocateFunc
m_alloc
;
runtime
::
DestroyFunc
m_dealloc
;
};
src/ngraph/runtime/cpu/cpu_call_frame.cpp
View file @
e762262e
...
...
@@ -143,7 +143,8 @@ void runtime::cpu::CPU_CallFrame::setup_runtime_context()
// Create temporary buffer pools
size_t
alignment
=
runtime
::
cpu
::
CPU_ExternalFunction
::
s_memory_pool_alignment
;
ngraph
::
runtime
::
Allocator
*
allocator
=
new
ngraph
::
runtime
::
cpu
::
CPUAllocator
();
ngraph
::
runtime
::
Allocator
*
allocator
=
new
ngraph
::
runtime
::
cpu
::
CPUAllocator
(
nullptr
,
nullptr
);
/*if (m_framework_allocator && m_framework_deallocator)
{
auto fw_allocator =
...
...
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