-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[TIR] 1-d AllocateNode::extent #9194
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
Conversation
b4f2b37 to
b162288
Compare
|
I've started a PR for an RFC that describes the motivation for this change in more detail. This change to |
8771fc8 to
623374c
Compare
|
Updated to resolve conflicts with main, change |
756ce1d to
73a854d
Compare
This commit has the primary goal of the PR, replacing the AllocateNode::extents variable, which represented the N-d shape of the tensor, with a 1-d AllocateNode::extent variable representing the amount of memory to be allocated. This is part of a larger push to support more flexible memory layouts across multiple device types, and to introduce a split between the physical layout in memory and the logical layout in a tensor or a compute definition.
After updating to a 1-d index in AllocateNode::extent, this commit adds all the secondary changes needed elsewhere in the codebase to be compatible with the 1-d extent.
Allow the IRBuilder to output BufferRealize/BufferLoad/BufferStore nodes, as well as Load/Store. This minimizes the changes that will be needed in the unit tests, as they can continue using N-d indices and allocations, which are then flattened during the `StorageFlatten` pass.
0e294bf to
b12082d
Compare
Some of the updated unit tests express allocation size as a product rather than as a single integer, for readability, but those products should still be treated as constant integers when determining the workspace size needed.
If UnrollLoop is applied before StorageFlatten, there may be BufferLoad/BufferStore nodes that haven't yet been lowered to Load/Store nodes. These should be counted equivalently to Store nodes.
These changes were not necessary for the UnrollLoop change in the previous commit to function, but were made as part of that investigation. They are kept as a separate commit in the PR for ease of review.
Previous test of CopyOnWrite semantics during StmtMutator relied on AllocateNode having an array parameter. Rewrote these tests to check the same behavior, but implemented over SeqStmtNode instead.
b12082d to
9b1d6e0
Compare
|
Updated to resolve breaks this caused in ethos unit tests. |
Currently in PR at apache#9194, waiting on RFC apache/tvm-rfcs#40. Locally, this is a merge commit for the 'allocate_node_1d', to help me keep track of which commits belong in which PRs.
|
Closing this PR, as changes resulting from discussion on apache/tvm-rfcs#39 has made this change no longer desirable. |
This PR replace the
AllocateNode::extentsvariable, which represented the logical N-d shape of the tensor, with a 1-dAllocateNode::extentvariable representing the amount of memory to be allocated. This is part of a larger push to support more flexible memory layouts across multiple device types, and to introduce a split between the physical layout in memory and the logical layout in a tensor or a compute definition.The commits of this PR are divided up into discrete sections to hopefully make it easier to review.
Change
AllocateNode::extents(plural) toAllocateNode::extent(singular). This first commit is the motivation for the PR, and the remaining commits are the additional changes needed to be compatible with this first change.C++ changes necessary to compile against the new
AllocateNodedefinition.A functionality addition to
IRBuilderto outputBufferRealize/BufferLoad/BufferStorenodes, in addition toAllocate/Load/Store. This minimizes the changes that will be needed in the unit tests, as they can continue using N-d indices and allocations withBufferRealize/BufferLoad/BufferStore, which are then flattened during theStorageFlattenpass.Update topi schedules to use 1-d extent.
Update python unittests to use 1-d extent.
Simplify() call added to workspace size calculation, needed for the workspace calculation unit tests.
Updated UnrollLoop to count
BufferStorein addition toStore. This resolves a breakage in the tests for unroll loop, and allows UnrollLoop to be used either before or afterStorageFlatten.Refactor of the tests for unroll loop. Done as part of the investigation for previous point, but kept as an independent commit for readability.