Add support for directly passing symint to empty#79494
Add support for directly passing symint to empty#79494ezyang wants to merge 3 commits intogh/ezyang/1221/basefrom
Conversation
Signed-off-by: Edward Z. Yang <ezyang@fb.com> [ghstack-poisoned]
🔗 Helpful links
✅ No Failures (0 Pending)As of commit 64374ac (more details on the Dr. CI page): Expand to see more💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
Signed-off-by: Edward Z. Yang <ezyangfb.com> [ghstack-poisoned]
Signed-off-by: Edward Z. Yang <ezyangfb.com> [ghstack-poisoned]
| // TODO: technically we need to check that the classes match | ||
| if (!a) { | ||
| a = common->wrap(data_); | ||
| toSymInt(a); // |
There was a problem hiding this comment.
toSymInt has a side-effect of persisting SymIntNodes into a SymIntTable, so a comment would probably help why we need to do this given that SymInt::toSymInt(a->add(b)); should have strong references to both a and b?
There was a problem hiding this comment.
This code is completely broken anyway; every time you convert SymbolicIntNode to SymInt the current code allocates a fresh table entry which is wrong
| ) { | ||
| auto device = device_or_default(device_opt); | ||
| TORCH_INTERNAL_ASSERT_DEBUG_ONLY(device.type() == DeviceType::Meta); | ||
| // NB: because there is no SparseMeta (yet), non-strided layout is |
| std::vector<SymInt> strides; | ||
| strides.resize(dim); | ||
|
|
||
| // TODO: Move this into TensorImpl |
There was a problem hiding this comment.
Isn't that already? You have the empty_tensor_restride(MemoryFormat::Contiguous) that does this.
There was a problem hiding this comment.
nit: it does feel like we need a helper here.
There was a problem hiding this comment.
empty_tensor_restride doesn't operate on symbolic integers. I'm a little torn about whether or not to directly SymInt'ify it or maintain two separate versions; there's a lot of arithmetic operations going on and it would be better for them to be all unchecked
| SparseCsrCPU, SparseCsrCUDA: empty_sparse_compressed | ||
| QuantizedCPU, QuantizedCUDA: empty_unknown_quantized | ||
|
|
||
| - func: empty.SymInt(SymInt[] size, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, MemoryFormat? memory_format=None) -> Tensor |
There was a problem hiding this comment.
No overload conflict for this one?
There was a problem hiding this comment.
Ho right this is done under the hood.
| std::vector<SymInt> strides; | ||
| strides.resize(dim); | ||
|
|
||
| // TODO: Move this into TensorImpl |
There was a problem hiding this comment.
nit: it does feel like we need a helper here.
| // TODO: technically we need to check that the classes match | ||
| if (!a) { | ||
| a = common->wrap(data_); | ||
| toSymInt(a); // |
There was a problem hiding this comment.
toSymInt has a side-effect of persisting SymIntNodes into a SymIntTable, so a comment would probably help why we need to do this given that SymInt::toSymInt(a->add(b)); should have strong references to both a and b?
albanD
left a comment
There was a problem hiding this comment.
Will need some cleanup, but sounds ok.
|
@pytorchbot merge |
|
@pytorchbot successfully started a merge job. Check the current status here |
|
Hey @ezyang. |
|
@pytorchbot revert |
|
❌ 🤖 pytorchbot command failed: Try |
|
@pytorchbot revert -m "conflicts with earlier diff that needs revert" |
|
@pytorchbot successfully started a revert job. Check the current status here |
|
Reverting PR 79494 failed due to Comment @pytorchbot revert -m "conflicts with earlier diff that needs revert" does not seem to be a valid revert command |
|
@pytorchbot revert -m "conflicts with earlier diff that needs revert" -c weird |
|
@pytorchbot successfully started a revert job. Check the current status here |
This reverts commit 05664a9. Reverted #79494 on behalf of https://github.com/ezyang due to conflicts with earlier diff that needs revert
Signed-off-by: Edward Z. Yang <ezyangfb.com> Pull Request resolved: pytorch#79494 Approved by: https://github.com/albanD
This reverts commit 3d96708. Reverted pytorch#79494 on behalf of https://github.com/ezyang due to conflicts with earlier diff that needs revert
Stack from ghstack (oldest at bottom):
Signed-off-by: Edward Z. Yang ezyang@fb.com