Skip to content

[TE] Add LegalizeInvalidAttach to legalize the compute_at location after split or fuse - #5917

Merged
merrymercy merged 5 commits into
apache:masterfrom
merrymercy:pr-legalize-invalid-attach
Jun 26, 2020
Merged

[TE] Add LegalizeInvalidAttach to legalize the compute_at location after split or fuse#5917
merrymercy merged 5 commits into
apache:masterfrom
merrymercy:pr-legalize-invalid-attach

Conversation

@merrymercy

@merrymercymerrymercy commented Jun 24, 2020

Copy link
Copy Markdown
Member

Add LegalizeInvalidAttach in Schedule::normalize to legalize the compute_at location if the target iterator of compute_at is split or fused.

  • Case 1: If the target of compute_at is split, we will move the compute_at location to the inner iterator.
  • Case 2: If the target of compute_at is fused, we will move the compute_at location to the newly fused iterator.
    Case 2 can only happen if the target of compute_at is the innermost operand of fuse operation.

Examples: the following two cases will crash the compiler before this fix, but they are legal after this fix.

A=te.compute((10, 10), lambdai, j: 1.0, name='A')
B=te.compute((10, 10), lambdai, j: A[i][j], name='B')
# Case 1: Split an axis which is the target of a compute_ats=te.create_schedule([B.op])
s[A].compute_at(s[B], B.op.axis[1])
s[B].split(B.op.axis[1], 2)
print(tvm.lower(s, [A, B], simple_mode=True))
# Case 2: Fuse an axis which is the target of a compute_ats=te.create_schedule([B.op])
s[A].compute_at(s[B], B.op.axis[1])
s[B].fuse(B.op.axis[0], B.op.axis[1])
print(tvm.lower(s, [A, B], simple_mode=True))

@merrymercymerrymercy changed the title Add LegalizeInvalidAttach to legalize the compute_at location after split or fuse[TIR] Add LegalizeInvalidAttach to legalize the compute_at location after split or fuseJun 24, 2020
@merrymercymerrymercy changed the title [TIR] Add LegalizeInvalidAttach to legalize the compute_at location after split or fuse[TE] Add LegalizeInvalidAttach to legalize the compute_at location after split or fuseJun 24, 2020
@merrymercy

Copy link
Copy Markdown
MemberAuthor

This is a support PR for #5883. cc @tqchen@comaniac@jcf94

@tqchentqchen self-assigned this Jun 24, 2020

@comaniaccomaniac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM in terms of the functionality.

Comment threadsrc/te/schedule/schedule_dataflow_rewrite.cc
Comment threadsrc/te/schedule/schedule_dataflow_rewrite.cc
@merrymercy

Copy link
Copy Markdown
MemberAuthor

@tqchen@comaniac comments are addressed

@tqchen

tqchen commented Jun 25, 2020

Copy link
Copy Markdown
Member

cc @vinx13@Hzfengsy@spectrometerHBH please also help to take a look, we can proceed to merge after reviews by a few more eyes

@vinx13vinx13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@junrushaojunrushao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

Comment thread.gitignore
.python_history
.pytest_cache
.local
cmake-build-debug

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we don’t need this line

@merrymercymerrymercyJun 26, 2020

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is produced by my Jetbrain Clion

@merrymercy
merrymercy merged commit 96bf271 into apache:masterJun 26, 2020
@merrymercy
merrymercy deleted the pr-legalize-invalid-attach branch June 26, 2020 05:52
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jun 30, 2020
…ter split or fuse (apache#5917)
* Add LegalizeInvalidAttach
* lint & typo
* lint & typo
* address comment
* fix lint
zhiics pushed a commit to neo-ai/tvm that referenced this pull request Jul 2, 2020
…ter split or fuse (apache#5917)
* Add LegalizeInvalidAttach
* lint & typo
* lint & typo
* address comment
* fix lint
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@merrymercy@tqchen@vinx13@comaniac@junrushao@Hzfengsy