pytorch
4dc5992a - [composite compliance] _make_wrapper_subclass respect strides (#78520)

Commit
2 years ago
[composite compliance] _make_wrapper_subclass respect strides (#78520) `at::for_blob` used to short-circuit if first dim had size `0` or if number of dims was `1`. `at::for_blob` is used in `_make_wrapper_subclass` implementation and resulted in `SubclassTensor` having different stride for the above case. ```python import torch from torch.testing._internal.composite_compliance import generate_cct elem = torch.ones(0,).as_strided((0,), (2,), 0) CCT = generate_cct() ret = CCT(elem) print(f"{ret.shape = }, {ret.stride() = }, {ret.elem.shape = }, {ret.elem.stride() = }") ``` Output Before ``` ret.shape = torch.Size([0]), ret.stride() = (1,), ret.elem.shape = torch.Size([0]), ret.elem.stride() = (2,) ``` Output After ``` ret.shape = torch.Size([0]), ret.stride() = (2,), ret.elem.shape = torch.Size([0]), ret.elem.stride() = (2,) ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/78520 Approved by: https://github.com/zou3519
Author
Committer
Parents
Loading