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
9970c680
Commit
9970c680
authored
5 years ago
by
Robert Kimball
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
6430acb6
master
v0.29.0-rc.0
v0.28.0-rc.1
v0.28.0-rc.0
v0.27.1-rc.3
v0.27.1-rc.2
v0.27.1-rc.1
v0.27.1-rc.0
v0.27.0-rc.1
v0.27.0-rc.0
v0.26.1-rc.0
v0.26.0
v0.26.0-rc.8
v0.26.0-rc.7
v0.26.0-rc.6
v0.26.0-rc.5
v0.26.0-rc.4
v0.26.0-rc.3
v0.26.0-rc.2
v0.26.0-rc.0
v0.25.1-rc.11
v0.25.1-rc.10
v0.25.1-rc.9
v0.25.1-rc.8
v0.25.1-rc.7
v0.25.1-rc.6
v0.25.1-rc.5
v0.25.1-rc.4
v0.25.1-rc.3
v0.25.1-rc.2
v0.25.1-rc.1
v0.25.1-rc.0
v0.25.0
v0.25.0-rc.3
v0.25.0-rc.2
v0.25.0-rc.1
v0.25.0-rc.0
v0.25.0-dev.0
v0.24.0
v0.24.0-rc.3
v0.24.0-rc.2
v0.24.0-rc.1
v0.24.0-rc.0
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
21 deletions
+53
-21
backend.cpp
src/ngraph/runtime/backend.cpp
+11
-2
backend.hpp
src/ngraph/runtime/backend.hpp
+13
-4
tensor.cpp
src/ngraph/runtime/tensor.cpp
+18
-8
tensor.hpp
src/ngraph/runtime/tensor.hpp
+8
-4
async.cpp
test/async.cpp
+3
-3
No files found.
src/ngraph/runtime/backend.cpp
View file @
9970c680
...
...
@@ -91,8 +91,12 @@ std::shared_ptr<runtime::Executable> runtime::Backend::load(istream& input_strea
throw
runtime_error
(
"load opertion unimplemented."
);
}
runtime
::
Backend
::
AsyncEvent
::
AsyncEvent
(
Type
type
,
void
*
p
,
size_t
size_in_bytes
)
runtime
::
Backend
::
AsyncEvent
::
AsyncEvent
(
Type
type
,
size_t
buffer_number
,
void
*
p
,
size_t
size_in_bytes
)
:
m_type
{
type
}
,
m_buffer_number
{
buffer_number
}
,
m_data
{
p
}
,
m_size_in_bytes
{
size_in_bytes
}
,
m_executable
{
nullptr
}
...
...
@@ -101,10 +105,12 @@ runtime::Backend::AsyncEvent::AsyncEvent(Type type, void* p, size_t size_in_byte
{
}
runtime
::
Backend
::
AsyncEvent
::
AsyncEvent
(
const
shared_ptr
<
Executable
>&
executable
,
runtime
::
Backend
::
AsyncEvent
::
AsyncEvent
(
size_t
buffer_number
,
const
shared_ptr
<
Executable
>&
executable
,
const
vector
<
shared_ptr
<
runtime
::
Tensor
>>&
outputs
,
const
vector
<
shared_ptr
<
runtime
::
Tensor
>>&
inputs
)
:
m_type
{
Type
::
EXECUTE
}
,
m_buffer_number
{
buffer_number
}
,
m_data
{
nullptr
}
,
m_size_in_bytes
{
0
}
,
m_executable
{
executable
}
...
...
@@ -115,12 +121,14 @@ runtime::Backend::AsyncEvent::AsyncEvent(const shared_ptr<Executable>& executabl
void
runtime
::
Backend
::
post_async_read_event
(
void
*
p
,
size_t
size_in_bytes
,
size_t
buffer_number
,
std
::
promise
<
void
>&
promise
)
{
}
void
runtime
::
Backend
::
post_async_write_event
(
const
void
*
p
,
size_t
size_in_bytes
,
size_t
buffer_number
,
std
::
promise
<
void
>&
promise
)
{
}
...
...
@@ -129,6 +137,7 @@ void runtime::Backend::post_async_execute_event(
const
std
::
shared_ptr
<
Executable
>&
executable
,
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>&
outputs
,
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>&
inputs
,
size_t
buffer_number
,
std
::
promise
<
void
>&
promise
)
{
}
This diff is collapsed.
Click to expand it.
src/ngraph/runtime/backend.hpp
View file @
9970c680
...
...
@@ -163,11 +163,13 @@ protected:
}
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>*
get_inputs
()
const
{
return
m_inputs
;
}
private
:
AsyncEvent
(
Type
,
void
*
p
,
size_t
size_in_bytes
);
AsyncEvent
(
const
std
::
shared_ptr
<
Executable
>&
m_executable
,
AsyncEvent
(
Type
type
,
size_t
buffer_number
,
void
*
p
,
size_t
size_in_bytes
);
AsyncEvent
(
size_t
buffer_number
,
const
std
::
shared_ptr
<
Executable
>&
m_executable
,
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>&
m_outputs
,
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>&
m_inputs
);
const
Type
m_type
;
size_t
m_buffer_number
;
void
*
m_data
;
const
size_t
m_size_in_bytes
;
std
::
shared_ptr
<
Executable
>
m_executable
;
...
...
@@ -175,10 +177,17 @@ protected:
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>*
m_inputs
;
};
void
post_async_read_event
(
void
*
p
,
size_t
size_in_bytes
,
std
::
promise
<
void
>&
promise
);
void
post_async_write_event
(
const
void
*
p
,
size_t
size_in_bytes
,
std
::
promise
<
void
>&
promise
);
void
post_async_read_event
(
void
*
p
,
size_t
size_in_bytes
,
size_t
buffer_number
,
std
::
promise
<
void
>&
promise
);
void
post_async_write_event
(
const
void
*
p
,
size_t
size_in_bytes
,
size_t
buffer_number
,
std
::
promise
<
void
>&
promise
);
void
post_async_execute_event
(
const
std
::
shared_ptr
<
Executable
>&
executable
,
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>&
outputs
,
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>&
inputs
,
size_t
buffer_number
,
std
::
promise
<
void
>&
promise
);
};
This diff is collapsed.
Click to expand it.
src/ngraph/runtime/tensor.cpp
View file @
9970c680
...
...
@@ -98,12 +98,12 @@ void runtime::Tensor::copy_from(const ngraph::runtime::Tensor& source)
write
(
buffer
.
get_ptr
(),
0
,
size
);
}
future
<
void
>
runtime
::
Tensor
::
begin_write
(
const
void
*
p
,
size_t
n
)
future
<
void
>
runtime
::
Tensor
::
begin_write
(
const
void
*
p
,
size_t
size_in_bytes
,
size_t
buffer_number
)
{
if
(
m_backend
)
{
auto
f
=
m_promise
.
get_future
();
m_backend
->
post_async_write_event
(
p
,
n
,
m_promise
);
m_backend
->
post_async_write_event
(
p
,
size_in_bytes
,
buffer_number
,
m_promise
);
return
f
;
}
else
...
...
@@ -117,11 +117,21 @@ future<void> runtime::Tensor::begin_write(const void* p, size_t n)
// return f;
}
future
<
void
>
runtime
::
Tensor
::
begin_read
(
void
*
p
,
size_t
n
)
future
<
void
>
runtime
::
Tensor
::
begin_read
(
void
*
p
,
size_t
size_in_bytes
,
size_t
buffer_number
)
{
using
namespace
std
::
placeholders
;
auto
f
=
m_promise
.
get_future
();
auto
bound_f
=
bind
(
&
Tensor
::
read
,
this
,
_1
,
_2
,
_3
);
async
(
bound_f
,
p
,
0
,
n
);
return
f
;
if
(
m_backend
)
{
auto
f
=
m_promise
.
get_future
();
m_backend
->
post_async_read_event
(
p
,
size_in_bytes
,
buffer_number
,
m_promise
);
return
f
;
}
else
{
throw
runtime_error
(
"Async operations not supported for this backend"
);
}
// using namespace std::placeholders;
// auto f = m_promise.get_future();
// auto bound_f = bind(&Tensor::read, this, _1, _2, _3);
// async(bound_f, p, 0, n);
// return f;
}
This diff is collapsed.
Click to expand it.
src/ngraph/runtime/tensor.hpp
View file @
9970c680
...
...
@@ -119,16 +119,20 @@ namespace ngraph
/// \brief Write bytes into the tensor. The data buffer pointed to by `p` must
/// be kept live until after the future is signaled complete
/// \param p Pointer to source of data
/// \param n Number of bytes to write, must be integral number of elements.
/// \param size_in_bytes Number of bytes to write, must be integral number of elements.
/// \param buffer_number For double-buffering, which buffer to write.
/// \return std::future to track the operation
virtual
std
::
future
<
void
>
begin_write
(
const
void
*
p
,
size_t
n
);
virtual
std
::
future
<
void
>
begin_write
(
const
void
*
p
,
size_t
size_in_bytes
,
size_t
buffer_number
);
/// \brief Read bytes from the tensor. The data buffer pointed to by `p` must
/// be kept live until after the future is signaled complete
/// \param p Pointer to destination for data
/// \param n Number of bytes to read, must be integral number of elements.
/// \param size_in_bytes Number of bytes to read, must be integral number of elements.
/// \param buffer_number For double-buffering, which buffer to read.
/// \return std::future to track the operation
virtual
std
::
future
<
void
>
begin_read
(
void
*
p
,
size_t
n
);
virtual
std
::
future
<
void
>
begin_read
(
void
*
p
,
size_t
size_in_bytes
,
size_t
buffer_number
);
/// \brief copy bytes directly from source to this tensor
/// \param source The source tensor
...
...
This diff is collapsed.
Click to expand it.
test/async.cpp
View file @
9970c680
...
...
@@ -70,9 +70,9 @@ TEST(async, tensor_read_write)
shared_ptr
<
runtime
::
Tensor
>
b
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
shared_ptr
<
runtime
::
Tensor
>
r
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
auto
future_a
=
a
->
begin_write
(
data
.
data
(),
data
.
size
()
*
sizeof
(
float
));
auto
future_b
=
b
->
begin_write
(
data
.
data
(),
data
.
size
()
*
sizeof
(
float
));
auto
future_r
=
r
->
begin_read
(
data_r
.
data
(),
data_r
.
size
()
*
sizeof
(
float
));
auto
future_a
=
a
->
begin_write
(
data
.
data
(),
data
.
size
()
*
sizeof
(
float
)
,
0
);
auto
future_b
=
b
->
begin_write
(
data
.
data
(),
data
.
size
()
*
sizeof
(
float
)
,
0
);
auto
future_r
=
r
->
begin_read
(
data_r
.
data
(),
data_r
.
size
()
*
sizeof
(
float
)
,
0
);
ASSERT_TRUE
(
future_a
.
valid
());
ASSERT_TRUE
(
future_b
.
valid
());
ASSERT_TRUE
(
future_r
.
valid
());
...
...
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