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
3bbeaa31
Commit
3bbeaa31
authored
Feb 14, 2018
by
fenglei.tian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clang format
parent
e34a6b2b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
55 deletions
+20
-55
gpu_emitter.cpp
src/ngraph/runtime/gpu/gpu_emitter.cpp
+20
-55
No files found.
src/ngraph/runtime/gpu/gpu_emitter.cpp
View file @
3bbeaa31
...
...
@@ -154,16 +154,10 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
auto
&
second
=
(
arg0_shape
.
empty
()
?
args
[
1
]
:
args
[
0
]);
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
// clang-format off
writer
<<
"cublasSdot("
<<
"cublas_handle,"
<<
second
.
get_size
()
<<
","
<<
first
.
get_name
()
<<
","
<<
"1,"
<<
second
.
get_name
()
<<
","
<<
"1,"
<<
out
[
0
].
get_name
()
<<
");
\n
"
;
// clang-format on
<<
"cublas_handle,"
<<
second
.
get_size
()
<<
","
<<
first
.
get_name
()
<<
","
<<
"1,"
<<
second
.
get_name
()
<<
","
<<
"1,"
<<
out
[
0
].
get_name
()
<<
");
\n
"
;
writer
.
indent
--
;
writer
<<
"}
\n
"
;
}
...
...
@@ -172,16 +166,10 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
// clang-format off
writer
<<
"cublasSdot("
<<
"cublas_handle,"
<<
arg0_shape
[
0
]
<<
","
<<
args
[
0
].
get_name
()
<<
","
<<
"1,"
<<
args
[
1
].
get_name
()
<<
","
<<
"1,"
<<
out
[
0
].
get_name
()
<<
");
\n
"
;
// clang-format on
<<
"cublas_handle,"
<<
arg0_shape
[
0
]
<<
","
<<
args
[
0
].
get_name
()
<<
","
<<
"1,"
<<
args
[
1
].
get_name
()
<<
","
<<
"1,"
<<
out
[
0
].
get_name
()
<<
");
\n
"
;
writer
.
indent
--
;
writer
<<
"}
\n
"
;
}
...
...
@@ -193,22 +181,15 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
writer
<<
"static const float beta = 1.0;
\n
"
;
writer
<<
"cublasSetPointerMode(cublas_handle, CUBLAS_POINTER_MODE_HOST);
\n
"
;
;
// clang-format off
writer
<<
"cublasSgemv("
<<
"cublas_handle,"
<<
"CUBLAS_OP_T,"
<<
arg0_shape
[
0
]
<<
","
<<
arg0_shape
[
1
]
<<
","
<<
"CUBLAS_OP_T,"
<<
arg0_shape
[
0
]
<<
","
<<
arg0_shape
[
1
]
<<
","
<<
"&alpha,"
// Alpha
<<
args
[
0
].
get_name
()
<<
","
<<
arg0_shape
[
1
]
<<
","
<<
args
[
1
].
get_name
()
<<
","
<<
args
[
0
].
get_name
()
<<
","
<<
arg0_shape
[
1
]
<<
","
<<
args
[
1
].
get_name
()
<<
","
<<
"1,"
<<
"&beta,"
// beta
<<
out
[
0
].
get_name
()
<<
","
<<
"1);
\n
"
;
// clang-format on
;
writer
.
indent
--
;
writer
<<
"}
\n
"
;
}
...
...
@@ -226,7 +207,6 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
writer
<<
"int n = "
<<
arg1_shape
[
1
]
<<
";
\n
"
;
writer
<<
"int k = "
<<
arg0_shape
[
0
]
<<
";
\n
"
;
writer
<<
"cublasSetPointerMode(cublas_handle, CUBLAS_POINTER_MODE_HOST);
\n
"
;
// clang-format off
writer
<<
"cublasSgemm("
<<
"cublas_handle,"
<<
"CUBLAS_OP_N,"
...
...
@@ -236,13 +216,11 @@ void runtime::gpu::GPU_Emitter::EmitDot(codegen::CodeWriter& writer,
<<
"k,"
<<
"&alpha,"
// Alpha
<<
args
[
1
].
get_name
()
<<
","
<<
"n,"
<<
args
[
0
].
get_name
()
<<
","
<<
"n,"
<<
args
[
0
].
get_name
()
<<
","
<<
"k,"
<<
"&beta,"
// beta
<<
out
[
0
].
get_name
()
<<
","
<<
"n);
\n
"
;
// clang-format on
writer
.
indent
--
;
writer
<<
"}
\n
"
;
}
...
...
@@ -522,30 +500,24 @@ void runtime::gpu::GPU_Emitter::EmitReshape(codegen::CodeWriter& writer,
// If there *is* a layout change in the 2D case, we transpose the input.
else
if
(
arg_rank
==
2
)
{
// clang-format off
// TODO Assert arg0_shape[0] == arg1_shape[0]?
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
"static const float alpha = 1.0;
\n
"
;
writer
<<
"static const float beta = 0.0;
\n
"
;
writer
<<
"cublasSetPointerMode(cublas_handle, CUBLAS_POINTER_MODE_HOST);
\n
"
;;
writer
<<
"cublasSetPointerMode(cublas_handle, CUBLAS_POINTER_MODE_HOST);
\n
"
;
;
writer
<<
"cublasSgeam("
<<
"cublas_handle,"
<<
"CUBLAS_OP_T,"
<<
"CUBLAS_OP_T,"
<<
arg_shape
[
0
]
<<
","
<<
arg_shape
[
1
]
<<
","
<<
"CUBLAS_OP_T,"
<<
arg_shape
[
0
]
<<
","
<<
arg_shape
[
1
]
<<
","
<<
"&alpha,"
// Alpha
<<
args
[
0
].
get_name
()
<<
","
<<
arg_shape
[
1
]
<<
","
<<
args
[
0
].
get_name
()
<<
","
<<
arg_shape
[
1
]
<<
","
<<
"&beta,"
// beta
<<
args
[
0
].
get_name
()
<<
","
<<
arg_shape
[
1
]
<<
","
<<
out
[
0
].
get_name
()
<<
","
<<
args
[
0
].
get_name
()
<<
","
<<
arg_shape
[
1
]
<<
","
<<
out
[
0
].
get_name
()
<<
","
<<
out
[
0
].
get_shape
()[
1
]
<<
");
\n
"
;
writer
.
indent
--
;
writer
<<
"}
\n
"
;
//clang-format on
}
// Other cases (reordering of axes for tensors with rank>2) are not handled yet.
else
...
...
@@ -630,17 +602,13 @@ cudnnSetOpTensorDescriptor(opTensorDesc,
writer
<<
"cudnnOpTensor(cudnn_handle,"
<<
"opTensorDesc,"
<<
"&alpha1,"
<<
"descriptor,"
<<
args
[
0
].
get_name
()
<<
","
<<
"descriptor,"
<<
args
[
0
].
get_name
()
<<
","
<<
"&alpha2,"
<<
"descriptor,"
<<
args
[
1
].
get_name
()
<<
","
<<
"descriptor,"
<<
args
[
1
].
get_name
()
<<
","
<<
"&beta,"
<<
"descriptor,"
<<
out
[
0
].
get_name
()
<<
");
\n
"
;
<<
"descriptor,"
<<
out
[
0
].
get_name
()
<<
");
\n
"
;
writer
.
indent
--
;
writer
<<
"}
\n
"
;
}
void
runtime
::
gpu
::
GPU_Emitter
::
EmitExp
(
codegen
::
CodeWriter
&
writer
,
...
...
@@ -796,14 +764,11 @@ cudnnSetOpTensorDescriptor(opTensorDesc,
writer
<<
"cudnnOpTensor(cudnn_handle,"
<<
"opTensorDesc,"
<<
"&alpha1,"
<<
"descriptor,"
<<
args
[
0
].
get_name
()
<<
","
<<
"descriptor,"
<<
args
[
0
].
get_name
()
<<
","
<<
"&alpha2,"
<<
"descriptor,"
<<
args
[
0
].
get_name
()
<<
","
<<
"descriptor,"
<<
args
[
0
].
get_name
()
<<
","
<<
"&beta,"
<<
"descriptor,"
<<
out
[
0
].
get_name
()
<<
");
\n
"
;
<<
"descriptor,"
<<
out
[
0
].
get_name
()
<<
");
\n
"
;
writer
.
indent
--
;
writer
<<
"}
\n
"
;
}
...
...
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