Skip to content

Commit

Permalink
[AutoBump] Merge with fixes of 8787970 (Oct 11)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgehre-amd committed Jan 6, 2025
2 parents 721a334 + 8787970 commit 66b87ed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/torch-mlir/Dialect/Torch/IR/GeneratedTorchOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -11506,6 +11506,7 @@ def Torch_AtenReshapeOp : Torch_Op<"aten.reshape", [
printDefaultTorchOp(printer, *this, 2, 1);
}
}];
let hasFolder = 1;
}

def Torch_AtenReshapeAsOp : Torch_Op<"aten.reshape_as", [
Expand Down
13 changes: 13 additions & 0 deletions lib/Dialect/Torch/IR/TorchOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2261,6 +2261,19 @@ void AtenUnflattenIntOp::getCanonicalizationPatterns(
});
}

//===----------------------------------------------------------------------===//
// AtenReshapeOp
//===----------------------------------------------------------------------===//

OpFoldResult AtenReshapeOp::fold(FoldAdaptor adaptor) {
auto selfTy = dyn_cast<ValueTensorType>(getSelf().getType());
auto opTy = dyn_cast<ValueTensorType>(getType());
if (selfTy && selfTy == opTy && selfTy.hasSizes() &&
selfTy.toBuiltinTensor().hasStaticShape())
return getSelf();
return nullptr;
}

//===----------------------------------------------------------------------===//
// AtenSelectIntOp
//===----------------------------------------------------------------------===//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ def emit_with_mutating_variants(key, **kwargs):
emit("aten::repeat_interleave.Tensor : (Tensor, int?) -> (Tensor)")
emit("aten::repeat_interleave.self_int : (Tensor, int, int?, int?) -> (Tensor)")
emit("aten::tile : (Tensor, int[]) -> (Tensor)")
emit("aten::reshape : (Tensor, int[]) -> (Tensor)")
emit("aten::reshape : (Tensor, int[]) -> (Tensor)", has_folder=True)
emit("aten::reshape_as : (Tensor, Tensor) -> (Tensor)")
emit("aten::_reshape_alias : (Tensor, int[], int[]) -> (Tensor)")
emit("aten::resize : (Tensor, int[], int?) -> (Tensor)")
Expand Down

0 comments on commit 66b87ed

Please sign in to comment.