[Mlir-commits] [mlir] [mlir][tosa] Optimize block scaled cast sequences (PR #188018)
Hocky Yudhiono
llvmlistbot at llvm.org
Mon Mar 23 05:12:48 PDT 2026
hockyy wrote:
btw, nit, the inverse has folding opportunity as well
```mlir
module {
func.func @test_canonicalize_cast_to_cast_from_block_scaled_f4E2M1(%arg0: tensor<15x3x2x256xf32>) -> (tensor<15x3x2x256xf32>, tensor<15x3x2x256xf4E2M1FN>, tensor<15x3x2x8xf8E8M0FNU>) {
%output_data, %output_scale = tosa.cast_to_block_scaled %arg0 {block_size = BLOCK_SIZE_32} : (tensor<15x3x2x256xf32>) -> (tensor<15x3x2x256xf4E2M1FN>, tensor<15x3x2x8xf8E8M0FNU>)
%0 = tosa.cast_from_block_scaled %output_data, %output_scale {block_size = BLOCK_SIZE_32} : (tensor<15x3x2x256xf4E2M1FN>, tensor<15x3x2x8xf8E8M0FNU>) -> tensor<15x3x2x256xf32>
return %0, %output_data, %output_scale : tensor<15x3x2x256xf32>, tensor<15x3x2x256xf4E2M1FN>, tensor<15x3x2x8xf8E8M0FNU>
}
}
```
https://github.com/llvm/llvm-project/pull/188018
More information about the Mlir-commits
mailing list