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] fix buffer_decl buffer allocation #13906

Merged
merged 1 commit into from
Feb 3, 2023

Conversation

cconvey
Copy link
Contributor

@cconvey cconvey commented Feb 2, 2023

  • Fix a bug where buffer_decl, combined with certain usage patterns of the resulting buffer, cause an TVM-internal assert failure during TIR-compilation.

@tvm-bot
Copy link
Collaborator

tvm-bot commented Feb 2, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@cconvey cconvey force-pushed the fix-buffer-decl-handling branch from a46d778 to ca96790 Compare February 2, 2023 15:15
@@ -111,6 +112,12 @@ class BufferAllocationLocator : public StmtExprMutator {
collector(func->body);
unmanaged_allocations_ = collector.unmanaged_allocations;

for (Var param : func->params) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for (Var param : func->params) {
for (const Var& param : func->params) {

# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import tvm
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a testcase in tests/python/unittest/test_tir_transform_plan_update_buffer_allocation_location.py as the code changes are in the related file?

@cconvey cconvey force-pushed the fix-buffer-decl-handling branch 2 times, most recently from 9166859 to 8d65c39 Compare February 2, 2023 15:33
@cconvey cconvey requested a review from Hzfengsy February 2, 2023 15:33
A[i] = 0

ir_mod = IRMod
built_mod = tvm.build(ir_mod)
Copy link
Member

Choose a reason for hiding this comment

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

It would be great to make the test "unit" enough, i.e., only test the related pass instead of a whole build workflow.

One of the common practices is to test the IRModule before and after the pass. Please see the test case test_1D_cascade_op_rolling_buffer() in the same file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, that's an excellent suggestion. Fixed (IMHO) in the newest version of the PR.

@cconvey cconvey force-pushed the fix-buffer-decl-handling branch from 8d65c39 to 2851525 Compare February 2, 2023 17:39
- Fix a bug where `buffer_decl`, combined with certain
  usage patterns of the resulting buffer, cause an TVM-internal
  assert failure during TIR-compilation.
@cconvey cconvey force-pushed the fix-buffer-decl-handling branch from 2851525 to 2035a7e Compare February 2, 2023 17:42
@cconvey cconvey requested a review from Hzfengsy February 2, 2023 17:44
@Hzfengsy
Copy link
Member

Hzfengsy commented Feb 3, 2023

Thanks @cconvey for the fixing and continuous improving

@Hzfengsy Hzfengsy merged commit a89ff3e into apache:main Feb 3, 2023
@cconvey cconvey deleted the fix-buffer-decl-handling branch February 3, 2023 12:37
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.

3 participants