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

Fix pipeline for view semantics #14

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix pipeline for view semantics #14

wants to merge 2 commits into from

Conversation

tkarna
Copy link
Collaborator

@tkarna tkarna commented Aug 12, 2024

  • adds cse,canonicalize passes before one-shot-bufferize to remove duplicate bufferization.to_memref ops
    • if multiple identical bufferization.to_memref ops are present, one-shot-bufferize will create a copies
  • adds a test that verifies that view semantics are correctly preserved

@tkarna tkarna requested a review from fschlimb August 12, 2024 14:20
fschlimb
fschlimb previously approved these changes Aug 13, 2024
Copy link
Contributor

@fschlimb fschlimb left a comment

Choose a reason for hiding this comment

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

Nice.
How/why can duplicate to_memrefs happen?

@tkarna
Copy link
Collaborator Author

tkarna commented Nov 7, 2024

While adding cse does fix the view semantics by eliminating duplicate bufferization.to_memref ops, the elimination of common sub-expressions in general can change semantics. For example, in

a = sp.ones((6, 6))
b = sp.ones((6, 6))
c = a + b

the creation of b is removed as duplicate of a and a is used instead. Resulting in a double free (both a and b are still returned as memrefs).

@fschlimb
Copy link
Contributor

fschlimb commented Nov 8, 2024

Ok, so the duplicate free gets explicitly triggered by sharpy?

@tkarna
Copy link
Collaborator Author

tkarna commented Nov 11, 2024

Ok, so the duplicate free gets explicitly triggered by sharpy?

Yes, exactly. And if we want to keep the array api semantics, b in the above example should not be a reference to a.

@tkarna tkarna force-pushed the fix-view-semantics branch from 6e94c3b to 87ec64d Compare January 9, 2025 09:36
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.

2 participants