This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add reifyReturnShape to shaped type OpInterface
ClosedPublic

Authored by jpienaar on Feb 27 2020, 3:09 PM.

Details

Reviewers
pifon2a
Summary

This call results in inserting operations that compute the return shape
dynamically for the operation.

Diff Detail

Event Timeline

jpienaar created this revision.Feb 27 2020, 3:09 PM
pifon2a added inline comments.Feb 27 2020, 4:05 PM
mlir/include/mlir/Analysis/InferTypeOpInterface.td
108

nit:

/*methodBody=*/[{}],
/*defaultImplementation=*/[{ return failure(); }]
mlir/test/lib/TestDialect/TestDialect.cpp
322

nit: maybe smth like:

auto sval = operandType.dyn_cast<ShapedType>();
if (!sval) {
    return emitOptionalError(location, "only shaped type operands allowed");
}
int64_t dim = sval.hasRank() ? sval.getShape().front() : ShapedType::kDynamicSize;
323–324

just out of curiosity: is reserve() really needed for 1 element?

325

why 17?

333

will smth like that work?

shapes = {builder.createOrFold<mlir::DimOp>(getLoc(), getOperand(0), 0)};
jpienaar updated this revision to Diff 247277.Feb 28 2020, 8:38 AM
jpienaar marked 6 inline comments as done.

Address review comments

jpienaar marked an inline comment as done.Feb 28 2020, 8:38 AM
jpienaar added inline comments.
mlir/test/lib/TestDialect/TestDialect.cpp
323–324

Not really, force of habit :)

325

To make it less likely that it accidentally happened :) No real reasion, completely arbitrary but I was using standard bitwidths as inputs and ensure it does get built.

pifon2a accepted this revision.Feb 28 2020, 8:40 AM
This revision is now accepted and ready to land.Feb 28 2020, 8:40 AM
jpienaar closed this revision.Feb 29 2020, 12:21 PM

Landed in e706533f0a52b2eb8929d4004d1daccd53feda29, removed the review line by accident.