10000 Representation string of a meta tensor is not a valid `tensor` call · Issue #147643 · pytorch/pytorch · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Representation string of a meta tensor is not a valid tensor call #147643
Open
@chajath

Description

@chajath

🚀 The feature, motivation and pitch

When creating tensor for meta device, the representation of the tensor is in the form of:

tensor(..., device='meta', size=(3,4))

If I try to run the representation code, I run into issues:

TypeError: tensor() got an unexpected keyword argument 'size'

this is different behavior to a concrete tensor where the valid construction call is given as a representation i.e.:

>>> # Not a valid call
>>> torch.empty(3,4, device='meta')
tensor(..., device='meta', size=(3, 4))
>>> # Valid tensor vall
>>> torch.empty(3,4)
tensor([[0., 0., 0., 0.],
        [0., 0., 0., 0.],
        [0., 0., 0., 0.]])

In the spirit of making representation runnable, it would be better to give an empty construction call i.e.:

>>> torch.empty([3,4], device="meta")
torch.empty([3,4], device='meta')

Alternatives

In the context of rendering, I would need to create a custom visitor that will check if the target object is meta tensor and redirect rendering to a custom rendering function

Additional context

We are generating code snippets and rely on representation strings of tensors in places where it makes sense.

cc @ezyang @eellison @bdhirsh @albanD

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: meta tensorsmodule: python frontendFor issues relating to PyTorch's Python frontendtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0