Skip to content

Possible to only inline preview of the first line for each variable #1855

@zhuoqun-chen

Description

@zhuoqun-chen

I have a use case where I need to know the shapes of each torch.Tensor, I have a custom hack for pytorch in python:

import torch
torch_available = True
def torch_custom_repr(self):
    return f">>> {tuple(self.shape)}\n{torch_original_repr(self)}\non <{self.device}>\n<<< {tuple(self.shape)}"

torch_original_repr = torch.Tensor.__repr__
torch.Tensor.__repr__ = torch_custom_repr

Now it looks like this in debug mode:

Image

Is it possible to make it shorter like this:

Image

Metadata

Metadata

Assignees

Labels

needs reproIssue has not been reproduced yet

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions