Description
🚀 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.