[Mlir-commits] [mlir] [TOSA] Change PadOp padding to tosa.shape (PR #123133)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jan 16 14:52:55 PST 2025
================
@@ -823,51 +844,42 @@ LogicalResult tosa::PadOp::inferReturnTypeComponents(
PadOp::Adaptor adaptor,
SmallVectorImpl<ShapedTypeComponents> &inferredReturnShapes) {
ShapeAdaptor inputShape(adaptor.getInput1().getType());
- ShapeAdaptor paddingShape(adaptor.getPadding().getType());
+ auto paddingRank =
+ cast<tosa::shapeType>(adaptor.getPadding().getType()).getRank();
SmallVector<int64_t> outputShape;
- // If both inputs have unknown shape, we cannot determine the shape of the
- // output.
- if (!inputShape.hasRank() && !paddingShape.hasRank()) {
- inferredReturnShapes.push_back(ShapedTypeComponents());
- return success();
- }
-
- // If the input rank is unknown we can info the output rank using the
- // padding shape's first dim.
+ // If the input rank is unknown, we can infer the output rank using the
+ // padding shape's rank divided by 2.
if (!inputShape.hasRank()) {
- if (paddingShape.isDynamicDim(0)) {
- inferredReturnShapes.push_back(ShapedTypeComponents());
- return success();
- }
-
- outputShape.resize(paddingShape.getDimSize(0) / 2, ShapedType::kDynamic);
+ outputShape.resize(paddingRank / 2, ShapedType::kDynamic);
----------------
Jerry-Ge wrote:
I will update this API in another patch since this is not related to PadOp directly
https://github.com/llvm/llvm-project/pull/123133
More information about the Mlir-commits
mailing list