Commit Graph

4 Commits

Author SHA1 Message Date
Michael Suo
49979c4021 [symint] Make TensorImpl::sizes_and_strides_ contain SymInt
Change our representation of sizes and strides to contain SymInts
instead of int64_t.

Right now it's not actually possible to create a Tensor with symbolic
shape, so this change is intended to be a no-op.

But the intended behavior is:
- If you create a Tensor with symbolic shape, a `CustomSizes` policy
will be set, and the `has_symbolic_sizes_strides_` bit will be set. (not
currently implemented)
- Calling any TensorImpl function that naively interacts with sizes and
strides will throw. For hot-path functions (`sizes()`, `strides()`), we
make use of the existing policy check to throw. For others, we just have
a regular `TORCH_CHECK(!has_symbolic_sizes_strides_)`.

This also undoes the explicit constructor I made in
https://github.com/pytorch/pytorch/pull/77666; it ended up being more
annoying than useful when making these changes.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/78272

Approved by: https://github.com/Krovatkin, https://github.com/Chillee
2022-05-25 20:54:51 +00:00
PyTorch MergeBot
fb84f2223c Revert "[symint] Make TensorImpl::sizes_and_strides_ contain SymInt"
This reverts commit a7a818d9e2.

Reverted https://github.com/pytorch/pytorch/pull/77994 on behalf of https://github.com/seemethere due to Talked with @suo and we decided to revert because of broken [internal builds](https://www.internalfb.com/intern/sandcastle/job/678535557/). Also appears as though internal codegen might be broken as well.
2022-05-24 00:14:02 +00:00
Michael Suo
a7a818d9e2 [symint] Make TensorImpl::sizes_and_strides_ contain SymInt
Change our representation of sizes and strides to contain SymInts
instead of int64_t.

Right now it's not actually possible to create a Tensor with symbolic
shape, so this change is intended to be a no-op.

But the intended behavior is:
- If you create a Tensor with symbolic shape, a `CustomSizes` policy
will be set, and the `has_symbolic_sizes_strides_` bit will be set. (not
currently implemented)
- Calling any TensorImpl function that naively interacts with sizes and
strides will throw. For hot-path functions (`sizes()`, `strides()`), we
make use of the existing policy check to throw. For others, we just have
a regular `TORCH_CHECK(!has_symbolic_sizes_strides_)`.

This also undoes the explicit constructor I made in
https://github.com/pytorch/pytorch/pull/77666; it ended up being more
annoying than useful when making these changes.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/77994

Approved by: https://github.com/Krovatkin
2022-05-20 20:17:06 +00:00
Nikolay Korovaiko
99339fddd9 move SymInt and SymIntArrayRef to c10/core (#77009)
Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/77009
Approved by: https://github.com/ezyang, https://github.com/malfet
2022-05-11 16:21:31 +00:00