Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bug] Fix Erroneous handling of ndarray in real function in CFG (#8245)
Issue: # `arg_id` doesn't make sense when two statements come from different callables. Therefore we cannot decide whether a `ExternalPtrStmt` in the real function points to the same ndarray as another `ExternalPtrStmt` in the kernel by checking the `arg_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 the `FuncCallStmt`. Then, we can add support for it in the alias analysis. We also don't include the `ExternalPtrStmt`s in the real functions in the store destination sets as they don't make any sense. ### Brief Summary <!-- copilot:summary --> ### <samp>🤖 Generated by Copilot at ba828dc</samp> 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 <!-- copilot:walkthrough --> ### <samp>🤖 Generated by Copilot at ba828dc</samp> * Add a special case for alias analysis of external tensor base pointers ([link](https://github.com/taichi-dev/taichi/pull/8245/files?diff=unified&w=0#diff-de599d158682f1f0209f39aa58631d6df8d8ded1eacb00d7d6c5200ef7391793R17-R38)) * Skip external pointers and matrix pointers from external pointers when gathering store destinations of a function ([link](https://github.com/taichi-dev/taichi/pull/8245/files?diff=unified&w=0#diff-0bfbe49ff08844a76d5d2e1c5b81c2cf813be4a9089422b997bc380ec9a68eadL65-R75)) * Add a test case for real functions writing to external arrays or tensors in `test_ndarray.py` ([link](https://github.com/taichi-dev/taichi/pull/8245/files?diff=unified&w=0#diff-ca3c8d1edb25b6a7f4affbb79b2e3e74f73b3757e5d465258ce42ea9eb09fbc0R1132-R1150))
- Loading branch information