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
a1dfb9ae
Commit
a1dfb9ae
authored
Oct 30, 2018
by
xqdan
Committed by
Tianqi Chen
Oct 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PASS]unroll loops with extent=1 (#2027)
parent
ed1718b6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletions
+21
-1
src/pass/unroll_loop.cc
+3
-1
tests/python/unittest/test_pass_unroll.py
+18
-0
No files found.
src/pass/unroll_loop.cc
View file @
a1dfb9ae
...
...
@@ -76,7 +76,9 @@ class LoopUnroller : public IRMutator {
normal_loop_depth_
+=
1
;
}
if
(
auto_unroll
&&
explicit_unroll_
)
{
if
((
auto_unroll
&&
explicit_unroll_
)
||
// unroll loops with extent = 1, no matter how many steps in body
(
value
<=
auto_max_extent_
&&
auto_max_extent_
==
1
))
{
return
Unroll
(
op
);
}
else
{
if
(
auto_unroll
)
{
...
...
tests/python/unittest/test_pass_unroll.py
View file @
a1dfb9ae
...
...
@@ -35,6 +35,23 @@ def test_unroll_loop():
assert
isinstance
(
ret
.
rest
,
tvm
.
stmt
.
For
)
assert
ret
.
rest
.
for_type
!=
tvm
.
stmt
.
For
.
Unrolled
def
test_unroll_fake_loop
():
ib
=
tvm
.
ir_builder
.
create
()
dtype
=
'int32'
n
=
tvm
.
var
(
'n'
)
Ab
=
tvm
.
decl_buffer
((
n
,
),
dtype
)
Aptr
=
ib
.
buffer_ptr
(
Ab
)
# for i in 0 to n-1:
with
ib
.
for_range
(
0
,
1
,
name
=
"i"
)
as
i
:
Aptr
[
i
*
2
]
=
3
with
ib
.
for_range
(
0
,
10
,
name
=
"j"
)
as
j
:
Aptr
[
j
+
1
]
=
Aptr
[
i
]
+
1
stmt
=
ib
.
get
()
ret
=
tvm
.
ir_pass
.
UnrollLoop
(
stmt
,
8
,
0
,
1
,
True
)
assert
isinstance
(
ret
.
first
,
tvm
.
stmt
.
Store
)
if
__name__
==
"__main__"
:
test_unroll_loop
()
test_unroll_fake_loop
()
\ No newline at end of file
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