[mlir][Linalg] Fix incorrect erase order

This commit is contained in:
Nicolas Vasilache 2021-01-25 14:04:06 +00:00
parent d462aa5a61
commit 52e25523a9

View File

@ -595,11 +595,14 @@ LogicalResult mlir::linalg::hoistPaddingOnTensors(SimplePadOp &simplePadOp,
b.create<SubTensorOp>(loc, simplePadOp.getResultType(), packedTensor,
offsets, sizes, strides)
->getResult(0));
simplePadOp.erase();
Operation *toErase = simplePadOp;
// Make the newly cloned `simplePadOp` available to the caller.
simplePadOp =
cast<SimplePadOp>(bvm.lookup(simplePadOp.result()).getDefiningOp());
toErase->erase();
return success();
}