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
134b0ae2
Commit
134b0ae2
authored
Aug 10, 2018
by
shssf
Committed by
Scott Cyphers
Aug 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IntelGPU backend: BatchNorm, Dot, Pad operations optimization (#1393)
parent
9c1c5b59
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
37 deletions
+14
-37
intelgpu_op_batchnorm.cpp
src/ngraph/runtime/intelgpu/intelgpu_op_batchnorm.cpp
+10
-37
intelgpu_op_custom_kernels.cpp
src/ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.cpp
+0
-0
intelgpu_op_custom_kernels.hpp
src/ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.hpp
+4
-0
No files found.
src/ngraph/runtime/intelgpu/intelgpu_op_batchnorm.cpp
View file @
134b0ae2
...
...
@@ -216,6 +216,7 @@ void runtime::intelgpu::do_batch_norm_operation(cldnn::topology& topology,
const
cldnn
::
layout
layout
=
IntelGPULayout
::
create_cldnn_layout
(
output_type
,
output_shape
);
const
string
entry_point_name
=
"batch_norm_"
+
output_name
;
codegen
::
CodeWriter
writer
;
vector
<
size_t
>
gws
;
writer
<<
"__kernel void "
<<
entry_point_name
<<
"( const __global float input"
<<
array_dims
(
input_shape
)
<<
", const __global float gamma"
<<
array_dims
(
gamma_shape
)
...
...
@@ -227,45 +228,17 @@ void runtime::intelgpu::do_batch_norm_operation(cldnn::topology& topology,
writer
.
block_begin
();
{
// Main function body
// Loop for Channel axis 1
writer
<<
"for (uint i"
<<
channel_axis
<<
" = 0; i"
<<
channel_axis
<<
" < "
<<
output_shape
.
at
(
channel_axis
)
<<
"; ++i"
<<
channel_axis
<<
")
\n
"
;
writer
.
block_begin
();
{
size_t
var_idx
=
0
;
// Main loops
for
(
auto
const
&
i
:
output_shape
)
{
if
(
var_idx
!=
channel_axis
)
{
writer
<<
"for (uint i"
<<
var_idx
<<
" = 0; i"
<<
var_idx
<<
" < "
<<
i
<<
"; ++i"
<<
var_idx
<<
")
\n
"
;
writer
.
block_begin
();
}
++
var_idx
;
}
gws
=
generate_loops
(
writer
,
output_shape
,
true
);
writer
<<
"float normalized = (input"
<<
access_dims
(
input_shape
)
<<
" - mean[i"
<<
channel_axis
<<
"]) / ("
<<
"sqrt(variance[i"
<<
channel_axis
<<
"] + "
<<
eps
<<
")"
<<
");
\n
"
;
writer
<<
"float normalized = (input"
<<
access_dims
(
input_shape
)
<<
" - mean[i"
<<
channel_axis
<<
"]) / ("
<<
"sqrt(variance[i"
<<
channel_axis
<<
"] + "
<<
eps
<<
")"
<<
");
\n
"
;
writer
<<
"output"
<<
access_dims
(
output_shape
)
<<
" = normalized * gamma[i"
<<
channel_axis
<<
"] + beta[i"
<<
channel_axis
<<
"];
\n
"
;
writer
<<
"output"
<<
access_dims
(
output_shape
)
<<
" = normalized * gamma[i"
<<
channel_axis
<<
"] + beta[i"
<<
channel_axis
<<
"];
\n
"
;
var_idx
=
0
;
// Closing brackets for main loops
for
(
auto
const
&
i
:
output_shape
)
{
if
(
var_idx
!=
channel_axis
)
{
writer
.
block_end
();
}
++
var_idx
;
}
}
// Closing brackets for Channel axis loop
writer
.
block_end
();
generate_loops
(
writer
,
output_shape
,
false
);
}
// Main function body
writer
.
block_end
();
...
...
@@ -279,6 +252,6 @@ void runtime::intelgpu::do_batch_norm_operation(cldnn::topology& topology,
get_kernel_args
(
5
,
1
),
""
,
layout
,
{
1
}
);
gws
);
topology
.
add
(
op_batch_norm
);
}
src/ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.cpp
View file @
134b0ae2
This diff is collapsed.
Click to expand it.
src/ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.hpp
View file @
134b0ae2
...
...
@@ -18,6 +18,8 @@
#include <CPP/topology.hpp>
#include "ngraph/runtime/intelgpu/code_writer.hpp"
#include "ngraph/axis_set.hpp"
#include "ngraph/coordinate.hpp"
#include "ngraph/shape.hpp"
...
...
@@ -96,6 +98,8 @@ namespace ngraph
std
::
string
access_dims
(
const
Shape
&
dimentions
,
const
AxisSet
&
axis
=
{},
bool
is_reversed
=
false
);
std
::
vector
<
size_t
>
generate_loops
(
codegen
::
CodeWriter
&
writer
,
const
Shape
&
shape
,
bool
is_begin
);
}
}
}
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