This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tosa] Add tosa.pad to linalg.pad operation
ClosedPublic

Authored by rsuderman on Mar 19 2021, 4:05 PM.

Details

Summary

Lowers from tosa's pad op to the linalg equivalent for floating,
integer, and quantized values.

Diff Detail

Event Timeline

rsuderman created this revision.Mar 19 2021, 4:05 PM
rsuderman requested review of this revision.Mar 19 2021, 4:05 PM
antiagainst accepted this revision.Mar 23 2021, 1:28 PM

Cool, just a few nits.

mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
676

Aren't these guaranteed by the source op's validation? If it's missing there, it's better to add there.

718

Use else if to chain them together so don't need to try the following cases if a previous one is hit?

720

Nit: this is quite skewed. What about having a local variable for it? :)

729

Should probably llvm_unreachable to guard against constant == null to fall through?

733

You can combine the create and replace with replaceOpWithNewOp.

This revision is now accepted and ready to land.Mar 23 2021, 1:28 PM
rsuderman updated this revision to Diff 332784.Mar 23 2021, 2:03 PM

Updated for Lei's comments

rsuderman marked 5 inline comments as done.Mar 23 2021, 2:05 PM
rsuderman added inline comments.
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
718

Changed to else ifs.

720

Instead of making the constant op for each I changed to just getting a valid Attr. Cleans up the skewed-ness quite a bit.

729

Added a rewriter error above.

733

Actually createPadOp is not the default constructor (instead containing some specialized behavior). It does not actually work with the constructor as a side effect so I need to separately construct and replace.

This revision was landed with ongoing or failed builds.Mar 23 2021, 2:18 PM
This revision was automatically updated to reflect the committed changes.
rsuderman marked 4 inline comments as done.