This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Match element type of result when doing propagation of unpack through elementwise
ClosedPublic

Authored by qedawkins on Feb 20 2023, 4:22 PM.

Details

Summary

When propagating tensor.unpack ops through elementwise generics, a new
output tensor is needed if the element type of the input differs from
that of the output in the elementwise op.

Diff Detail

Event Timeline

qedawkins created this revision.Feb 20 2023, 4:22 PM
qedawkins requested review of this revision.Feb 20 2023, 4:22 PM
chelini added inline comments.Feb 21 2023, 2:45 AM
mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp
437–453

differs

441

Do we have a shorter way to get the element type from a generic?

445

Maybe a bit shorter if we write:

if (producerUnPackOp.getDestType().getElementType() != genericOutElementType)
qedawkins updated this revision to Diff 499164.Feb 21 2023, 7:15 AM

address comments

qedawkins marked an inline comment as done.Feb 21 2023, 7:19 AM
qedawkins added inline comments.
mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp
441

It's not shorter but perhaps this looks a bit cleaner? Alternatively we can try to infer the element type from the body of the generic (not sure exactly how to write that so it would be better than this).

qedawkins marked an inline comment as not done.Feb 21 2023, 7:20 AM
mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp
441

Thanks! Just found getElementTypeOrSelf. You can pass to it the result Value.

qedawkins updated this revision to Diff 499204.Feb 21 2023, 9:08 AM

Use getElementTypeOrSelf

qedawkins marked an inline comment as done.Feb 21 2023, 9:10 AM
qedawkins added inline comments.
mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp
441

Perfect, thanks for the tip!

chelini accepted this revision.Feb 21 2023, 9:14 AM

Thanks

This revision is now accepted and ready to land.Feb 21 2023, 9:14 AM