mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Fixes #143216 **Test Result** **Before** ```python >>> import torch >>> torch._refs.tensor([]) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/zong/code/pytorch/torch/_refs/__init__.py", line 6614, in tensor new_tensor = _internal_new_from_data( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/zong/code/pytorch/torch/_refs/__init__.py", line 6596, in _internal_new_from_data tensor = _recursive_build(inferred_scalar_type, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/zong/code/pytorch/torch/_refs/__init__.py", line 6545, in _recursive_build return torch.stack([_recursive_build(scalarType, item) for item in seq]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: stack expects a non-empty TensorList ``` **After** ```python >>> torch._refs.tensor([]) tensor([]) >>> torch._refs.tensor([], device='cuda') tensor([], device='cuda:0') ``` ```bash $ pytest test/test_tensor_creation_ops.py -k test_refs_tensor ```  ```bash $ lintrunner ```  Pull Request resolved: https://github.com/pytorch/pytorch/pull/143461 Approved by: https://github.com/ezyang, https://github.com/soulitzer |
||
|---|---|---|
| .. | ||
| linalg | ||
| nn | ||
| special | ||
| __init__.py | ||
| _conversions.py | ||
| fft.py | ||