[Mlir-commits] [mlir] [mlir][linalg] Add scalable vectorisation for depthwise convolutions (PR #81625)

Cullen Rhodes llvmlistbot at llvm.org
Thu Feb 15 02:15:40 PST 2024


================
@@ -1609,6 +1610,19 @@ static LogicalResult reductionPreconditions(LinalgOp op) {
 }
 
 static LogicalResult vectorizeDynamicLinalgOpPrecondition(linalg::LinalgOp op) {
+  // Support dynamic shapes in 1D depthwise convolution, but only in the
+  // _channel_ dimension. That's exclusively to support scalable vectorisation.
+  if (auto conv = dyn_cast<linalg::DepthwiseConv1DNwcWcOp>(op.getOperation())) {
+    auto lhsShaped = op.getDpsInputOperand(0)->get();
+    ArrayRef<int64_t> lhsShape =
+        dyn_cast<ShapedType>(lhsShaped.getType()).getShape();
+    auto shapeWithoutCh = lhsShape.drop_back(1);
+    if (ShapedType::isDynamicShape(shapeWithoutCh))
+      return failure();
+
+    return success();
----------------
c-rhodes wrote:

ah ok, I was suggesting
```suggestion
    if (ShapedType::isDynamicShape(lhsShape.back()))
      return success();

    return failure();
```
but as you say that's not checking if the other dims are static. Perhaps worth adding a negative test with dynamic dims other than channel to check nothing happens.

https://github.com/llvm/llvm-project/pull/81625


More information about the Mlir-commits mailing list