Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gdb print methods support same as pytorch-lldb (pytorch#140935)
`pytorch-lldb` support pretty printing size and key_set of tensor via pytorch#97101 Add same pretty printing for gdb debugging. **Test Result** ```bash $ gdb python (gdb) break at::native::negative (gdb) r >>> import torch >>> t = torch.tensor([1, 2, 3, 4], dtype=torch.float64) >>> t.negative() Thread 1 "python" hit Breakpoint 1, at::native::negative (self=...) at /home/zong/code/pytorch/aten/src/ATen/native/UnaryOps.cpp:854 854 Tensor negative(const Tensor& self) { return self.neg(); } ``` **Before** ```bash (gdb) p self.key_set() $2 = {repr_ = 1271310352385} (gdb) p self.sizes() $3 = {Data = 0x9cb488, Length = 1} ``` **After** ```bash (gdb) torch-int-array-ref-repr self.sizes() [4] (gdb) torch-dispatch-keyset-repr self.key_set() DispatchKeySet(CPU, ADInplaceOrView, AutogradCPU, AutocastCPU) ``` ```bash $ lintrunner ``` ![image](https://github.com/user-attachments/assets/b720e284-13b1-4581-ae3a-963f6482fdb2) Pull Request resolved: pytorch#140935 Approved by: https://github.com/drisspg
- Loading branch information