[Bug] Fix Erroneous handling of ndarray in real function in CFG #8245
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: #
arg_id
doesn't make sense when two statements come from different callables. Therefore we cannot decide whether aExternalPtrStmt
in the real function points to the same ndarray as anotherExternalPtrStmt
in the kernel by checking thearg_id
of them.Instead, we can assume that all ndarrays passed into a real function can be modified. When a ndarray is passed into a real function, a
ExternalTensorBasePtrStmt
is inserted into the argument of the real function, which will appear in the store destinations of theFuncCallStmt
. Then, we can add support for it in the alias analysis. We also don't include theExternalPtrStmt
s in the real functions in the store destination sets as they don't make any sense.Brief Summary
🤖 Generated by Copilot at ba828dc
Add support for real functions writing to external arrays or tensors. Update alias analysis and store destination collection to handle external pointers. Add a test case for the new feature.
Walkthrough
🤖 Generated by Copilot at ba828dc
test_ndarray.py
(link)