This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tosa] Disable tosa shape verification between operands/results
ClosedPublic

Authored by rsuderman on Jul 22 2021, 3:43 PM.

Details

Summary

Tosa shape verification prevent shape propagation when coming from a dialect
of known shape. Relax this constraint to allow ingestion / shape propagation
from these other dialects.

Diff Detail

Event Timeline

rsuderman created this revision.Jul 22 2021, 3:43 PM
rsuderman requested review of this revision.Jul 22 2021, 3:43 PM
rsuderman updated this revision to Diff 361019.Jul 22 2021, 4:08 PM

Relaxed tosa tensor types to allow unranked in all cases as they could be
refined to valid types.

eric-k256 added inline comments.Jul 22 2021, 5:05 PM
mlir/include/mlir/Dialect/Tosa/IR/TosaTypesBase.td
123

I think it may confuse people if the Tosa_TensorND now includes unranked along with the given rank. Most of the ops which are flexible in their rank already take Tosa_Tensor, which is supposed to take ranked and unranked.
If we make this change, do we have the right validation that tensors are the right rank, as that was previously enforced by the type?
A comment noting why Tosa_UnrankedTensor is included in the defined tensor types would be helpful to add here .

rsuderman updated this revision to Diff 361039.Jul 22 2021, 5:24 PM

Updated with comment.

The short is we wanted unranked to be supported so that shape inference can
propagate to unranked tensors. If unranked tensors are illegal it requires all
constructed TOSA IR to be always valid.

By enabling unranked we can allow the shape inference to propagate known shapes
then fail if unranked tensors remain in the IR.

rsuderman marked an inline comment as done.Jul 22 2021, 5:25 PM
rsuderman added inline comments.
mlir/include/mlir/Dialect/Tosa/IR/TosaTypesBase.td
123

Added a comment to clarify. Short story is we need flexibility on allowing unranked tensors so that shape inference on unknown shape lowerings to still lower to TOSA. Then Tosa's shape inference can handle the remaining shape inference.

Essentially we can't say an UnrankedTensor is invalid because its rank is unknown. Rather we should depend on shape inference to propagate the shape and then (only) when that shape cannot be propagate we can label the IR as invalid.

eric-k256 accepted this revision.Jul 22 2021, 6:05 PM

Thanks for the clarification and comment.

This revision is now accepted and ready to land.Jul 22 2021, 6:05 PM
stellaraccident accepted this revision.Jul 22 2021, 10:19 PM

Makes sense. Thanks!

This revision was automatically updated to reflect the committed changes.
rsuderman marked an inline comment as done.