This is an archive of the discontinued LLVM Phabricator instance.

[tosa][mlir] Add support for dynamic width/height for Conv2D inputs in tosa-to-linalg
ClosedPublic

Authored by NatashaKnk on Feb 16 2022, 2:09 PM.

Details

Diff Detail

Event Timeline

NatashaKnk created this revision.Feb 16 2022, 2:09 PM
NatashaKnk requested review of this revision.Feb 16 2022, 2:09 PM
jpienaar accepted this revision.Feb 17 2022, 5:49 AM

Nice, thanks!

mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
65

As is currently named the function may be confusing as the name is quite general (index refers to the type here, but many could think of index into tensor/index in axis sense). If we follow the other shape work, reifyConstantDim could work (else materialize would feel more natural locally, but the method to materialize the shape computations as actual ops in the module is using reify).

67

This is adding a cast unconditionally, one could use createOrFold (https://mlir.llvm.org/doxygen/classmlir_1_1ImplicitLocOpBuilder.html#aec0ceee6a6e834449c1f7c65d45b26e5) or just check the type before creating instead. (That also allows to assert that the type is compatible, so if you got a float attr instead of an integer one, you could flag it)

74

Could you rewrite the formula in terms of what the inputs are below? (And then like H=F(IH, ...)) If one just reads the comment one could think that this returns 2 values, one for the w and one for the h, but instead you have noticed it is one formula needed that enables calculating either by passing in different attributes needed.

133
mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-named.mlir
444

So (OOC) the reification of shape computations are currently combined with lowering to linalg? (There isn't a an intermediate step)

This revision is now accepted and ready to land.Feb 17 2022, 5:49 AM
rsuderman added inline comments.Feb 22 2022, 4:49 PM
mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-named.mlir
444

Thats my thought. It would be nice to have a better computation mechanism for reify-ing shapes but we explicitly do it during the lowering. I was wondering whether a refactor in the future to push it to a reification would help simplify things.

jpienaar added inline comments.Feb 22 2022, 5:25 PM
mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-named.mlir
444

I think we can get there with InferTensorTypeWithReify + perhaps some cleanups in its reify mechanism (ValueShapeRange is intended to allow injecting info without mutating). Such a refactor would be great!

Small clarity updates

NatashaKnk marked 4 inline comments as done.Feb 24 2022, 8:42 AM
This revision was landed with ongoing or failed builds.Mar 2 2022, 12:23 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2022, 12:23 PM