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
a07588df
Commit
a07588df
authored
Mar 19, 2019
by
pruthvi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- move Allocator abstract class to runtime namespace
- provide default implementation for allocator and deallocators
parent
43b1b2cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
allocator.cpp
src/ngraph/runtime/allocator.cpp
+38
-0
allocator.hpp
src/ngraph/runtime/allocator.hpp
+39
-0
No files found.
src/ngraph/runtime/allocator.cpp
0 → 100644
View file @
a07588df
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include "ngraph/runtime/allocator.hpp"
void
*
ngraph
::
runtime
::
Allocator
::
Malloc
(
void
*
,
size_t
size
,
size_t
alignment
)
{
void
*
ptr
=
malloc
(
size
);
// check for exception
if
(
size
!=
0
&&
!
ptr
)
{
throw
ngraph_error
(
"malloc failed to allocate memory of size "
+
std
::
to_string
(
size
));
throw
std
::
bad_alloc
();
}
return
ptr
;
}
void
ngraph
::
runtime
::
Allocator
::
Free
(
void
*
ptr
,
void
*
)
{
if
(
ptr
)
{
free
(
ptr
);
}
}
src/ngraph/runtime/allocator.hpp
0 → 100644
View file @
a07588df
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include "ngraph/except.hpp"
#include "ngraph/util.hpp"
namespace
ngraph
{
namespace
runtime
{
class
Allocator
;
}
}
// Abstarct class for the allocator, for allocating and deallocating device memory
class
ngraph
::
runtime
::
Allocator
{
public
:
virtual
~
Allocator
()
=
default
;
virtual
void
*
Malloc
(
void
*
,
size_t
size
,
size_t
alignment
);
virtual
void
Free
(
void
*
ptr
,
void
*
);
};
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