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
6d32037c
Unverified
Commit
6d32037c
authored
Nov 30, 2018
by
Tianqi Chen
Committed by
GitHub
Nov 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SCHEDULE] Fix code lowering when loop condition depends on outer axis. (#2208)
parent
94acff30
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
src/op/compute_op.cc
+11
-6
tests/python/unittest/test_schedule_schedule_ops.py
+11
-0
No files found.
src/op/compute_op.cc
View file @
6d32037c
...
...
@@ -321,27 +321,32 @@ Stmt MakeComputeStmt(const ComputeOpNode* self,
source
.
push_back
(
stage
->
op
.
output
(
i
));
}
MakeReduction
(
self
,
source
,
&
init
,
&
provide
);
init
=
op
::
Substitute
(
init
,
n
.
init_vmap
);
init
=
MergeNest
(
n
.
init_nest
,
init
);
init
=
op
::
Substitute
(
init
,
n
.
init_vmap
);
// common nest
std
::
vector
<
std
::
vector
<
Stmt
>
>
common
(
n
.
main_nest
.
begin
(),
n
.
main_nest
.
begin
()
+
n
.
num_common_loop
+
1
);
std
::
vector
<
std
::
vector
<
Stmt
>
>
reduce
(
n
.
main_nest
.
begin
()
+
n
.
num_common_loop
+
1
,
n
.
main_nest
.
end
());
provide
=
op
::
Substitute
(
provide
,
n
.
main_vmap
);
provide
=
MergeNest
(
reduce
,
provide
);
if
(
debug_keep_trivial_loop
)
{
return
MergeNest
(
common
,
provide
);
provide
=
MergeNest
(
common
,
provide
);
}
else
{
return
MergeNest
(
common
,
Block
::
make
(
init
,
provide
));
provide
=
MergeNest
(
common
,
Block
::
make
(
init
,
provide
));
}
// run substitution in the on the full nest, because loop condition
// could depend on outer loops.
return
op
::
Substitute
(
provide
,
n
.
main_vmap
);
}
else
{
std
::
vector
<
Stmt
>
provides
;
for
(
size_t
i
=
0
;
i
<
self
->
body
.
size
();
++
i
)
{
provides
.
emplace_back
(
MakeProvide
(
self
,
stage
->
op
.
output
(
i
)));
}
Stmt
provide
=
op
::
Substitute
(
Block
::
make
(
provides
),
n
.
main_vmap
);
return
MergeNest
(
n
.
main_nest
,
provide
);
Stmt
provide
=
Block
::
make
(
provides
);
provide
=
MergeNest
(
n
.
main_nest
,
provide
);
// run substitution in the on the full nest, because loop condition
// could depend on outer loops.
return
op
::
Substitute
(
provide
,
n
.
main_vmap
);
}
}
...
...
tests/python/unittest/test_schedule_schedule_ops.py
View file @
6d32037c
...
...
@@ -409,7 +409,18 @@ def test_schedule_tensor_compute3():
stmt
=
tvm
.
schedule
.
ScheduleOps
(
s
,
bounds
)
def
test_loop_dep_reduce
():
X
=
tvm
.
placeholder
(
shape
=
(
10
,),
name
=
"x"
)
def
f
(
n
):
rv
=
tvm
.
reduce_axis
((
0
,
n
))
return
tvm
.
sum
(
X
[
rv
],
axis
=
rv
)
Y
=
tvm
.
compute
(
X
.
shape
,
f
,
name
=
"y"
)
s
=
tvm
.
create_schedule
([
Y
.
op
])
f
=
tvm
.
build
(
s
,
[
X
,
Y
])
if
__name__
==
"__main__"
:
test_loop_dep_reduce
()
test_schedule_middle_cache
()
test_inline_multi_reduce
()
test_schedule_cache_relayout4
()
...
...
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