This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Linalg] Generate unique LibraryCallName for LinalgOps.
ClosedPublic

Authored by kaitingwang on Mar 6 2023, 9:17 PM.

Details

Summary

When lowering LinalgToStandard for named UnaryFn/BinaryFn ops, ensure the fun name appears in the generated library name. Further, for linalg.copy to/from different address spaces, ensure the to/from address spaces are appended onto the library name for uniqueness. This fixes the lowering error with the linalg.copy testcase shown in this patch.

Diff Detail

Event Timeline

kaitingwang created this revision.Mar 6 2023, 9:17 PM
Herald added a project: Restricted Project. · View Herald Transcript
kaitingwang requested review of this revision.Mar 6 2023, 9:17 PM
ftynse added inline comments.Mar 14 2023, 10:33 AM
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
1806

There's no guarantee this cast succeeds. You likely want a dyn_cast and propagate failure.

Avoid performing cast here but instead, use getMemorySpaceAsInt() API.

ftynse requested changes to this revision.Mar 20 2023, 8:58 AM
ftynse added inline comments.
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
1806

getMemorySpaceAsInt is deprecated, and there is no guarantee it succeeds either. Furthermore, this is introducing a subtle behavior change where no suffix will be emitted for the address space 0 (this sounds desirable for the default memory space, but needs a test).

Please do a dyn_cast and just return failure() if it fails...

This revision now requires changes to proceed.Mar 20 2023, 8:58 AM
kaitingwang marked an inline comment as done.

Perform dyn_cast and upon failure, return failure().

ftynse accepted this revision.Mar 20 2023, 9:23 AM
This revision is now accepted and ready to land.Mar 20 2023, 9:23 AM
kaitingwang marked an inline comment as done.Mar 20 2023, 9:25 AM

Thanks for the review! @ftynse