Skip to content

[mlir][linalg]: Fixed possible memory leak in cloneToCollapsedOp #87595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1497,9 +1497,10 @@ LinalgOp cloneToCollapsedOp<LinalgOp>(RewriterBase &rewriter, LinalgOp origOp,
SmallVector<Type> resultTypes;
collapseOperandsAndResults(origOp, collapsingInfo, rewriter, inputOperands,
outputOperands, resultTypes);
return cast<LinalgOp>(clone(

return clone(
rewriter, origOp, resultTypes,
llvm::to_vector(llvm::concat<Value>(inputOperands, outputOperands))));
llvm::to_vector(llvm::concat<Value>(inputOperands, outputOperands)));
}

/// Collapse a `GenericOp`
Expand Down
6 changes: 4 additions & 2 deletions mlir/lib/Dialect/Utils/StructuredOpsUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@ Operation *mlir::clone(OpBuilder &b, Operation *op, TypeRange newResultTypes,
IRMapping bvm;
OperationState state(op->getLoc(), op->getName(), newOperands, newResultTypes,
op->getAttrs());
for (Region &r : op->getRegions())
r.cloneInto(state.addRegion(), bvm);
for (Region &r : op->getRegions()) {
Region *newRegion = state.addRegion();
b.cloneRegionBefore(r, *newRegion, newRegion->begin(), bvm);
}
return b.create(state);
}

Expand Down