Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
c0cde10d
Commit
c0cde10d
authored
Oct 16, 2017
by
ziheng
Committed by
Tianqi Chen
May 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[OPT] Improve PreComputePrune When Output Is Pruned (#178)
parent
9a6feca6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
14 deletions
+26
-14
nnvm/src/compiler/precompute_prune.cc
+26
-14
No files found.
nnvm/src/compiler/precompute_prune.cc
View file @
c0cde10d
...
...
@@ -27,6 +27,25 @@ nnvm::Graph PrecomputePrune(nnvm::Graph src) {
// number of edges that are not variable
int
non_var_edge
=
0
;
auto
replace_pruned_entry
=
[
&
]
(
const
NodeEntry
&
e
)
{
if
(
!
entry_var
.
count
(
e
))
{
if
(
!
e
.
node
->
is_variable
())
{
++
non_var_edge
;
}
nnvm
::
NodePtr
var
=
nnvm
::
Node
::
Create
();
var
->
attrs
.
name
=
e
.
node
->
attrs
.
name
;
if
(
e
.
node
->
num_outputs
()
!=
1
)
{
var
->
attrs
.
name
+=
"_output"
+
std
::
to_string
(
e
.
index
);
}
entry_var
.
emplace
(
e
,
var
);
CHECK
(
!
unique_name
.
count
(
var
->
attrs
.
name
));
unique_name
.
insert
(
var
->
attrs
.
name
);
return
nnvm
::
NodeEntry
{
var
,
0
,
0
};
}
else
{
return
nnvm
::
NodeEntry
{
entry_var
.
at
(
e
),
0
,
0
};
}
};
DFSVisit
(
src
.
outputs
,
[
&
](
const
nnvm
::
NodePtr
&
n
)
{
bool
can_be_pruned
=
true
;
if
(
n
->
is_variable
())
{
...
...
@@ -47,20 +66,7 @@ nnvm::Graph PrecomputePrune(nnvm::Graph src) {
// scan again to find edge nodes, skip variables
for
(
auto
&
e
:
n
->
inputs
)
{
if
(
pruned
.
count
(
e
.
node
.
get
()))
{
if
(
!
entry_var
.
count
(
e
))
{
if
(
!
e
.
node
->
is_variable
())
{
++
non_var_edge
;
}
nnvm
::
NodePtr
var
=
nnvm
::
Node
::
Create
();
var
->
attrs
.
name
=
e
.
node
->
attrs
.
name
;
if
(
e
.
node
->
num_outputs
()
!=
1
)
{
var
->
attrs
.
name
+=
"_output"
+
std
::
to_string
(
e
.
index
);
}
entry_var
.
emplace
(
e
,
var
);
CHECK
(
!
unique_name
.
count
(
var
->
attrs
.
name
));
unique_name
.
insert
(
var
->
attrs
.
name
);
}
e
=
nnvm
::
NodeEntry
{
entry_var
.
at
(
e
),
0
,
0
};
e
=
replace_pruned_entry
(
e
);
}
}
}
...
...
@@ -71,6 +77,12 @@ nnvm::Graph PrecomputePrune(nnvm::Graph src) {
return
src
;
}
for
(
auto
&
e
:
src
.
outputs
)
{
if
(
pruned
.
count
(
e
.
node
.
get
()))
{
e
=
replace_pruned_entry
(
e
);
}
}
nnvm
::
Graph
pre_graph
;
pre_graph
.
outputs
.
reserve
(
entry_var
.
size
());
std
::
vector
<
std
::
string
>
output_names
;
...
...
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