This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][TOSA] Tosa elementwise broadcasting
ClosedPublic

Authored by rsuderman on Feb 5 2021, 5:20 PM.

Details

Summary

Added support for broadcasting size-1 dimensions for TOSA elementwise
operations.

Diff Detail

Event Timeline

rsuderman created this revision.Feb 5 2021, 5:20 PM
rsuderman requested review of this revision.Feb 5 2021, 5:20 PM

There is a typo in the commit description: elemtnwise

mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
154–155

The way the error message is worded makes me think that this should be an assert.

160

Cache end iterators to avoid recomputing during the loop.

https://llvm.org/docs/CodingStandards.html#don-t-evaluate-end-every-time-through-a-loop

187

nit: Spell out auto here. Type is the same number of characters as auto.

194

nit: Drop trivial braces here.

205

Same comment here on braces, and caching the number of results. Although in this case, seems better to do something like:

indexingMaps.append(operation->getNumResults(), rewriter.getMultiDimIdentityMap(nloops));
rsuderman edited the summary of this revision. (Show Details)Feb 5 2021, 7:24 PM
rsuderman updated this revision to Diff 321913.Feb 5 2021, 7:34 PM

rriddle@ comments

rsuderman marked 5 inline comments as done.Feb 5 2021, 7:34 PM
silvas added inline comments.Feb 9 2021, 12:10 PM
mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
17

add tests

ssilva@ comments for additional broadcast tests.

rsuderman marked an inline comment as done.Feb 10 2021, 12:43 PM
rsuderman added inline comments.
mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
17

I revamped the previous failing broadcasting test. Updated to include additional broadcasting tests.

silvas accepted this revision.Feb 10 2021, 2:32 PM
silvas added inline comments.
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
155

add assertion message.

163

Tosa op verifiers should enforce this already. Can be deleted.

181–182

Now it supports broadcast :)

mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
58–68

Capture with filecheck. Example of "non-local" capture requires "$": https://github.com/llvm/llvm-project/blob/main/mlir/test/Conversion/SCFToGPU/parallel_loop.mlir#L18

This revision is now accepted and ready to land.Feb 10 2021, 2:32 PM
rsuderman updated this revision to Diff 322838.Feb 10 2021, 3:13 PM
rsuderman marked an inline comment as done.

Removed unneeded checks. Updated broadcasting comments.

rsuderman updated this revision to Diff 322840.Feb 10 2021, 3:21 PM
rsuderman marked 3 inline comments as done.

Updated to reference affine maps through variable capture

rsuderman marked an inline comment as done.Feb 10 2021, 3:21 PM
This revision was landed with ongoing or failed builds.Feb 10 2021, 3:29 PM
This revision was automatically updated to reflect the committed changes.