This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Add canonicalizers for depthwise conv
ClosedPublic

Authored by rsuderman on Aug 30 2021, 5:01 PM.

Details

Summary

There are two main versions of depthwise conv depending whether the multiplier
is 1 or not. In cases where m == 1 we should use the version without the
multiplier channel as it can perform greater optimization.

Add lowering for the quantized/float versions to have a multiplier of one.

Diff Detail

Event Timeline

rsuderman created this revision.Aug 30 2021, 5:01 PM
rsuderman requested review of this revision.Aug 30 2021, 5:01 PM

Rebased on head to retrigger presubmits

This feels like you want the inverse of the generalize transformation ..
The way it would work is you'd:

  1. replace the named op by the generic impl
  2. drop the unit dims you want out
  3. compare that to the generic coming from a subset of candidate ops.

Basically that would avoid and inverse problem and replace it by a search and 2 forward problems (i.e. just compare the generated version from a database of named ops).
I could see how to get that in the absence of attributes but attributes are definitely more tricky (unless you know they are not going to be modified which seems to be the case here).

We had discussed this in the past with @antiagainst ; do you see an opportunity to make progress on the above?

antiagainst accepted this revision.Sep 14 2021, 10:55 AM

We had discussed this in the past with @antiagainst ; do you see an opportunity to make progress on the above?

Sorry for the late reply. Missed this one. I haven't been able to find time to work on the inverse of Linalg generalization. Likely also true for the near future. So I'd +1 to land this for now given Rob already have it to serve the current use cases.

mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
3059

Can cast to LinalgOp and then check hasTensorSemantics.

This revision is now accepted and ready to land.Sep 14 2021, 10:55 AM
rsuderman updated this revision to Diff 372781.Sep 15 2021, 1:02 PM

Fixed for antiagainst@ comments. Checking clang-tidy passes.

This revision was automatically updated to reflect the committed changes.