[ez] add docblock for _eval_is_non_overlapping_and_dense (#154399)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/154399
Approved by: https://github.com/laithsakka
ghstack dependencies: #154400, #154398, #154396
This commit is contained in:
bobrenjc93 2025-05-28 15:14:14 -07:00 committed by PyTorch MergeBot
parent 0f56318152
commit 0c00e32632

View File

@ -2368,6 +2368,19 @@ def eval_is_non_overlapping_and_dense(
def _eval_is_non_overlapping_and_dense(
sizes: Sequence[int], strides: Sequence[int]
) -> bool:
"""
Evaluates whether a tensor with the given sizes and strides is non-overlapping and dense.
A tensor is non-overlapping if there's no memory location that belongs to more than one element.
A tensor is dense if all elements are stored in memory without gaps.
Args:
sizes: Sequence of dimension sizes for the tensor
strides: Sequence of strides for the tensor
Returns:
True if the tensor is non-overlapping and dense, False otherwise
"""
dim = len(sizes)
# Short-circuits for tensors of rank one, which are