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
60523801
Commit
60523801
authored
May 25, 2018
by
Fenglei
Committed by
Robert Kimball
May 25, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add gpu product (#1040)
* add gpu product * enable test, change initial value for product
parent
2177cf5b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
18 deletions
+49
-18
gpu_emitter.cpp
src/ngraph/runtime/gpu/gpu_emitter.cpp
+44
-0
unit_test.manifest
src/ngraph/runtime/gpu/unit_test.manifest
+0
-14
backend_test.in.cpp
test/backend_test.in.cpp
+5
-4
No files found.
src/ngraph/runtime/gpu/gpu_emitter.cpp
View file @
60523801
...
...
@@ -1316,6 +1316,50 @@ CUDNN_SAFE_CALL(cudnnSetOpTensorDescriptor(opTensorDesc,
return
;
}
template
<>
void
GPU_Emitter
::
EMITTER_DECL
(
ngraph
::
op
::
Product
)
{
const
ngraph
::
op
::
Product
*
product
=
static_cast
<
const
ngraph
::
op
::
Product
*>
(
node
);
writer
.
block_begin
(
" // "
+
node
->
get_name
());
{
if
(
out
[
0
].
get_size
()
!=
0
)
{
// one of args[] axes has zero size, fill output with 1
if
(
args
[
0
].
get_size
()
==
0
)
{
writer
<<
"float init_value = 1;
\n
"
;
writer
<<
"std::vector<float> temp("
<<
out
[
0
].
get_size
()
<<
", init_value);
\n
"
;
writer
<<
"runtime::gpu::cuda_memcpyHtD("
<<
out
[
0
].
get_name
()
<<
", (void*)temp.data(), "
<<
out
[
0
].
get_size
()
<<
" * "
<<
out
[
0
].
get_element_type
().
size
()
<<
");
\n
"
;
}
else
if
(
args
[
0
].
get_shape
().
size
()
==
out
[
0
].
get_shape
().
size
())
{
kernel
::
emit_memcpyDtD
(
writer
,
out
[
0
],
args
[
0
]);
}
// descriptors for tensors with <= 4 dimensions
else
{
auto
&
cudnn_emitter
=
external_function
->
get_primitive_emitter
()
->
get_cudnn_emitter
();
auto
index
=
cudnn_emitter
->
build_reduce_forward
(
external_function
->
ctx
().
get
(),
CUDNN_REDUCE_TENSOR_MUL
,
args
[
0
].
get_shape
(),
product
->
get_reduction_axes
());
writer
<<
"gpu::invoke_primitive(ctx, "
<<
index
<<
", "
;
writer
<<
"std::vector<void*>{"
<<
args
[
0
].
get_name
()
<<
"}.data(), "
;
writer
<<
"std::vector<void*>{"
<<
out
[
0
].
get_name
()
<<
"}.data()"
;
writer
<<
");
\n
"
;
}
}
}
writer
.
block_end
();
return
;
}
template
<>
void
GPU_Emitter
::
EMITTER_DECL
(
ngraph
::
op
::
Reduce
)
{
...
...
src/ngraph/runtime/gpu/unit_test.manifest
View file @
60523801
...
...
@@ -83,20 +83,6 @@ one_hot_vector_1_barely_oob
one_hot_vector_1_far_oob
one_hot_vector_1_fp_nonint
parameter_as_output
product_3d_eliminate_zero_dim
product_3d_to_matrix_least_sig
product_3d_to_matrix_most_sig
product_3d_to_scalar
product_3d_to_vector
product_matrix_cols_zero
product_matrix_columns
product_matrix_rows
product_matrix_rows_zero
product_matrix_to_scalar_zero_by_zero
product_to_scalar
product_trivial
product_trivial_5d
product_vector_zero
reduce_window_emulating_max_pool_1d_1channel_1image
reduce_window_emulating_max_pool_1d_1channel_2image
reduce_window_emulating_max_pool_1d_2channel_2image
...
...
test/backend_test.in.cpp
View file @
60523801
...
...
@@ -6805,10 +6805,11 @@ NGRAPH_TEST(${BACKEND_NAME}, product_3d_to_scalar)
auto
result
=
backend
->
create_tensor
(
element
::
f32
,
shape_rt
);
backend
->
call
(
f
,
{
result
},
{
a
});
EXPECT_EQ
((
vector
<
float
>
{
1.0
f
*
10.0
f
*
9.0
f
*
4.0
f
*
13.0
f
*
6.0
f
*
7.0
f
*
12.0
f
*
3.0
f
*
2.0
f
*
11.0
f
*
8.0
f
*
5.0
f
*
14.0
f
*
5.0
f
*
8.0
f
*
11.0
f
*
2.0
f
*
3.0
f
*
12.0
f
*
7.0
f
*
6.0
f
*
13.0
f
*
4.0
f
*
9.0
f
*
10.0
f
*
1.0
f
}),
read_vector
<
float
>
(
result
));
EXPECT_TRUE
(
test
::
all_close
(
vector
<
float
>
{
1.0
f
*
10.0
f
*
9.0
f
*
4.0
f
*
13.0
f
*
6.0
f
*
7.0
f
*
12.0
f
*
3.0
f
*
2.0
f
*
11.0
f
*
8.0
f
*
5.0
f
*
14.0
f
*
5.0
f
*
8.0
f
*
11.0
f
*
2.0
f
*
3.0
f
*
12.0
f
*
7.0
f
*
6.0
f
*
13.0
f
*
4.0
f
*
9.0
f
*
10.0
f
*
1.0
f
},
read_vector
<
float
>
(
result
)));
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
product_3d_eliminate_zero_dim
)
...
...
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