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
45b50d06
Commit
45b50d06
authored
Aug 03, 2018
by
shssf
Committed by
Robert Kimball
Aug 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IntelGPU backend: BatchNorm operation completly redeveloped (#1318)
parent
39278e7d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
20 deletions
+58
-20
intelgpu_backend.cpp
src/ngraph/runtime/intelgpu/intelgpu_backend.cpp
+34
-11
intelgpu_op_batchnorm.cpp
src/ngraph/runtime/intelgpu/intelgpu_op_batchnorm.cpp
+0
-0
intelgpu_op_batchnorm.hpp
src/ngraph/runtime/intelgpu/intelgpu_op_batchnorm.hpp
+24
-9
No files found.
src/ngraph/runtime/intelgpu/intelgpu_backend.cpp
View file @
45b50d06
...
...
@@ -533,35 +533,58 @@ bool runtime::intelgpu::IntelGPUBackend::compile(shared_ptr<Function> func)
}
const
string
&
output_name
=
op
->
get_outputs
().
begin
()
->
get_tensor
().
get_name
();
const
Shape
&
output_shape
=
op
->
get_outputs
().
begin
()
->
get_shape
();
const
element
::
Type
&
output_type
=
op
->
get_outputs
().
begin
()
->
get_tensor
().
get_element_type
();
const
string
&
gamma_name
=
op
->
get_inputs
().
at
(
0
).
get_tensor
().
get_name
();
const
Shape
&
gamma_shape
=
op
->
get_inputs
().
at
(
0
).
get_shape
();
const
string
&
beta_name
=
op
->
get_inputs
().
at
(
1
).
get_tensor
().
get_name
();
const
string
&
input_name
=
op
->
get_inputs
().
at
(
2
).
get_tensor
().
get_name
();
const
Shape
&
input_shape
=
op
->
get_inputs
().
at
(
2
).
get_shape
();
string
mean_name
;
string
variance_name
;
if
(
op
->
get_outputs
().
size
()
==
3
)
{
arguments_check
(
op
,
3
,
3
);
mean_name
=
op
->
get_outputs
().
at
(
1
).
get_tensor
().
get_name
();
variance_name
=
op
->
get_outputs
().
at
(
2
).
get_tensor
().
get_name
();
do_create_mean
(
topology
,
mean_name
,
gamma_shape
,
output_type
,
input_name
,
input_shape
);
do_create_variance
(
topology
,
variance_name
,
gamma_shape
,
output_type
,
input_name
,
input_shape
,
mean_name
);
}
if
(
op
->
get_outputs
().
size
()
==
1
)
if
(
op
->
get_outputs
().
size
()
==
1
||
op
->
get_outputs
().
size
()
==
3
)
{
arguments_check
(
op
,
5
,
1
);
if
(
mean_name
.
empty
()
||
variance_name
.
empty
())
{
arguments_check
(
op
,
5
,
1
);
const
string
&
mean_name
=
op
->
get_inputs
().
at
(
3
).
get_tensor
().
get_name
();
const
string
&
variance_name
=
op
->
get_inputs
().
at
(
4
).
get_tensor
().
get_name
();
mean_name
=
op
->
get_inputs
().
at
(
3
).
get_tensor
().
get_name
();
variance_name
=
op
->
get_inputs
().
at
(
4
).
get_tensor
().
get_name
();
}
do_batch_norm_operation
(
topology
,
output_name
,
output_shape
,
output_type
,
eps
,
input_name
,
input_shape
,
gamma_name
,
gamma_shape
,
beta_name
,
mean_name
,
variance_name
);
}
else
if
(
op
->
get_outputs
().
size
()
==
3
)
{
arguments_check
(
op
,
3
,
3
);
do_batch_norm_operation
(
topology
,
output_name
,
eps
,
input_name
,
input_shape
,
gamma_name
,
beta_name
);
}
else
{
arguments_check
(
op
,
5
,
1
);
// throw exception in this case
...
...
src/ngraph/runtime/intelgpu/intelgpu_op_batchnorm.cpp
View file @
45b50d06
This diff is collapsed.
Click to expand it.
src/ngraph/runtime/intelgpu/intelgpu_op_batchnorm.hpp
View file @
45b50d06
...
...
@@ -19,6 +19,7 @@
#include <CPP/topology.hpp>
#include "ngraph/shape.hpp"
#include "ngraph/type/element_type.hpp"
namespace
ngraph
{
...
...
@@ -27,22 +28,36 @@ namespace ngraph
namespace
intelgpu
{
// This implements BatchNorm nGraph operation
// Since nGraph uses channels in this operation but clDNN uses full input data
// at one time we have to use following algorithm:
// 1. Split all input data arrays into several matrices by channel axis
// 2. Independently do cldnn::batch_norm on particular matrix
// 3. Every result of the cldnn::batch_norm must be scaled and
// shifted because cldnn::batch_norm dosn't use gamma and beta
// 4. Concatenate all results into output matrix by channel axis
// nGraph uses channels in this operation but clDNN uses full input data
void
do_batch_norm_operation
(
cldnn
::
topology
&
topology
,
const
std
::
string
&
output_name
,
const
Shape
&
output_shape
,
const
element
::
Type
&
output_type
,
double
eps
,
const
std
::
string
&
input_name
,
const
Shape
&
input_shape
,
const
std
::
string
&
gamma_name
,
const
Shape
&
gamma_shape
,
const
std
::
string
&
beta_name
,
const
std
::
string
&
mean_name
=
std
::
string
(),
const
std
::
string
&
variance_name
=
std
::
string
());
const
std
::
string
&
mean_name
,
const
std
::
string
&
variance_name
);
// This creates mean of the input matrix by Channel axis
void
do_create_mean
(
cldnn
::
topology
&
topology
,
const
std
::
string
&
output_name
,
const
Shape
&
output_shape
,
const
element
::
Type
&
output_type
,
const
std
::
string
&
input_name
,
const
Shape
&
input_shape
);
// This creates mean of the input matrix by Channel axis
void
do_create_variance
(
cldnn
::
topology
&
topology
,
const
std
::
string
&
output_name
,
const
Shape
&
output_shape
,
const
element
::
Type
&
output_type
,
const
std
::
string
&
input_name
,
const
Shape
&
input_shape
,
const
std
::
string
&
mean_name
);
}
}
}
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