This is an archive of the discontinued LLVM Phabricator instance.

Fix handling of rank-1 tensors in tosa.reduce_sum
ClosedPublic

Authored by ramiro050 on Oct 12 2022, 4:42 PM.

Details

Summary

The conversion of tosa.reduce_sum to linalg creates a
linalg.generic op that produces a tensor of rank `input_rank -
1`. This tensor is then expanded back into a tensor of rank
input_rank. In the case where the tensor being expanded is rank-0,
the reassociation map used must be empty. However, the current
implementation indexes and modifies the reassociation map independent
of the rank of the tensor being expanded, resulting in out-of-bounds
indexing when the tensor being expanded is rank-0. This commit adds a
guard to the reassociation map indexing.

Diff Detail

Event Timeline

ramiro050 created this revision.Oct 12 2022, 4:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2022, 4:42 PM
ramiro050 requested review of this revision.Oct 12 2022, 4:42 PM
jpienaar accepted this revision.Oct 12 2022, 5:01 PM

Good catch

mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
787

I'd suggest CHECK-DAG as these two are effecitively constants.

This revision is now accepted and ready to land.Oct 12 2022, 5:01 PM
ramiro050 updated this revision to Diff 467486.Oct 13 2022, 8:25 AM

Change CHECK to CHECK-DAG for constants in test

This revision was automatically updated to reflect the committed changes.