[Mlir-commits] [mlir] [mlir][tosa] Refactor convolution infer return type (PR #178869)
Luke Hutton
llvmlistbot at llvm.org
Thu Feb 12 05:48:56 PST 2026
================
@@ -3435,162 +3435,241 @@ static LogicalResult poolingInferReturnTypes(
return success();
}
-LogicalResult Conv2DOp::inferReturnTypeComponents(
- MLIRContext *context, ::std::optional<Location> location,
- Conv2DOp::Adaptor adaptor,
- SmallVectorImpl<ShapedTypeComponents> &inferredReturnShapes) {
- llvm::SmallVector<int64_t> outputShape(4, ShapedType::kDynamic);
+template <typename AdaptorT>
+class ConvInferShapeAdaptor;
- int64_t inputWidth = ShapedType::kDynamic;
- int64_t inputHeight = ShapedType::kDynamic;
- int64_t weightWidth = ShapedType::kDynamic;
- int64_t weightHeight = ShapedType::kDynamic;
-
- // Input shape describes input width/height and batch.
+class ConvInferShapeAdaptorBase {
----------------
lhutton1 wrote:
We spoke about this a little offline, but after looking at this more closely, I think I'd prefer to avoid it. Adding virtuals here will force a dynamic lookup and create a vtable, this results in a small overhead (minimal, but it exists). While I couldn't find a explicit document mentioning it, I think MLIR tries to avoid it, instead preferring static polymorphism. We could use the CRTP (Curiously Recurring Template Pattern) here to avoid this, but it seems a little overkill for an internal utility.
WDYT?
https://github.com/llvm/llvm-project/pull/178869
More information about the Mlir-commits
mailing list