Hi ! I have a mlir func with linalg.softmax.
module {
func.func @forward(%arg0: tensor<13x13xf32>) -> tensor<13x13xf32> {
%0 = tensor.empty() : tensor<13x13xf32>
%1 = linalg.softmax dimension(0) ins(%arg0 : tensor<13x13xf32>) outs(%0 : tensor<13x13xf32>) -> tensor<13x13xf32>
return %1 : tensor<13x13xf32>
}
}
Here is my passpipeline.
-arith-expand \
-eliminate-empty-tensors \
-empty-tensor-to-alloc-tensor \
-convert-elementwise-to-linalg \
-linalg-bufferize \
-convert-linalg-to-affine-loops \
-affine-loop-fusion \
-affine-parallelize \
-lower-affine \
-convert-scf-to-openmp \
-func-bufferize \
-arith-bufferize \
-tensor-bufferize \
-buffer-deallocation \
-finalizing-bufferize \
-convert-vector-to-scf \
-expand-strided-metadata \
-convert-vector-to-llvm \
-memref-expand \
-arith-expand \
-convert-arith-to-llvm \
-finalize-memref-to-llvm \
-convert-scf-to-cf \
-llvm-request-c-wrappers \
-convert-openmp-to-llvm \
-convert-math-to-llvm \
-convert-math-to-libm \
-convert-func-to-llvm \
-reconcile-unrealized-casts \
-mlir-print-ir-before-all \
It will finally result this.
// -----// IR Dump Before FinalizingBufferize (finalizing-bufferize) //----- //
func.func @forward(%arg0: memref<13x13xf32>) -> memref<13x13xf32> {
%0 = bufferization.to_tensor %arg0 : memref<13x13xf32>
%alloc = memref.alloc() {alignment = 64 : i64} : memref<13x13xf32>
%1 = bufferization.to_tensor %alloc : memref<13x13xf32>
memref.dealloc %alloc : memref<13x13xf32>
%2 = linalg.softmax dimension(0) ins(%0 : tensor<13x13xf32>) outs(%1 : tensor<13x13xf32>) -> tensor<13x13xf32>
%3 = bufferization.to_memref %2 : memref<13x13xf32>
return %3 : memref<13x13xf32>
}
error: failed to legalize operation 'linalg.softmax'
I think it is because linalg.softmax didn’t lower. Are there some wrongs in my pipeline? Thank you for your help.