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
3ca1b5ba
Commit
3ca1b5ba
authored
May 17, 2019
by
Robert Kimball
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
63055ecd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
3 deletions
+54
-3
executable.cpp
src/ngraph/runtime/executable.cpp
+8
-0
tensor.hpp
src/ngraph/runtime/tensor.hpp
+2
-0
async.cpp
test/async.cpp
+44
-3
No files found.
src/ngraph/runtime/executable.cpp
View file @
3ca1b5ba
...
@@ -128,6 +128,14 @@ bool runtime::Executable::begin_execute_helper(const vector<shared_ptr<runtime::
...
@@ -128,6 +128,14 @@ bool runtime::Executable::begin_execute_helper(const vector<shared_ptr<runtime::
const
vector
<
shared_ptr
<
runtime
::
Tensor
>>&
inputs
)
const
vector
<
shared_ptr
<
runtime
::
Tensor
>>&
inputs
)
{
{
bool
rc
=
call
(
outputs
,
inputs
);
bool
rc
=
call
(
outputs
,
inputs
);
for
(
const
shared_ptr
<
runtime
::
Tensor
>&
t
:
outputs
)
{
t
->
m_promise
.
set_value
();
}
for
(
const
shared_ptr
<
runtime
::
Tensor
>&
t
:
inputs
)
{
t
->
m_promise
.
set_value
();
}
return
rc
;
return
rc
;
}
}
...
...
src/ngraph/runtime/tensor.hpp
View file @
3ca1b5ba
...
@@ -38,6 +38,8 @@ namespace ngraph
...
@@ -38,6 +38,8 @@ namespace ngraph
{
{
class
Tensor
class
Tensor
{
{
friend
class
Executable
;
protected
:
protected
:
Tensor
(
const
std
::
shared_ptr
<
ngraph
::
descriptor
::
Tensor
>&
descriptor
)
Tensor
(
const
std
::
shared_ptr
<
ngraph
::
descriptor
::
Tensor
>&
descriptor
)
:
m_descriptor
(
descriptor
)
:
m_descriptor
(
descriptor
)
...
...
test/async.cpp
View file @
3ca1b5ba
...
@@ -43,18 +43,59 @@ TEST(async, execute)
...
@@ -43,18 +43,59 @@ TEST(async, execute)
auto
handle
=
backend
->
compile
(
f
);
auto
handle
=
backend
->
compile
(
f
);
auto
future
=
handle
->
begin_execute
({
r
},
{
a
,
b
});
auto
future
=
handle
->
begin_execute
({
r
},
{
a
,
b
});
ASSERT_TRUE
(
future
.
valid
());
bool
rc
=
future
.
get
();
bool
rc
=
future
.
get
();
for
(
float
x
:
result_data
)
for
(
float
x
:
result_data
)
{
{
ASSERT_EQ
(
x
,
2
);
ASSERT_EQ
(
x
,
4
);
}
}
}
}
TEST
(
async
,
tensor_
read
)
TEST
(
async
,
tensor_
write
)
{
{
Shape
shape
{
100000
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Add
>
(
A
,
B
),
ParameterVector
{
A
,
B
});
auto
backend
=
runtime
::
Backend
::
create
(
"INTERPRETER"
);
auto
handle
=
backend
->
compile
(
f
);
vector
<
float
>
data
(
shape_size
(
shape
),
2
);
vector
<
float
>
result_data
(
shape_size
(
shape
),
0
);
// Create some tensors for input/output
shared_ptr
<
runtime
::
Tensor
>
a
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
shared_ptr
<
runtime
::
Tensor
>
b
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
shared_ptr
<
runtime
::
Tensor
>
r
=
backend
->
create_tensor
(
element
::
f32
,
shape
,
result_data
.
data
());
auto
future_a
=
a
->
begin_write
(
data
.
data
(),
data
.
size
()
*
sizeof
(
float
));
auto
future_b
=
b
->
begin_write
(
data
.
data
(),
data
.
size
()
*
sizeof
(
float
));
ASSERT_TRUE
(
future_a
.
valid
());
ASSERT_TRUE
(
future_b
.
valid
());
chrono
::
milliseconds
ten_ms
(
10
);
EXPECT_EQ
(
future_a
.
wait_for
(
ten_ms
),
future_status
::
timeout
);
EXPECT_EQ
(
future_b
.
wait_for
(
ten_ms
),
future_status
::
timeout
);
this_thread
::
sleep_for
(
chrono
::
milliseconds
(
500
));
EXPECT_EQ
(
future_a
.
wait_for
(
ten_ms
),
future_status
::
timeout
);
EXPECT_EQ
(
future_b
.
wait_for
(
ten_ms
),
future_status
::
timeout
);
auto
future
=
handle
->
begin_execute
({
r
},
{
a
,
b
});
bool
rc
=
future
.
get
();
EXPECT_EQ
(
future_a
.
wait_for
(
ten_ms
),
future_status
::
ready
);
EXPECT_EQ
(
future_b
.
wait_for
(
ten_ms
),
future_status
::
ready
);
for
(
float
x
:
result_data
)
{
ASSERT_EQ
(
x
,
4
);
}
}
}
TEST
(
async
,
tensor_
write
)
TEST
(
async
,
tensor_
read
)
{
{
}
}
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