[bufferization] generate unexpected layout for CastOp when their layouts of input and output are different
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
* For example, the input layout is nN, while don't record the output layout
```
%cast = tensor.cast %8 : tensor}> to tensor
```
* After OneShotBufferizePass, becomes:
```
cast = memref.cast %alloc_2 : memref}> to memref}>
```
* This bacause the getBufferType of **CastOpInterface** copies srcBufferType.getLayout() as the result memref layout, ignoring the target tensor's actual layout attributes. When target tensor has no custom layout.
https://github.com/llvm/llvm-project/blob/bea7080fe3ce45d397c2aefda3e27dff868f7746/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp#L85
Contributor guide
Research direction
Start in mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp at the CastOpInterface getBufferType implementation linked in the issue. Trace how the source and target tensor types provide layout attributes, then verify the bufferized cast when the input has a custom layout and the target does not. Done means the generated memref cast preserves the target's actual layout rather than copying the source layout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100