diff --git a/lib/Dialect/Torch/IR/TorchOps.cpp b/lib/Dialect/Torch/IR/TorchOps.cpp index d49bcaac2..c4223ae55 100644 --- a/lib/Dialect/Torch/IR/TorchOps.cpp +++ b/lib/Dialect/Torch/IR/TorchOps.cpp @@ -3505,7 +3505,11 @@ atenBinaryFloatOperatorFoldHelper(ArrayRef operands, // AtenAliasOp //===----------------------------------------------------------------------===// -OpFoldResult AtenAliasOp::fold(FoldAdaptor adaptor) { return getOperand(); } +OpFoldResult AtenAliasOp::fold(FoldAdaptor adaptor) { + if (getOperand().getType() != getResult().getType()) + return {}; + return getOperand(); +} //===----------------------------------------------------------------------===// // AtenFloordivIntOp