This is an archive of the discontinued LLVM Phabricator instance.

Add type function for ConstShape op.
ClosedPublic

Authored by jpienaar on May 10 2021, 10:24 AM.

Details

Summary
  • Enables inferring return type for ConstShape, takes into account valid return types;
  • The compatible return type function could be reused, leaving that for next use refactoring;

Diff Detail

Event Timeline

jpienaar created this revision.May 10 2021, 10:24 AM
jpienaar requested review of this revision.May 10 2021, 10:24 AM
Chia-hungDuan added inline comments.May 15 2021, 7:23 PM
mlir/lib/Dialect/Shape/IR/Shape.cpp
781–782

I'm thinking if we need to report error here. It seems to me this is to try to infer the return types, any errors may indicate we can't do that, so that is a failed case. What do you think?

789–791

I thinking that do we need to check this or we should have the assumption that it'll be the type we write in ODS? I.e., the size must be 1. Or if we have followed ODS, it's still possible to have size() > 1 case while calling isCompatibleReturnTypes?

In the following check

if (lhs.isa<ShapeType>() || rhs.isa<ShapeType>())
  // Shape type is compatible with all other valid return types.
  return true;

auto lhsTensorType = lhs.cast<TensorType>();
auto rhsTensorType = rhs.cast<TensorType>();

We assume if it's not ShapeType then it will be TensorType, this takes the ODS.

804–816

Can we use verifyCompatibleShapes?

frgossen accepted this revision.May 17 2021, 1:41 AM
frgossen added inline comments.
mlir/lib/Dialect/Shape/IR/Shape.cpp
806–810

Can they ever be something other than rank 1?

813

lhsTensorType.isDynamicDim(0) || ...

This revision is now accepted and ready to land.May 17 2021, 1:41 AM
jpienaar updated this revision to Diff 345948.May 17 2021, 11:33 AM
jpienaar marked 2 inline comments as done.

Updating to use verify compatible shape helper

This revision was landed with ongoing or failed builds.May 17 2021, 11:47 AM
This revision was automatically updated to reflect the committed changes.