diff --git a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp @@ -476,6 +476,9 @@ DenseSet blockArgsToDetensor; FunctionOpInterface funcOp = getOperation(); + if (funcOp.getFunctionBody().empty()) + return; + // Make sure the entry block of the function doesn't contain any Linalg ops. // Otherwise, it may lead to the signature of the block being changed by the // dialect conversion below, which would make the function op invalid