Memref to SPIRV Conversion

While lowering memref operations into spirv operations, for memref.load into spirv.load . I’m facing pattern match failure. Any thoughts on what I’m missing ?

Legalizing operation : ‘memref.load’(0x5645e05532b0) {
%180 = “memref.load”(%132, %104, %179) <{nontemporal = false}> : (memref<1x5xf64, strided<[5, 1], offset: ?>, spirv.storage_class>, index, index) → f64

  • Fold {
    } → FAILURE : unable to fold

  • Pattern : ‘memref.load → ()’ {
    Trying to match “(anonymous namespace)::LoadOpPattern”
    “(anonymous namespace)::LoadOpPattern” result 0
    } → FAILURE : pattern failed to match

  • Pattern : ‘memref.load → ()’ {
    Trying to match “(anonymous namespace)::IntLoadOpPattern”
    “(anonymous namespace)::IntLoadOpPattern” result 0
    } → FAILURE : pattern failed to match
    } → FAILURE : no matched legalization pattern
    //===-------------------------------------------===//
    error: failed to legalize operation ‘memref.load’

Hi @Vijethvk,

It’s hard to say what’s wrong based only on this error message. We have a mechanism to print more helpful errors – you can go the implementation of this conversion pattern (llvm-project/mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp at 7f2f905361558b9137855b00debfdcc5eb057729 · llvm/llvm-project · GitHub) and replace return failure(); with return rewriter.notifyMatchFailure(op, "reason");.

If things are not clear after that, I’d encourage you to open an issue on github and attach minimized MLIR input that reproduces the issue.

2 Likes

Resolved after adding createFoldMemRefAliasOpsPass in pass pipeline