Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIR] Ignore Allocate/AllocateConst in BufferAllocationLocator #10998

Merged

Conversation

Lunderberg
Copy link
Contributor

Prior to this commit, the BufferAllocationLocator mutator used in the PlanAndUpdateBufferAllocationLocation pass would erroneously insert an entry to BlockNode::alloc_buffers for buffers allocated using Allocate or AllocateConst nodes. This error was introduced in #9727, which deprecated Load and Store nodes, replacing them with BufferLoad and BufferStore nodes. As a result, BufferAllocationLocator identified these as buffers whose allocations should be moved to inner loops, rather than as unmanaged allocations that should be ignored.

This commit restores the earlier behavior by only operating on buffer allocations in BlockNode::alloc_buffers, and explicitly ignoring any buffers whose allocation is done with Allocate or AllocateConst.

Prior to this commit, the BufferAllocationLocator mutator used in the
PlanAndUpdateBufferAllocationLocation pass would erroneously insert an
entry to `BlockNode::alloc_buffers` for buffers allocated using
`Allocate` or `AllocateConst` nodes.  This error was introduced in
apache#9727, which deprecated `Load` and
`Store` nodes, replacing them with `BufferLoad` and `BufferStore`
nodes.  As a result, BufferAllocationLocator identified these as
buffers whose allocations should be moved to inner loops, rather than
as unmanaged allocations that should be ignored.

This commit restores the earlier behavior by only operating on buffer
allocations in `BlockNode::alloc_buffers`, and explicitly ignoring any
buffers whose allocation is done with `Allocate` or `AllocateConst`.
Previously, all buffers found were managed buffers, so this check
wasn't needed.
@vinx13 vinx13 merged commit b941196 into apache:main Apr 14, 2022
@Lunderberg Lunderberg deleted the tir_buffer_planning_ignore_allocateconst branch April 15, 2022 13:32
Lucien0 pushed a commit to Lucien0/tvm that referenced this pull request Apr 19, 2022
…e#10998)

* [TIR] Ignore Allocate/AllocateConst in BufferAllocationLocator

Prior to this commit, the BufferAllocationLocator mutator used in the
PlanAndUpdateBufferAllocationLocation pass would erroneously insert an
entry to `BlockNode::alloc_buffers` for buffers allocated using
`Allocate` or `AllocateConst` nodes.  This error was introduced in
apache#9727, which deprecated `Load` and
`Store` nodes, replacing them with `BufferLoad` and `BufferStore`
nodes.  As a result, BufferAllocationLocator identified these as
buffers whose allocations should be moved to inner loops, rather than
as unmanaged allocations that should be ignored.

This commit restores the earlier behavior by only operating on buffer
allocations in `BlockNode::alloc_buffers`, and explicitly ignoring any
buffers whose allocation is done with `Allocate` or `AllocateConst`.

* Only inject opaque block if managed buffers exist.

Previously, all buffers found were managed buffers, so this check
wasn't needed.
altanh pushed a commit to altanh/tvm that referenced this pull request Apr 28, 2022
…e#10998)

* [TIR] Ignore Allocate/AllocateConst in BufferAllocationLocator

Prior to this commit, the BufferAllocationLocator mutator used in the
PlanAndUpdateBufferAllocationLocation pass would erroneously insert an
entry to `BlockNode::alloc_buffers` for buffers allocated using
`Allocate` or `AllocateConst` nodes.  This error was introduced in
apache#9727, which deprecated `Load` and
`Store` nodes, replacing them with `BufferLoad` and `BufferStore`
nodes.  As a result, BufferAllocationLocator identified these as
buffers whose allocations should be moved to inner loops, rather than
as unmanaged allocations that should be ignored.

This commit restores the earlier behavior by only operating on buffer
allocations in `BlockNode::alloc_buffers`, and explicitly ignoring any
buffers whose allocation is done with `Allocate` or `AllocateConst`.

* Only inject opaque block if managed buffers exist.

Previously, all buffers found were managed buffers, so this check
wasn't needed.
Lunderberg added a commit to Lunderberg/tvm that referenced this pull request Mar 14, 2024
Prior to this commit, the `tir.PlanAndUpdateBufferAllocationLocation`
pass would attempt to merge buffer allocations, unless the buffer's
backing allocation was found in a `Allocate`, `AllocateConst`, or
`PrimFuncNode::params`.  Previous
PRs (e.g. apache#10998) collected these
locations and marked them as unmanaged.  However, this requires
exhaustively checking all locations where unmanaged allocations could
occur.

This PR updates `tir.PlanAndUpdateBufferAllocationLocation` to instead
collect the managed buffers, and only perform rewrites of these
managed buffers.  This only required inspection of `BlockNode`, and no
other constructs.

The unit test added in this PR is another location where unmanaged
buffers may be produced.
Lunderberg added a commit to Lunderberg/tvm that referenced this pull request Mar 15, 2024
Prior to this commit, the `tir.PlanAndUpdateBufferAllocationLocation`
pass would attempt to merge buffer allocations, unless the buffer's
backing allocation was found in a `Allocate`, `AllocateConst`, or
`PrimFuncNode::params`.  Previous
PRs (e.g. apache#10998) collected these
locations and marked them as unmanaged.  However, this requires
exhaustively checking all locations where unmanaged allocations could
occur.

This PR updates `tir.PlanAndUpdateBufferAllocationLocation` to instead
collect the managed buffers, and only perform rewrites of these
managed buffers.  This only required inspection of `BlockNode`, and no
other constructs.

The unit test added in this PR is another location where unmanaged
buffers may be produced.
vinx13 pushed a commit that referenced this pull request Mar 18, 2024
Prior to this commit, the `tir.PlanAndUpdateBufferAllocationLocation`
pass would attempt to merge buffer allocations, unless the buffer's
backing allocation was found in a `Allocate`, `AllocateConst`, or
`PrimFuncNode::params`.  Previous
PRs (e.g. #10998) collected these
locations and marked them as unmanaged.  However, this requires
exhaustively checking all locations where unmanaged allocations could
occur.

This PR updates `tir.PlanAndUpdateBufferAllocationLocation` to instead
collect the managed buffers, and only perform rewrites of these
managed buffers.  This only required inspection of `BlockNode`, and no
other constructs.

The unit test added in this PR is another location where unmanaged
buffers may be produced.
thaisacs pushed a commit to thaisacs/tvm that referenced this pull request Apr 3, 2024
…#16726)

Prior to this commit, the `tir.PlanAndUpdateBufferAllocationLocation`
pass would attempt to merge buffer allocations, unless the buffer's
backing allocation was found in a `Allocate`, `AllocateConst`, or
`PrimFuncNode::params`.  Previous
PRs (e.g. apache#10998) collected these
locations and marked them as unmanaged.  However, this requires
exhaustively checking all locations where unmanaged allocations could
occur.

This PR updates `tir.PlanAndUpdateBufferAllocationLocation` to instead
collect the managed buffers, and only perform rewrites of these
managed buffers.  This only required inspection of `BlockNode`, and no
other constructs.

The unit test added in this PR is another location where unmanaged
buffers may be produced.
Sign up for free to 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.

None yet

3 participants