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
0138997f
Commit
0138997f
authored
Sep 01, 2017
by
Tianqi Chen
Committed by
GitHub
Sep 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BUILD] Allow inject custom pass via phase (#408)
parent
f73c461f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
python/tvm/build_module.py
+16
-4
No files found.
python/tvm/build_module.py
View file @
0138997f
...
...
@@ -62,6 +62,7 @@ class BuildConfig(object):
assert
self
.
_old_scope
BuildConfig
.
current
=
self
.
_old_scope
BuildConfig
.
current
=
BuildConfig
()
def
build_config
(
**
kwargs
):
...
...
@@ -102,7 +103,8 @@ def build_config(**kwargs):
Whether split the loop containing double buffer so
that the buffer fetching won't contain condition.
add_lower_pass: list of function(Stmt->Stmt), default=None
add_lower_pass: list of tuiple (phase, function(Stmt->Stmt)), default=None
phase contains an integer on which optimization pass we apply the pass.
Additional lowering passes to be applied before make_api.
Returns
...
...
@@ -193,11 +195,19 @@ def lower(sch,
"""
binds
,
arg_list
=
get_binds
(
args
,
binds
)
cfg
=
BuildConfig
.
current
add_lower_pass
=
cfg
.
add_lower_pass
if
cfg
.
add_lower_pass
else
[]
lower_phase0
=
[
x
[
1
]
for
x
in
add_lower_pass
if
x
[
0
]
==
0
]
lower_phase1
=
[
x
[
1
]
for
x
in
add_lower_pass
if
x
[
0
]
==
1
]
lower_phase2
=
[
x
[
1
]
for
x
in
add_lower_pass
if
x
[
0
]
>
1
]
# normalize schedule first
sch
=
sch
.
normalize
()
# Phase 0
bounds
=
schedule
.
InferBound
(
sch
)
stmt
=
schedule
.
ScheduleOps
(
sch
,
bounds
)
stmt
=
ir_pass
.
InjectPrefetch
(
stmt
)
for
f
in
lower_phase0
:
stmt
=
f
(
stmt
)
# Phase 1
stmt
=
ir_pass
.
StorageFlatten
(
stmt
,
binds
,
64
)
stmt
=
ir_pass
.
CanonicalSimplify
(
stmt
)
if
not
simple_mode
:
...
...
@@ -211,13 +221,15 @@ def lower(sch,
cfg
.
auto_unroll_max_step
,
cfg
.
auto_unroll_min_depth
,
cfg
.
unroll_explicit
)
if
cfg
.
add_lower_pass
:
for
f
in
cfg
.
add_lower_pass
:
stmt
=
f
(
stmt
)
for
f
in
lower_phase1
:
stmt
=
f
(
stmt
)
# Phase 2
stmt
=
ir_pass
.
Simplify
(
stmt
)
stmt
=
ir_pass
.
LowerStorageAccessInfo
(
stmt
)
stmt
=
ir_pass
.
RemoveNoOp
(
stmt
)
stmt
=
ir_pass
.
RewriteUnsafeSelect
(
stmt
)
for
f
in
lower_phase2
:
stmt
=
f
(
stmt
)
if
simple_mode
:
return
stmt
return
ir_pass
.
MakeAPI
(
stmt
,
name
,
arg_list
,
0
,
cfg
.
restricted_func
)
...
...
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