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
22412726
Commit
22412726
authored
Oct 07, 2019
by
Chengji Yao
Committed by
Wuwei Lin
Oct 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dicrease the complexity of CalcDep from exponential to linear (#4053)
parent
6961ad14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletions
+18
-1
src/relay/pass/dead_code.cc
+9
-1
tests/python/relay/test_pass_dead_code_elimination.py
+9
-0
No files found.
src/relay/pass/dead_code.cc
View file @
22412726
...
...
@@ -110,7 +110,15 @@ class CalcDep : private ExprVisitor {
VarMap
<
size_t
>
use_map_
;
void
VisitExpr
(
const
Expr
&
e
)
final
{
return
ExprFunctor
<
void
(
const
Expr
&
e
)
>::
VisitExpr
(
e
);
visit_counter_
[
e
.
get
()]
++
;
// The dce code seprate variable into three parts:
// used 0 times (remove)
// used 1 times (inline)
// used 2 times (dont do anything).
if
(
visit_counter_
[
e
.
get
()]
<=
2
)
{
using
TParent
=
ExprFunctor
<
void
(
const
Expr
&
)
>
;
TParent
::
VisitExpr
(
e
);
}
}
void
VisitExpr_
(
const
LetNode
*
l
)
final
{
...
...
tests/python/relay/test_pass_dead_code_elimination.py
View file @
22412726
...
...
@@ -19,7 +19,9 @@ from tvm import relay
from
tvm.relay
import
Function
,
transform
from
tvm.relay.analysis
import
alpha_equal
,
graph_equal
,
free_vars
,
assert_alpha_equal
from
tvm.relay.op
import
log
,
add
,
equal
,
subtract
from
tvm.relay.testing
import
inception_v3
import
pytest
class
env
:
def
__init__
(
self
):
...
...
@@ -129,6 +131,12 @@ def test_tuple_get_item():
assert
alpha_equal
(
Function
(
free_vars
(
dced
),
dced
),
Function
(
free_vars
(
g
),
g
))
@pytest.mark.timeout
(
timeout
=
10
,
method
=
"thread"
)
def
test_complexity
():
g
=
inception_v3
.
get_net
(
1
,
1000
,
(
3
,
299
,
299
),
'float32'
)
run_opt_pass
(
g
,
transform
.
DeadCodeElimination
())
if
__name__
==
"__main__"
:
test_let
()
test_used_let
()
...
...
@@ -138,3 +146,4 @@ if __name__ == "__main__":
test_recursion_dead
()
test_op_let
()
test_tuple_get_item
()
test_complexity
()
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