mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-23 23:04:52 +08:00
Add python nested_tensor
and as_nested_tensor
constructors in torch.nested
(#85593)
Remove `torch.nested_tensor` which has erroneous behavior wrt gradients (could be either leaf or not leaf). Introduce `torch.nested.nested_tensor` and `torch.nested.as_nested_tensor` in the vein of `torch.tensor` and `torch.as_tensor`. Done in nested `__init__.py` for now but can move to pybind in future (when we want to load from numpy/nested lists ). Discussed offline with @cpuhrsch and pybind constructor (https://github.com/pytorch/pytorch/pull/85536) was more gnarly than expected, so we can move to that when we do need loading from numpy etc. Differential Revision: [D39806622](https://our.internmc.facebook.com/intern/diff/D39806622) Pull Request resolved: https://github.com/pytorch/pytorch/pull/85593 Approved by: https://github.com/drisspg, https://github.com/cpuhrsch
This commit is contained in:
committed by
PyTorch MergeBot
parent
a876432aea
commit
afaee00fec
@ -10,6 +10,6 @@
|
||||
TEST(NestedTest, Nested) {
|
||||
auto a = torch::randn({2, 3});
|
||||
auto b = torch::randn({4, 5});
|
||||
auto nt = torch::nested_tensor({a, b});
|
||||
auto nt = torch::nested::nested_tensor({a, b});
|
||||
torch::nested::to_padded_tensor(nt, 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user