[EPLB] Nixl communicator optimization. Zero-copy transfers (#41633)
Signed-off-by: ilmarkov <markovilya197@gmail.com> Signed-off-by: Markov Ilya <markovilya19@gmail.com> Signed-off-by: Tyler Michael Smith <tlrmchlsmth@gmail.com> Co-authored-by: Markov Ilya <markovilya19@gmail.com> Co-authored-by: Nicolò Lucchesi <nlucches@redhat.com> Co-authored-by: Tyler Michael Smith <tyler@neuralmagic.com> Co-authored-by: Tyler Michael Smith <tlrmchlsmth@gmail.com>
This commit is contained in:
co-authored by
Markov Ilya
Nicolò Lucchesi
Tyler Michael Smith
Tyler Michael Smith
parent
f0cd590d62
commit
4f423bd5bc
@@ -64,6 +64,20 @@ def divide(numerator, denominator):
|
||||
return numerator // denominator
|
||||
|
||||
|
||||
def is_weak_contiguous(inp: torch.Tensor) -> bool:
|
||||
"""Check that *inp* occupies a single contiguous block of memory.
|
||||
|
||||
Unlike ``torch.Tensor.is_contiguous()``, this also accepts tensors
|
||||
whose strides are not strictly C-contiguous (e.g. column-major) as
|
||||
long as the underlying storage from the tensor's offset onward is
|
||||
exactly ``numel * element_size`` bytes.
|
||||
"""
|
||||
return inp.is_contiguous() or (
|
||||
inp.storage().nbytes() - inp.storage_offset() * inp.element_size()
|
||||
== inp.numel() * inp.element_size()
|
||||
)
|
||||
|
||||
|
||||
def split_tensor_along_last_dim(
|
||||
tensor: torch.Tensor,
|
||||
num_partitions: int,
|
||||
|
||||
Reference in New Issue
Block a user