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
0ac2a8b6
Commit
0ac2a8b6
authored
6 years ago
by
Nick Korovaiko
Committed by
Robert Kimball
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swim a special case of broadcast (#2034)
parent
1daac094
master
v0.29.0-rc.0
v0.28.0-rc.1
v0.28.0-rc.0
v0.27.1-rc.3
v0.27.1-rc.2
v0.27.1-rc.1
v0.27.1-rc.0
v0.27.0-rc.1
v0.27.0-rc.0
v0.26.1-rc.0
v0.26.0
v0.26.0-rc.8
v0.26.0-rc.7
v0.26.0-rc.6
v0.26.0-rc.5
v0.26.0-rc.4
v0.26.0-rc.3
v0.26.0-rc.2
v0.26.0-rc.0
v0.25.1-rc.11
v0.25.1-rc.10
v0.25.1-rc.9
v0.25.1-rc.8
v0.25.1-rc.7
v0.25.1-rc.6
v0.25.1-rc.5
v0.25.1-rc.4
v0.25.1-rc.3
v0.25.1-rc.2
v0.25.1-rc.1
v0.25.1-rc.0
v0.25.0
v0.25.0-rc.3
v0.25.0-rc.2
v0.25.0-rc.1
v0.25.0-rc.0
v0.25.0-dev.0
v0.24.0
v0.24.0-rc.3
v0.24.0-rc.2
v0.24.0-rc.1
v0.24.0-rc.0
v0.23.0-rc.7
v0.23.0-rc.6
v0.23.0-rc.5
v0.23.0-rc.4
v0.23.0-rc.3
v0.23.0-rc.2
v0.23.0-rc.1
v0.23.0-rc.0
v0.22.2-rc.0
v0.22.1
v0.22.1-rc.0
v0.22.0
v0.22.0-rc.2
v0.22.0-rc.0
v0.21.0
v0.21.0-rc.1
v0.21.0-rc.0
v0.20.1-rc.4
v0.20.1-rc.3
v0.20.1-rc.2
v0.20.1-rc.1
v0.20.1-rc.0
v0.20.0-rc.2
v0.20.0-rc.1
v0.20.0-rc.0
v0.20.0-dev.0
v0.19.1
v0.19.1-rc.0
v0.19.0
v0.19.0-rc.5
v0.19.0-rc.4
v0.19.0-rc.3
v0.19.0-rc.2
v0.19.0-rc.1
v0.19.0-rc.0
v0.18.1
v0.18.1-rc.1
v0.18.1-rc.0
v0.18.0
v0.18.0-rc.2
v0.18.0-rc.1
v0.18.0-rc.0
v0.17.0-rc.1
v0.17.0-rc.0
v0.16.0-rc.3
v0.16.0-rc.2
v0.16.0-rc.1
v0.16.0-rc.0
v0.15.1-rc.2
v0.15.1-rc.1
v0.15.0
v0.15.0-rc.2
v0.15.0-rc.1
v0.15.0-rc.0
v0.14.0
v0.14.0-rc.1
v0.14.0-rc.0
v0.13.0
v0.12.0
v0.12.0-rc.2
v0.12.0-rc.1
v0.12.0-rc.0
v0.11.1
v0.11.0
v0.11.0-rc.1
v0.11.0-rc.0
v0.10.1
v0.10.0
v0.10.0-rc.6
v0.10.0-rc.5
v0.10.0-rc.4
v0.10.0-rc.3
v0.10.0-rc.2
v0.10.0-rc.1
v0.10.0-rc.0
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
cpu_reshape_sinking.cpp
src/ngraph/runtime/cpu/pass/cpu_reshape_sinking.cpp
+36
-0
No files found.
src/ngraph/runtime/cpu/pass/cpu_reshape_sinking.cpp
View file @
0ac2a8b6
...
...
@@ -84,6 +84,25 @@ static void delete_reshape(std::shared_ptr<Node> reshape)
}
}
static
bool
unique_dims
(
const
Shape
&
shape
)
{
if
(
shape
.
size
()
==
0
)
{
return
true
;
}
size_t
n
=
shape
.
at
(
0
);
for
(
size_t
i
=
1
;
i
<
shape
.
size
();
i
++
)
{
if
(
n
==
shape
.
at
(
i
))
{
return
false
;
}
}
return
true
;
}
static
void
mark_reshape_for_deletion
(
std
::
shared_ptr
<
Node
>
reshape
,
std
::
set
<
std
::
shared_ptr
<
Node
>>&
reshapes_to_delete
)
{
...
...
@@ -144,6 +163,23 @@ void swim(descriptor::Input* input, std::shared_ptr<op::Reshape> reshape)
NGRAPH_DEBUG
<<
"Propagating reshape "
<<
describe_reshape
(
csw
.
reshape
)
<<
" for "
<<
n
->
get_name
()
<<
" to "
<<
unary
->
get_argument
(
0
);
}
else
if
(
std
::
dynamic_pointer_cast
<
op
::
Broadcast
>
(
n
)
&&
n
->
get_argument
(
0
)
->
get_shape
().
size
()
==
1
&&
unique_dims
(
n
->
get_shape
()))
{
auto
old_broadcast
=
std
::
static_pointer_cast
<
op
::
Broadcast
>
(
n
);
ngraph
::
AxisSet
as
;
size_t
channel
=
n
->
get_argument
(
0
)
->
get_shape
().
at
(
0
);
for
(
size_t
i
=
0
;
i
<
n
->
get_shape
().
size
();
i
++
)
{
if
(
csw
.
reshape
->
get_shape
().
at
(
i
)
!=
channel
)
{
as
.
insert
(
i
);
}
}
auto
new_broadcast
=
std
::
make_shared
<
op
::
Broadcast
>
(
n
->
get_argument
(
0
),
csw
.
reshape
->
get_shape
(),
as
);
csw
.
input
->
replace_output
(
new_broadcast
->
get_outputs
().
at
(
0
));
}
//TODO: Add cases to push through Reshape and BinaryElementwiseArithmetic
else
{
...
...
This diff is collapsed.
Click to expand it.
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