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
3609cc74
Commit
3609cc74
authored
Sep 07, 2018
by
shssf
Committed by
Robert Kimball
Sep 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IntelGPU backend: Reshape operation optimization (#1566)
parent
e6267708
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
4 deletions
+30
-4
intelgpu_backend.cpp
src/ngraph/runtime/intelgpu/intelgpu_backend.cpp
+11
-4
backend_test.in.cpp
test/backend_test.in.cpp
+19
-0
No files found.
src/ngraph/runtime/intelgpu/intelgpu_backend.cpp
View file @
3609cc74
...
@@ -594,19 +594,21 @@ bool runtime::intelgpu::IntelGPUBackend::compile(shared_ptr<Function> func)
...
@@ -594,19 +594,21 @@ bool runtime::intelgpu::IntelGPUBackend::compile(shared_ptr<Function> func)
{
{
arguments_check
(
op
,
1
,
1
);
arguments_check
(
op
,
1
,
1
);
const
shared_ptr
<
op
::
Reshape
>
op_broadcast
=
static_pointer_cast
<
op
::
Reshape
>
(
op
);
const
shared_ptr
<
op
::
Reshape
>
op_reshape
=
static_pointer_cast
<
op
::
Reshape
>
(
op
);
const
AxisVector
&
broadcast_axes
=
op_broadcast
->
get_input_order
();
if
(
op_reshape
->
get_is_transpose
())
{
vector
<
uint16_t
>
permute_order
({
0
,
1
,
2
,
3
});
// No action by default
vector
<
uint16_t
>
permute_order
({
0
,
1
,
2
,
3
});
// No action by default
const
AxisVector
&
reshape_axes
=
op_reshape
->
get_input_order
();
const
size_t
max_dim
=
4
;
const
size_t
max_dim
=
4
;
const
size_t
scale
=
const
size_t
scale
=
broadcast_axes
.
size
()
<
max_dim
?
max_dim
-
broadcast
_axes
.
size
()
:
0
;
reshape_axes
.
size
()
<
max_dim
?
max_dim
-
reshape
_axes
.
size
()
:
0
;
// Need to scale indexes up according on array rank.
// Need to scale indexes up according on array rank.
// For example, in 2D array, indexes are 0,1 but in 4D array it should be 2,3
// For example, in 2D array, indexes are 0,1 but in 4D array it should be 2,3
// because cldnn::tensor is always 4D assuming cldnn::bfyx model
// because cldnn::tensor is always 4D assuming cldnn::bfyx model
size_t
rindex
=
max_dim
;
size_t
rindex
=
max_dim
;
for
(
auto
i
=
broadcast_axes
.
crbegin
();
i
!=
broadcast
_axes
.
crend
()
&&
rindex
>
0
;
for
(
auto
i
=
reshape_axes
.
crbegin
();
i
!=
reshape
_axes
.
crend
()
&&
rindex
>
0
;
++
i
,
--
rindex
)
++
i
,
--
rindex
)
{
{
permute_order
.
at
(
rindex
-
1
)
=
*
i
+
scale
;
permute_order
.
at
(
rindex
-
1
)
=
*
i
+
scale
;
...
@@ -616,6 +618,11 @@ bool runtime::intelgpu::IntelGPUBackend::compile(shared_ptr<Function> func)
...
@@ -616,6 +618,11 @@ bool runtime::intelgpu::IntelGPUBackend::compile(shared_ptr<Function> func)
get_output_name
(
op
),
get_input_name
(
op
),
permute_order
);
get_output_name
(
op
),
get_input_name
(
op
),
permute_order
);
topology
.
add
(
cldnn_permute
);
topology
.
add
(
cldnn_permute
);
}
}
else
{
do_equal_propagation
(
topology
,
get_input_name
(
op
),
get_output_name
(
op
));
}
}
else
if
(
"Negative"
==
op
->
description
())
else
if
(
"Negative"
==
op
->
description
())
{
{
const
cldnn_activation_additional_params
param
=
{
-
1.
f
,
0.
f
};
const
cldnn_activation_additional_params
param
=
{
-
1.
f
,
0.
f
};
...
...
test/backend_test.in.cpp
View file @
3609cc74
...
@@ -2691,6 +2691,25 @@ NGRAPH_TEST(${BACKEND_NAME}, reshape_s2t)
...
@@ -2691,6 +2691,25 @@ NGRAPH_TEST(${BACKEND_NAME}, reshape_s2t)
EXPECT_EQ
((
vector
<
float
>
{
42
}),
read_vector
<
float
>
(
result
));
EXPECT_EQ
((
vector
<
float
>
{
42
}),
read_vector
<
float
>
(
result
));
}
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
reshape_s2t1
)
{
Shape
shape_a
{};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
boolean
,
shape_a
);
Shape
shape_r
{
1
};
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{},
shape_r
);
auto
f
=
make_shared
<
Function
>
(
r
,
op
::
ParameterVector
{
A
});
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
);
// Create some tensors for input/output
auto
a
=
backend
->
create_tensor
(
element
::
boolean
,
shape_a
);
copy_data
(
a
,
vector
<
char
>
{
42
});
auto
result
=
backend
->
create_tensor
(
element
::
boolean
,
shape_r
);
backend
->
call_with_validate
(
f
,
{
result
},
{
a
});
EXPECT_EQ
((
vector
<
char
>
{
42
}),
read_vector
<
char
>
(
result
));
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
reshape_v2m_col
)
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
reshape_v2m_col
)
{
{
Shape
shape_a
{
3
};
Shape
shape_a
{
3
};
...
...
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