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
77a703c2
Commit
77a703c2
authored
Aug 03, 2018
by
dmyershov
Committed by
Robert Kimball
Aug 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IntelGPU backend: Select operation (#1314)
parent
f8926a7b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
117 additions
and
6 deletions
+117
-6
intelgpu_backend.cpp
src/ngraph/runtime/intelgpu/intelgpu_backend.cpp
+26
-0
intelgpu_layout.cpp
src/ngraph/runtime/intelgpu/intelgpu_layout.cpp
+1
-1
intelgpu_op_broadcast.cpp
src/ngraph/runtime/intelgpu/intelgpu_op_broadcast.cpp
+4
-2
intelgpu_op_custom_kernels.cpp
src/ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.cpp
+75
-3
intelgpu_op_custom_kernels.hpp
src/ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.hpp
+11
-0
No files found.
src/ngraph/runtime/intelgpu/intelgpu_backend.cpp
View file @
77a703c2
...
...
@@ -220,6 +220,32 @@ bool runtime::intelgpu::IntelGPUBackend::compile(shared_ptr<Function> func)
strides
);
}
}
else
if
(
"Select"
==
op
->
description
())
{
arguments_check
(
op
,
3
,
1
);
const
string
&
input0_name
=
op
->
get_inputs
().
at
(
0
).
get_tensor
().
get_name
();
const
Shape
&
input0_shape
=
op
->
get_inputs
().
at
(
0
).
get_shape
();
const
string
&
input1_name
=
op
->
get_inputs
().
at
(
1
).
get_tensor
().
get_name
();
const
Shape
&
input1_shape
=
op
->
get_inputs
().
at
(
1
).
get_shape
();
const
string
&
input2_name
=
op
->
get_inputs
().
at
(
2
).
get_tensor
().
get_name
();
const
Shape
&
input2_shape
=
op
->
get_inputs
().
at
(
2
).
get_shape
();
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
();
do_select_operation
(
topology
,
input0_name
,
input0_shape
,
input1_name
,
input1_shape
,
input2_name
,
input2_shape
,
output_name
,
output_shape
,
output_type
);
}
else
if
(
"Add"
==
op
->
description
())
{
do_eltwise_operation
(
topology
,
op
,
cldnn
::
eltwise_mode
::
sum
);
...
...
src/ngraph/runtime/intelgpu/intelgpu_layout.cpp
View file @
77a703c2
...
...
@@ -58,7 +58,7 @@ bool runtime::intelgpu::IntelGPULayout::
cldnn
::
data_types
runtime
::
intelgpu
::
IntelGPULayout
::
get_cldnn_type
(
const
element
::
Type
&
element_type
)
{
if
(
element_type
==
ngraph
::
element
::
i8
)
if
(
(
element_type
==
ngraph
::
element
::
i8
)
||
(
element_type
==
ngraph
::
element
::
boolean
)
)
{
return
cldnn
::
data_types
::
i8
;
}
...
...
src/ngraph/runtime/intelgpu/intelgpu_op_broadcast.cpp
View file @
77a703c2
...
...
@@ -100,7 +100,8 @@ void runtime::intelgpu::do_bcast_sum_operation_scalar(cldnn::topology& topology,
function_name
,
parameters_1inp_1out
,
string
(
"-DCOUNT="
+
to_string
(
input_count
)),
layout
);
layout
,
{
1
});
topology
.
add
(
op_scalar
);
}
...
...
@@ -171,6 +172,7 @@ void runtime::intelgpu::do_bcast_sum_operation(cldnn::topology& topology,
function_name
,
parameters_1inp_1out
,
""
,
layout
);
layout
,
{
1
});
topology
.
add
(
op_bcast_sum
);
}
src/ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.cpp
View file @
77a703c2
...
...
@@ -29,6 +29,8 @@ using namespace ngraph;
static
vector
<
cldnn_arg
>
parameters_1inp_1out
=
{{
arg_input
,
0
},
{
arg_output
,
0
}};
static
vector
<
cldnn_arg
>
parameters_2inp_1out
=
{{
arg_input
,
0
},
{
arg_input
,
1
},
{
arg_output
,
0
}};
static
vector
<
cldnn_arg
>
parameters_3inp_1out
=
{
{
arg_input
,
0
},
{
arg_input
,
1
},
{
arg_input
,
2
},
{
arg_output
,
0
}};
static
string
array_dims
(
const
Shape
&
dimentions
)
{
...
...
@@ -156,7 +158,8 @@ void runtime::intelgpu::do_pad_operation(cldnn::topology& topology,
entry_point_name
,
parameters_2inp_1out
,
""
,
layout
);
layout
,
{
1
});
topology
.
add
(
op_scalar
);
}
...
...
@@ -450,7 +453,8 @@ void runtime::intelgpu::do_dot_operation(cldnn::topology& topology,
entry_point_name
,
parameters_2inp_1out
,
""
,
layout
);
layout
,
{
1
});
topology
.
add
(
op_dot
);
}
...
...
@@ -500,6 +504,74 @@ void runtime::intelgpu::do_slice_operation(cldnn::topology& topology,
entry_point_name
,
parameters_1inp_1out
,
""
,
layout
);
layout
,
{
1
});
topology
.
add
(
op_slice
);
}
void
runtime
::
intelgpu
::
do_select_operation
(
cldnn
::
topology
&
topology
,
const
string
&
input0_name
,
const
Shape
&
input0_shape
,
const
string
&
input1_name
,
const
Shape
&
input1_shape
,
const
string
&
input2_name
,
const
Shape
&
input2_shape
,
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
);
string
entry_point_name
=
"select"
+
output_name
;
codegen
::
CodeWriter
writer
;
writer
<<
"__kernel void "
<<
entry_point_name
<<
"(const __global char input0"
<<
array_dims
(
input0_shape
)
<<
", const __global float input1"
<<
array_dims
(
input1_shape
)
<<
", const __global float input2"
<<
array_dims
(
input2_shape
)
<<
", __global float output"
<<
array_dims
(
output_shape
)
<<
")
\n
"
;
writer
.
block_begin
();
{
size_t
var_idx
=
0
;
// Main loops
for
(
auto
const
&
i
:
output_shape
)
{
writer
<<
"for (uint i"
<<
var_idx
<<
" = 0; i"
<<
var_idx
<<
" < "
<<
i
<<
"; ++i"
<<
var_idx
<<
")
\n
"
;
writer
.
block_begin
();
++
var_idx
;
}
writer
<<
"if (input0"
<<
access_dims
(
input0_shape
)
<<
" != 0)
\n
"
;
writer
.
block_begin
();
{
writer
<<
"output"
<<
access_dims
(
output_shape
)
<<
" = input1"
<<
access_dims
(
input1_shape
)
<<
";
\n
"
;
}
writer
.
block_end
();
writer
<<
"else
\n
"
;
writer
.
block_begin
();
{
writer
<<
"output"
<<
access_dims
(
output_shape
)
<<
" = input2"
<<
access_dims
(
input2_shape
)
<<
";
\n
"
;
}
writer
.
block_end
();
// Closing brackets for main loops
for
(
auto
const
&
i
:
output_shape
)
{
writer
.
block_end
();
}
}
writer
.
block_end
();
const
cldnn
::
custom_gpu_primitive
op_select
(
output_name
,
{
input0_name
,
input1_name
,
input2_name
},
{
writer
.
get_code
()},
entry_point_name
,
parameters_3inp_1out
,
""
,
layout
,
{
1
});
topology
.
add
(
op_select
);
}
src/ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.hpp
View file @
77a703c2
...
...
@@ -58,6 +58,17 @@ namespace ngraph
const
Coordinate
&
lower_bounds
,
const
Coordinate
&
uppper_bounds
,
const
Strides
&
strides
);
void
do_select_operation
(
cldnn
::
topology
&
topology
,
const
std
::
string
&
input0_name
,
const
Shape
&
input0_shape
,
const
std
::
string
&
input1_name
,
const
Shape
&
input1_shape
,
const
std
::
string
&
input2_name
,
const
Shape
&
input2_shape
,
const
std
::
string
&
output_name
,
const
Shape
&
output_shape
,
const
element
::
Type
&
output_type
);
}
}
}
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