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
04230095
Commit
04230095
authored
Aug 23, 2018
by
Nick Korovaiko
Committed by
Scott Cyphers
Aug 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply perm (#1460)
parent
abff494d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
39 deletions
+35
-39
reshape_elimination.cpp
src/ngraph/pass/reshape_elimination.cpp
+5
-19
cpu_fusion.cpp
src/ngraph/runtime/cpu/pass/cpu_fusion.cpp
+5
-20
util.cpp
src/ngraph/util.cpp
+23
-0
util.hpp
src/ngraph/util.hpp
+2
-0
No files found.
src/ngraph/pass/reshape_elimination.cpp
View file @
04230095
...
...
@@ -33,23 +33,9 @@
#include "ngraph/pattern/op/skip.hpp"
#include "ngraph/util.hpp"
template
<
typename
T
>
static
std
::
vector
<
T
>
apply_permutation
(
std
::
vector
<
T
>
input
,
ngraph
::
AxisVector
order
)
{
if
(
input
.
size
()
!=
order
.
size
())
{
throw
"input and order sizes don't match!"
;
}
std
::
vector
<
T
>
output
(
input
.
size
());
for
(
size_t
i
=
0
;
i
<
order
.
size
();
i
++
)
{
output
[
i
]
=
input
.
at
(
order
.
at
(
i
));
}
return
output
;
}
extern
template
ngraph
::
AxisVector
ngraph
::
apply_permutation
<
ngraph
::
AxisVector
>
(
ngraph
::
AxisVector
input
,
ngraph
::
AxisVector
order
);
void
ngraph
::
pass
::
ReshapeElimination
::
construct_identity_reshape_pattern
()
{
...
...
@@ -133,8 +119,8 @@ void ngraph::pass::ReshapeElimination::construct_reshapex2_pattern()
return
true
;
}
auto
perm1
=
apply_permutation
(
do_r1
,
r1
->
get_input_order
());
auto
perm2
=
apply_permutation
(
perm1
,
r2
->
get_input_order
());
auto
perm1
=
ngraph
::
apply_permutation
(
do_r1
,
r1
->
get_input_order
());
auto
perm2
=
ngraph
::
apply_permutation
(
perm1
,
r2
->
get_input_order
());
if
(
perm2
==
do_r1
)
{
NGRAPH_DEBUG
<<
"Two transposes were removed!"
;
...
...
src/ngraph/runtime/cpu/pass/cpu_fusion.cpp
View file @
04230095
...
...
@@ -56,6 +56,9 @@
#include "ngraph/runtime/cpu/op/sigmoid_mul.hpp"
#include "ngraph/util.hpp"
extern
template
ngraph
::
Shape
ngraph
::
apply_permutation
<
ngraph
::
Shape
>
(
ngraph
::
Shape
input
,
ngraph
::
AxisVector
order
);
static
bool
init_cblas_arg
(
std
::
shared_ptr
<
ngraph
::
Node
>
reshape
,
std
::
shared_ptr
<
ngraph
::
Node
>
arg
,
bool
&
transpose_w
,
...
...
@@ -108,24 +111,6 @@ static bool init_cblas_arg(std::shared_ptr<ngraph::Node> reshape,
return
true
;
}
template
<
typename
T
>
static
std
::
vector
<
T
>
apply_permutation
(
std
::
vector
<
T
>
input
,
ngraph
::
AxisVector
order
)
{
if
(
input
.
size
()
!=
order
.
size
())
{
throw
"input and order sizes don't match!"
;
}
std
::
vector
<
T
>
output
(
input
.
size
());
for
(
size_t
i
=
0
;
i
<
order
.
size
();
i
++
)
{
output
[
i
]
=
input
.
at
(
order
.
at
(
i
));
}
return
output
;
}
void
ngraph
::
runtime
::
cpu
::
pass
::
CPUFusion
::
construct_matmulbias
()
{
Shape
shape_w
{
2
,
4
};
...
...
@@ -427,8 +412,8 @@ void ngraph::runtime::cpu::pass::CPUFusion::construct_zero_padded_reshaped_conv(
std
::
dynamic_pointer_cast
<
op
::
Reshape
>
(
pattern_map
[
reshape_label
]);
const
auto
&
input_order
=
matched_reshape
->
get_input_order
();
auto
hoisted_reshape_output_shape
=
apply_permutation
<
Shape
::
value_type
>
(
pattern_map
[
pad_input
]
->
get_shape
(),
input_order
);
auto
hoisted_reshape_output_shape
=
ngraph
::
apply_permutation
<
Shape
>
(
pattern_map
[
pad_input
]
->
get_shape
(),
input_order
);
auto
hoisted_reshape
=
std
::
make_shared
<
op
::
Reshape
>
(
pattern_map
[
pad_input
],
...
...
src/ngraph/util.cpp
View file @
04230095
...
...
@@ -29,6 +29,7 @@
#include "ngraph/node.hpp"
#include "ngraph/op/result_vector.hpp"
#include "ngraph/runtime/backend.hpp"
#include "ngraph/shape.hpp"
#include "ngraph/util.hpp"
#include <iostream>
...
...
@@ -451,6 +452,28 @@ void ngraph::check_fp_values_isnan(const char* name, const double* array, size_t
}
}
}
template
<
typename
T
>
T
ngraph
::
apply_permutation
(
T
input
,
AxisVector
order
)
{
if
(
input
.
size
()
!=
order
.
size
())
{
throw
"input and order sizes don't match!"
;
}
T
output
(
input
.
size
());
for
(
size_t
i
=
0
;
i
<
order
.
size
();
i
++
)
{
output
[
i
]
=
input
.
at
(
order
.
at
(
i
));
}
return
output
;
}
template
AxisVector
ngraph
::
apply_permutation
<
AxisVector
>
(
AxisVector
input
,
AxisVector
order
);
template
Shape
ngraph
::
apply_permutation
<
Shape
>
(
Shape
input
,
AxisVector
order
);
AxisVector
ngraph
::
get_default_order
(
const
Shape
&
shape
)
{
return
get_default_order
(
shape
.
size
());
...
...
src/ngraph/util.hpp
View file @
04230095
...
...
@@ -222,6 +222,8 @@ namespace ngraph
void
*
aligned_alloc
(
size_t
alignment
,
size_t
size
);
void
aligned_free
(
void
*
);
size_t
round_up
(
size_t
size
,
size_t
alignment
);
template
<
typename
T
>
T
apply_permutation
(
T
input
,
ngraph
::
AxisVector
order
);
AxisVector
get_default_order
(
size_t
rank
);
AxisVector
get_default_order
(
const
Shape
&
shape
);
...
...
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