This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tosa] Add tosa.cast to linalg lowering
ClosedPublic

Authored by rsuderman on Mar 17 2021, 4:34 PM.

Details

Summary

Handles lowering from the tosa CastOp to the equivalent linalg lowering. It
includes support for interchange between bool, int, and floating point.

Diff Detail

Event Timeline

rsuderman created this revision.Mar 17 2021, 4:34 PM
rsuderman requested review of this revision.Mar 17 2021, 4:34 PM
antiagainst added inline comments.Mar 19 2021, 8:12 AM
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
293

So tosa::CastOp is an op from all types to all types? That's powerful.

I'm a bit puzzled by the if-else structure in the following. In my mind, it should follow the order of:

if (src == FpType && dst == FpType) {
  // Use fp to fp ops
} else if (src == FpType) {
  // Use fp to int ops and handle special case for bool
} else if (dst == FpType) {
  // use int to fp ops and handle special case for bool
} else {
  // Use int to int ops and handle special case for bool
}

or start with if (src == IntType && dst == IntType) ?

Cleaned up for clarity.

rsuderman marked an inline comment as done.Mar 19 2021, 11:12 AM
rsuderman added inline comments.
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
293

I reworked most of the lowering. This should be a lot cleaner.

antiagainst accepted this revision.Mar 19 2021, 11:39 AM
This revision is now accepted and ready to land.Mar 19 2021, 11:39 AM
This revision was landed with ongoing or failed builds.Mar 19 2021, 11:49 AM
This revision was automatically updated to reflect the committed changes.
rsuderman marked an inline comment as done.