mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Add torch.nested
namespace (#84102)
First step towards #83775 - only `to_padded_tensor` is moved to the nested namespace for now - following the schema used for `special`, `fft`, `linalg` and other namespaces, nested functions are registered in native_functions.yaml as `nested_{function_name}` and are bound to the desired Python name in `torch/nested/__init__.py`, and the desired C++ name in `torch/csrc/api/include/torch/nested.h`. ~~**Question**: should we keep the documentation for `Tensor.to_padded_tensor` or can this deleted since it is shared by `torch.nested.to_padded_tensor`?~~ [generated nested docs](https://docs-preview.pytorch.org/84102/nested.html?highlight=nested#module-torch.nested) Differential Revision: [D39361148](https://our.internmc.facebook.com/intern/diff/D39361148) Pull Request resolved: https://github.com/pytorch/pytorch/pull/84102 Approved by: https://github.com/drisspg
This commit is contained in:
committed by
PyTorch MergeBot
parent
9c78f599e4
commit
e217b30b0f
@ -213,7 +213,7 @@ class TestMHADeviceType(TestCase):
|
||||
q, k, v, key_padding_mask=mask if use_padding and not use_nt else None
|
||||
)
|
||||
if use_nt:
|
||||
ynpt = ynpt.to_padded_tensor(0)
|
||||
ynpt = torch.nested.to_padded_tensor(ynpt, 0)
|
||||
if pad_all:
|
||||
ynpt_final = torch.zeros_like(ypt)
|
||||
ynpt_final[:, :ynpt.shape[1], :] = ynpt
|
||||
|
Reference in New Issue
Block a user