From ed901094c1a8d0ef07ef6a34abdd4df07501268a Mon Sep 17 00:00:00 2001 From: Maksim Levental Date: Mon, 21 Nov 2022 19:15:53 -0600 Subject: [PATCH] Fix https://github.com/llvm/torch-mlir/issues/1618 by stripping `requires_grad` from results of view ops. (#1624) --- python/torch_mlir/eager_mode/torch_mlir_tensor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/torch_mlir/eager_mode/torch_mlir_tensor.py b/python/torch_mlir/eager_mode/torch_mlir_tensor.py index 0bb593222..aae1e6581 100644 --- a/python/torch_mlir/eager_mode/torch_mlir_tensor.py +++ b/python/torch_mlir/eager_mode/torch_mlir_tensor.py @@ -131,6 +131,8 @@ class TorchMLIRTensor(torch.Tensor): if UNSUPPORTED_OPS.match(op_name): raise UnsupportedByTorchMlirEagerMode(op_name) + requires_grad = requires_grad and "view" not in op_name + if not hasattr(func, "_schema"): raise RuntimeError(f"op {func} has no schema.")