mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Fix docstring for torch.UntypedStorage.from_file (#155067)
Fixes #130629 Happy to revert the second commit if we think it's making the test too fragile for the future Pull Request resolved: https://github.com/pytorch/pytorch/pull/155067 Approved by: https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
a1057cda31
commit
9bf6593e96
@ -3205,7 +3205,7 @@ class TestTensorCreation(TestCase):
|
|||||||
self.assertTrue(t_mapped.untyped_storage().filename == expected_filename)
|
self.assertTrue(t_mapped.untyped_storage().filename == expected_filename)
|
||||||
self.assertEqual(torch.flatten(t), t_mapped)
|
self.assertEqual(torch.flatten(t), t_mapped)
|
||||||
|
|
||||||
s = torch.UntypedStorage.from_file(f.name, shared, t.numel() * dtype.itemsize)
|
s = torch.UntypedStorage.from_file(f.name, shared, nbytes=t.numel() * dtype.itemsize)
|
||||||
self.assertTrue(s.filename == expected_filename)
|
self.assertTrue(s.filename == expected_filename)
|
||||||
|
|
||||||
@onlyCPU
|
@onlyCPU
|
||||||
|
|||||||
@ -20,7 +20,7 @@ def add_docstr_all(method, docstr):
|
|||||||
add_docstr_all(
|
add_docstr_all(
|
||||||
"from_file",
|
"from_file",
|
||||||
"""
|
"""
|
||||||
from_file(filename, shared=False, size=0) -> Storage
|
from_file(filename, shared=False, nbytes=0) -> Storage
|
||||||
|
|
||||||
Creates a CPU storage backed by a memory-mapped file.
|
Creates a CPU storage backed by a memory-mapped file.
|
||||||
|
|
||||||
@ -28,15 +28,15 @@ If ``shared`` is ``True``, then memory is shared between all processes.
|
|||||||
All changes are written to the file. If ``shared`` is ``False``, then the changes on
|
All changes are written to the file. If ``shared`` is ``False``, then the changes on
|
||||||
the storage do not affect the file.
|
the storage do not affect the file.
|
||||||
|
|
||||||
``size`` is the number of elements in the storage. If ``shared`` is ``False``,
|
``nbytes`` is the number of bytes of storage. If ``shared`` is ``False``,
|
||||||
then the file must contain at least ``size * sizeof(Type)`` bytes
|
then the file must contain at least ``nbytes`` bytes. If ``shared`` is
|
||||||
(``Type`` is the type of storage, in the case of an ``UnTypedStorage`` the file must contain at
|
``True`` the file will be created if needed. (Note that for ``UntypedStorage``
|
||||||
least ``size`` bytes). If ``shared`` is ``True`` the file will be created if needed.
|
this argument differs from that of ``TypedStorage.from_file``)
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
filename (str): file name to map
|
filename (str): file name to map
|
||||||
shared (bool): whether to share memory (whether ``MAP_SHARED`` or ``MAP_PRIVATE`` is passed to the
|
shared (bool): whether to share memory (whether ``MAP_SHARED`` or ``MAP_PRIVATE`` is passed to the
|
||||||
underlying `mmap(2) call <https://man7.org/linux/man-pages/man2/mmap.2.html>`_)
|
underlying `mmap(2) call <https://man7.org/linux/man-pages/man2/mmap.2.html>`_)
|
||||||
size (int): number of elements in the storage
|
nbytes (int): number of bytes of storage
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user