This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tosa] Updates tosa.equal to use the InferTensorType interface
ClosedPublic

Authored by not-jenni on Jul 22 2022, 10:32 AM.

Diff Detail

Event Timeline

not-jenni created this revision.Jul 22 2022, 10:32 AM
Herald added a project: Restricted Project. · View Herald Transcript
not-jenni requested review of this revision.Jul 22 2022, 10:32 AM
jpienaar added inline comments.Jul 22 2022, 7:35 PM
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
965–966

Lets move this up to where the custom shape functions are and leave these for nary infer ones.

974

Lets keep it consistent with others and verify operands are broadcastable.

Address comments

not-jenni marked 2 inline comments as done.Jul 25 2022, 12:51 PM
not-jenni added inline comments.
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
974

Done, and I moved up the resolveBroadcastShape function so that EqualOp::inferReturnTypeComponents can use it

jpienaar added inline comments.Jul 26 2022, 11:18 AM
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
349

This function is returning failure for case where operands are invalid as well as in this case where we can't produce anything other than unranked. That's not ideal. Could you add a TODO that this should be updated?

469

Lets return success here and then we can flatten else.

471

Instead of creating and mutating in place, I think we can just construct.

473

Above you are calculating the broadcasted shape but here you just take first operand which could not match the broadcasted shape (e.g., scalar first operand).

not-jenni updated this revision to Diff 450793.Aug 8 2022, 6:55 AM
not-jenni marked an inline comment as done.

Address comments

not-jenni marked 3 inline comments as done.Aug 8 2022, 6:58 AM
not-jenni added inline comments.
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
474

Above you are calculating the broadcasted shape but here you just take first operand which could not match the broadcasted shape (e.g., scalar first operand).

Should I be using the result type here instead of the first operand's type?

jpienaar added inline comments.Aug 8 2022, 8:29 AM
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
474

Use the shape you computed above in resolveBroadcastShape yes.

not-jenni updated this revision to Diff 450880.Aug 8 2022, 11:04 AM

Address comments

not-jenni marked 2 inline comments as done.Aug 8 2022, 11:05 AM
jpienaar accepted this revision.Aug 8 2022, 11:07 AM

LG and we can refine post the above TODO.

mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
478

Do we get here?

This revision is now accepted and ready to land.Aug 8 2022, 11:07 AM
not-jenni updated this revision to Diff 450921.Aug 8 2022, 1:22 PM

Address comments

not-jenni marked an inline comment as done.Aug 8 2022, 1:25 PM
not-jenni added inline comments.
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
478

Ah that case wouldn't be reached because resolveBroadcastShape already checks that all the tensors have rank

This revision was landed with ongoing or failed builds.Aug 8 2022, 4:12 PM
This revision was automatically updated to reflect the committed changes.