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
9c2230aa
Commit
9c2230aa
authored
Jun 25, 2019
by
fenglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test
parent
a2ef00f4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
2 deletions
+36
-2
recv.cpp
src/ngraph/op/recv.cpp
+1
-1
send.cpp
src/ngraph/op/send.cpp
+1
-1
distributed.in.cpp
test/distributed.in.cpp
+34
-0
No files found.
src/ngraph/op/recv.cpp
View file @
9c2230aa
...
...
@@ -22,7 +22,7 @@ using namespace ngraph;
const
string
op
::
Recv
::
type_name
{
"Recv"
};
op
::
Recv
::
Recv
(
const
Output
<
Node
>&
arg
,
int
src_id
)
:
Op
(
check_single_output_args
({
arg
})
)
:
Op
(
{
arg
}
)
,
m_src_id
(
src_id
)
{
constructor_validate_and_infer_types
();
...
...
src/ngraph/op/send.cpp
View file @
9c2230aa
...
...
@@ -22,7 +22,7 @@ using namespace ngraph;
const
string
op
::
Send
::
type_name
{
"Send"
};
op
::
Send
::
Send
(
const
Output
<
Node
>&
arg
,
int
dest_id
)
:
Op
(
check_single_output_args
({
arg
})
)
:
Op
(
{
arg
}
)
,
m_dest_id
(
dest_id
)
{
constructor_validate_and_infer_types
();
...
...
test/distributed.in.cpp
View file @
9c2230aa
...
...
@@ -140,3 +140,37 @@ TEST(distributed_${BACKEND_NAME}, broadcastdistributed)
EXPECT_EQ
(
v
,
read_vector
<
float
>
(
result
));
}
}
TEST
(
distributed_
$
{
BACKEND_NAME
},
send_recv
)
{
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
comm_size
=
get_distributed_interface
()
->
get_size
();
if
(
comm_size
!=
2
)
{
return
;
}
auto
rank
=
get_distributed_interface
()
->
get_rank
();
std
::
shared_ptr
<
Function
>
f
;
if
(
rank
==
0
)
{
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Send
>
(
A
,
1
),
ParameterVector
{
A
});
}
else
{
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Recv
>
(
A
,
0
),
ParameterVector
{
A
});
}
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
);
auto
v
=
vector
<
float
>
{
1
,
2
,
3
,
4
};
auto
result
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
copy_data
(
result
,
vector
<
float
>
(
4
,
0
));
if
(
rank
==
0
)
{
copy_data
(
result
,
v
);
}
auto
handle
=
backend
->
compile
(
f
);
handle
->
call_with_validate
({
result
},
{
result
});
EXPECT_EQ
(
v
,
read_vector
<
float
>
(
result
));
}
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