From 36a5d796b6faad49872a7594ec37cfd524767255 Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 6 Mar 2024 17:08:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20hack=5Ftensor.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hack_tensor.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 hack_tensor.md diff --git a/hack_tensor.md b/hack_tensor.md new file mode 100644 index 0000000..4eb26ad --- /dev/null +++ b/hack_tensor.md @@ -0,0 +1,14 @@ +# PyorchHack + +python3.10/site-packages/torch/_tensor.py + +``` + def __repr__(self, *, tensor_contents=None): + return "Tensor %s" % (str(self.size())) + if has_torch_function_unary(self): + return handle_torch_function( + Tensor.__repr__, (self,), self, tensor_contents=tensor_contents + ) + # All strings are unicode in Python 3. + return torch._tensor_str._str(self, tensor_contents=tensor_contents) +``` \ No newline at end of file