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][StorageRewrite] Allow in-place buffer reuse of non-flat memory #12655

Merged
merged 3 commits into from
Sep 6, 2022

Conversation

Lunderberg
Copy link
Contributor

@Lunderberg Lunderberg commented Aug 30, 2022

Previously, shared buffer use was entirely disabled for non-flat memory, since the existing checks for shared memory assume flat 1-d spaces. This was enforced in FindAlloc and validated in PrepareNewAlloc. The validation in PrepareNewAlloc could trigger, if the buffer sharing was due to an in-place operation, and not through the FindAlloc function.

In-place operations do not require N-d packing, nor do they introduce ambiguity in how different code generators may interpret non-flat physical indices. Therefore, this commit relaxes the validation in PrepareNewAlloc, allowing buffer reuse of non-flat buffers for in-place operations.

cc @Hzfengsy @junrushao1994

Previously, shared buffer use was entirely disabled for non-flat
memory, since the existing checks for shared memory assume flat 1-d
spaces.  This was enforced in `FindAlloc` and validated in
`PrepareNewAlloc`.  The validation in `PrepareNewAlloc` could trigger,
if the buffer sharing was due to an in-place operation, and not
through the `FindAlloc` function.

In-place operations do not require N-d packing, nor do they introduce
ambiguity in how different code generators may interpret non-flat
physical indices.  Therefore, this commit relaxes the validation in
`PrepareNewAlloc`, allowing buffer reuse of non-flat buffers for
in-place operations.
@Lunderberg
Copy link
Contributor Author

Lunderberg commented Aug 30, 2022

Unit tests in this PR depend on the T.decl_buffer syntax introduced in PR #12412. When that PR merges, this will be rebased on top of it and marked as ready for review.

@Lunderberg Lunderberg marked this pull request as ready for review August 31, 2022 17:51
@Lunderberg
Copy link
Contributor Author

cc @cconvey

@vinx13 vinx13 merged commit 744649e into apache:main Sep 6, 2022
@Lunderberg Lunderberg deleted the storagerewrite_inplace_nonflat branch September 6, 2022 18:49
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
…pache#12655)

* [TIR][StorageRewrite] Allow in-place buffer reuse of non-flat memory

Previously, shared buffer use was entirely disabled for non-flat
memory, since the existing checks for shared memory assume flat 1-d
spaces.  This was enforced in `FindAlloc` and validated in
`PrepareNewAlloc`.  The validation in `PrepareNewAlloc` could trigger,
if the buffer sharing was due to an in-place operation, and not
through the `FindAlloc` function.

In-place operations do not require N-d packing, nor do they introduce
ambiguity in how different code generators may interpret non-flat
physical indices.  Therefore, this commit relaxes the validation in
`PrepareNewAlloc`, allowing buffer reuse of non-flat buffers for
in-place operations.

* Update new StorageRewrite with correct allocate/buffer_decl usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants