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
780ef08c
Commit
780ef08c
authored
Feb 15, 2019
by
Sergey Shalnov
Committed by
Robert Kimball
Feb 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IntelGPU backend: Eltwise and unary operation all types support (#2460)
parent
afcc4ca8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
135 deletions
+55
-135
intelgpu_backend.cpp
src/ngraph/runtime/intelgpu/intelgpu_backend.cpp
+0
-0
intelgpu_op_custom_kernels.cpp
src/ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.cpp
+42
-81
intelgpu_op_custom_kernels.hpp
src/ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.hpp
+4
-20
intelgpu_op_softmax.cpp
src/ngraph/runtime/intelgpu/intelgpu_op_softmax.cpp
+9
-7
unit_test.manifest
src/ngraph/runtime/intelgpu/unit_test.manifest
+0
-27
No files found.
src/ngraph/runtime/intelgpu/intelgpu_backend.cpp
View file @
780ef08c
This diff is collapsed.
Click to expand it.
src/ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.cpp
View file @
780ef08c
...
...
@@ -1012,7 +1012,8 @@ void runtime::intelgpu::do_eltwise_kernel(cldnn::topology& topology,
const
string
&
output_name
,
const
Shape
&
output_shape
,
const
element
::
Type
&
output_type
,
const
string
&
operation
)
const
string
&
operation
,
bool
function_operation
)
{
const
cldnn
::
layout
layout
=
IntelGPULayout
::
create_cldnn_layout
(
output_type
,
output_shape
);
const
string
entry_point_name
=
"eltwise_"
+
output_name
;
...
...
@@ -1031,15 +1032,34 @@ void runtime::intelgpu::do_eltwise_kernel(cldnn::topology& topology,
// Main loops
gws
=
generate_loops
(
writer
,
output_shape
,
true
);
writer
<<
"output"
<<
access_dims
(
output_shape
)
<<
" = "
<<
operation
<<
"(input0"
<<
access_dims
(
input0_shape
)
<<
", input1"
<<
access_dims
(
input1_shape
)
<<
");
\n
"
;
writer
<<
"output"
<<
access_dims
(
output_shape
)
<<
" = "
;
if
(
function_operation
)
{
string
explicit_conversion
;
// TODO need better workaround for this built_in
if
(
operation
==
"pow"
)
{
explicit_conversion
=
"convert_double"
;
}
writer
<<
operation
<<
"("
<<
explicit_conversion
<<
"(input0"
<<
access_dims
(
input0_shape
)
<<
"), "
<<
explicit_conversion
<<
"(input1"
<<
access_dims
(
input1_shape
)
<<
"));"
;
}
else
{
writer
<<
"(input0"
<<
access_dims
(
input0_shape
)
<<
" "
<<
operation
<<
" input1"
<<
access_dims
(
input1_shape
)
<<
");"
;
}
writer
<<
" // "
<<
get_opencl_type_name
(
input0_type
)
<<
" "
<<
get_opencl_type_name
(
output_type
)
<<
"
\n
"
;
// Closing brackets for main loops
generate_loops
(
writer
,
output_shape
,
false
);
}
writer
.
block_end
();
const
cldnn
::
custom_gpu_primitive
op_
logical
(
output_name
,
const
cldnn
::
custom_gpu_primitive
op_
eltwise
(
output_name
,
{
input0_name
,
input1_name
},
{
writer
.
get_code
()},
entry_point_name
,
...
...
@@ -1047,7 +1067,7 @@ void runtime::intelgpu::do_eltwise_kernel(cldnn::topology& topology,
""
,
layout
,
gws
);
topology
.
add
(
op_
logical
);
topology
.
add
(
op_
eltwise
);
}
void
runtime
::
intelgpu
::
do_reverse_operation
(
cldnn
::
topology
&
topology
,
...
...
@@ -1268,16 +1288,17 @@ void runtime::intelgpu::do_sigmoid_backprop_operation(cldnn::topology& topology,
topology
.
add
(
op_sigmoid_backprop
);
}
void
runtime
::
intelgpu
::
do_custom_
eltwise
_operation
(
cldnn
::
topology
&
topology
,
void
runtime
::
intelgpu
::
do_custom_
unary
_operation
(
cldnn
::
topology
&
topology
,
const
string
&
input_name
,
const
Shape
&
input_shape
,
const
element
::
Type
&
input_type
,
const
string
&
output_name
,
const
Shape
&
output_shape
,
const
element
::
Type
&
output_type
,
const
CUSTOM_ELTWISE
operation_name
)
const
string
&
operation_name
)
{
const
string
entry_point_name
=
"op_custom_eltwise_"
+
output_name
;
const
string
entry_point_name
=
"op_custom_unary_"
+
output_name
;
const
string
intermidiate_type
=
input_type
.
size
()
<
8
?
"float"
:
"double"
;
codegen
::
CodeWriter
writer
;
vector
<
size_t
>
gws
;
...
...
@@ -1290,39 +1311,19 @@ void runtime::intelgpu::do_custom_eltwise_operation(cldnn::topology& topology,
writer
.
block_begin
();
{
gws
=
generate_loops
(
writer
,
output_shape
,
true
);
writer
<<
"output"
<<
access_dims
(
output_shape
)
<<
" = "
;
switch
(
operation_name
)
{
case
CUSTOM_ELTWISE
:
:
Atan
:
{
writer
<<
"atan"
;
break
;
}
case
CUSTOM_ELTWISE
:
:
Ceil
:
{
writer
<<
"ceil"
;
break
;
}
case
CUSTOM_ELTWISE
:
:
Floor
:
{
if
(
input_type
.
is_real
())
{
writer
<<
"floor"
;
}
break
;
}
case
CUSTOM_ELTWISE
:
:
Sign
:
{
writer
<<
"sign"
;
break
;
}
case
CUSTOM_ELTWISE
:
:
Tan
:
{
writer
<<
"tan"
;
break
;
}
}
writer
<<
"(input0"
<<
access_dims
(
input_shape
)
<<
");
\n
"
;
// convert to intermediate floating point type
writer
<<
intermidiate_type
<<
" input_var = convert_"
<<
intermidiate_type
<<
"(input0"
<<
access_dims
(
input_shape
)
<<
");
\n
"
;
// do the operation with the same type
writer
<<
intermidiate_type
<<
" output_var = "
<<
operation_name
<<
"(input_var); //Type: "
<<
get_opencl_type_name
(
input_type
)
<<
"
\n
"
;
// convert to destination type
writer
<<
"output"
<<
access_dims
(
output_shape
)
<<
" = convert_"
<<
get_opencl_type_name
(
output_type
)
<<
"(output_var);
\n
"
;
generate_loops
(
writer
,
output_shape
,
false
);
}
writer
.
block_end
();
...
...
@@ -1419,46 +1420,6 @@ void runtime::intelgpu::do_arg_max_min_operation(cldnn::topology& topology,
topology
.
add
(
op_arg_max_min
);
}
void
runtime
::
intelgpu
::
do_negative_operation
(
cldnn
::
topology
&
topology
,
const
string
&
input_name
,
const
Shape
&
input_shape
,
const
element
::
Type
&
input_type
,
const
string
&
output_name
,
const
Shape
&
output_shape
,
const
element
::
Type
&
output_type
)
{
const
cldnn
::
layout
layout
=
IntelGPULayout
::
create_cldnn_layout
(
output_type
,
output_shape
);
const
string
entry_point_name
=
"negative_"
+
output_name
;
const
string
&
input_type_name
=
get_opencl_type_name
(
input_type
);
const
string
&
output_type_name
=
get_opencl_type_name
(
output_type
);
codegen
::
CodeWriter
writer
;
vector
<
size_t
>
gws
;
gen_func_def
(
writer
,
entry_point_name
,
{
input_type_name
},
{
input_shape
},
output_type_name
,
output_shape
);
writer
.
block_begin
();
{
gws
=
generate_loops
(
writer
,
output_shape
,
true
);
writer
<<
"output"
<<
access_dims
(
output_shape
)
<<
" = - (input0"
<<
access_dims
(
input_shape
)
<<
");
\n
"
;
generate_loops
(
writer
,
output_shape
,
false
);
}
writer
.
block_end
();
const
cldnn
::
custom_gpu_primitive
op_negative
(
output_name
,
{
input_name
},
{
writer
.
get_code
()},
entry_point_name
,
get_kernel_args
(
1
,
1
),
""
,
layout
,
gws
);
topology
.
add
(
op_negative
);
}
void
runtime
::
intelgpu
::
do_reshape_operation
(
cldnn
::
topology
&
topology
,
const
string
&
input_name
,
const
Shape
&
input_shape
,
...
...
src/ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.hpp
View file @
780ef08c
...
...
@@ -119,7 +119,8 @@ namespace ngraph
const
std
::
string
&
output_name
,
const
Shape
&
output_shape
,
const
element
::
Type
&
output_type
,
const
std
::
string
&
operation
);
const
std
::
string
&
operation
,
bool
function_operation
);
void
do_reverse_operation
(
cldnn
::
topology
&
topology
,
const
std
::
string
&
input_name
,
...
...
@@ -162,23 +163,14 @@ namespace ngraph
const
Shape
&
output_shape
,
const
element
::
Type
&
output_type
);
enum
class
CUSTOM_ELTWISE
{
Atan
,
Ceil
,
Floor
,
Sign
,
Tan
};
void
do_custom_eltwise_operation
(
cldnn
::
topology
&
topology
,
void
do_custom_unary_operation
(
cldnn
::
topology
&
topology
,
const
std
::
string
&
input_name
,
const
Shape
&
input_shape
,
const
element
::
Type
&
input_type
,
const
std
::
string
&
output_name
,
const
Shape
&
output_shape
,
const
element
::
Type
&
output_type
,
const
CUSTOM_ELTWISE
operation_name
);
const
std
::
string
&
operation_name
);
void
do_arg_max_min_operation
(
cldnn
::
topology
&
topology
,
const
std
::
string
&
input_name
,
...
...
@@ -190,14 +182,6 @@ namespace ngraph
const
size_t
reduction_axis
,
const
bool
is_max
);
void
do_negative_operation
(
cldnn
::
topology
&
topology
,
const
std
::
string
&
input_name
,
const
Shape
&
input_shape
,
const
element
::
Type
&
input_type
,
const
std
::
string
&
output_name
,
const
Shape
&
output_shape
,
const
element
::
Type
&
output_type
);
void
do_reshape_operation
(
cldnn
::
topology
&
topology
,
const
std
::
string
&
input_name
,
const
Shape
&
input_shape
,
...
...
src/ngraph/runtime/intelgpu/intelgpu_op_softmax.cpp
View file @
780ef08c
...
...
@@ -65,9 +65,10 @@ void runtime::intelgpu::do_softmax_operation(cldnn::topology& topology,
codegen
::
CodeWriter
writer1
;
vector
<
size_t
>
gws
;
writer0
<<
"__kernel void "
<<
entry_point_middle_name
<<
"(const __global float input"
<<
array_dims
(
input_shape
)
<<
", __global float output"
<<
array_dims
(
input_shape
,
axes
)
<<
")
\n
"
;
writer0
<<
"__kernel void "
<<
entry_point_middle_name
<<
"(const __global "
<<
get_opencl_type_name
(
input_type
)
<<
" input"
<<
array_dims
(
input_shape
)
<<
", __global "
<<
get_opencl_type_name
(
output_type
)
<<
" output"
<<
array_dims
(
input_shape
,
axes
)
<<
")
\n
"
;
writer0
.
block_begin
();
{
...
...
@@ -90,10 +91,11 @@ void runtime::intelgpu::do_softmax_operation(cldnn::topology& topology,
gws
);
topology
.
add
(
op_softmax_middle
);
writer1
<<
"__kernel void "
<<
entry_point_name
<<
"(const __global float input0"
<<
array_dims
(
input_shape
)
<<
", const __global float input1"
<<
array_dims
(
input_shape
,
axes
)
<<
", __global float output"
<<
array_dims
(
output_shape
)
<<
")
\n
"
;
writer1
<<
"__kernel void "
<<
entry_point_name
<<
"(const __global "
<<
get_opencl_type_name
(
input_type
)
<<
" input0"
<<
array_dims
(
input_shape
)
<<
", const __global "
<<
get_opencl_type_name
(
input_type
)
<<
" input1"
<<
array_dims
(
input_shape
,
axes
)
<<
", __global "
<<
get_opencl_type_name
(
output_type
)
<<
" output"
<<
array_dims
(
output_shape
)
<<
")
\n
"
;
writer1
.
block_begin
();
{
...
...
src/ngraph/runtime/intelgpu/unit_test.manifest
View file @
780ef08c
...
...
@@ -13,9 +13,6 @@ backwards_reverse_sequence_n3_c2_h3
backwards_reverse_sequence_n4d2c3h2w2
backwards_slice
batch_norm_bprop_n4c3h2w2
batch_norm_inference_0eps_f64
batch_norm_inference_f64
batch_norm_training_0eps_f64
dequantize
dequantize_axes
dequantize_dynamic_offset
...
...
@@ -64,7 +61,6 @@ shape_of_5d
shape_of_matrix
shape_of_scalar
shape_of_vector
softmax_axis_3d_double
topk_1d_max_all
topk_1d_max_one
topk_1d_max_partial
...
...
@@ -88,26 +84,3 @@ topk_3d_min_partial
topk_3d_single_output
topk_5d_max_partial
topk_int64
zero_sized_abs
zero_sized_acos
zero_sized_add
zero_sized_asin
zero_sized_atan
zero_sized_ceiling
zero_sized_cos
zero_sized_cosh
zero_sized_divide
zero_sized_exp
zero_sized_log
zero_sized_maximum
zero_sized_minimum
zero_sized_multiply
zero_sized_negative
zero_sized_power
zero_sized_sign
zero_sized_sin
zero_sized_sinh
zero_sized_sqrt
zero_sized_subtract
zero_sized_tan
zero_sized_tanh
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