Remove unnecessary list comprehensions (#164103)

Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/164103
Approved by: https://github.com/Lucaskabela, https://github.com/mlazos
This commit is contained in:
Yuanyuan Chen
2025-09-30 03:56:54 +00:00
committed by PyTorch MergeBot
parent ca19815e3c
commit 85012fe167
16 changed files with 51 additions and 68 deletions

View File

@ -88,7 +88,7 @@ def normalize_axis_tuple(axis, ndim, argname=None, allow_duplicate=False):
except TypeError:
pass
# Going via an iterator directly is slower than via list comprehension.
axis = tuple([normalize_axis_index(ax, ndim, argname) for ax in axis])
axis = tuple(normalize_axis_index(ax, ndim, argname) for ax in axis)
if not allow_duplicate and len(set(map(int, axis))) != len(axis):
if argname:
raise ValueError(f"repeated axis in `{argname}` argument")