mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE] f-stringify torch/ and scripts (#105538)
This PR is a follow up on the pyupgrade series to convert more strings to use f-strings using `flynt`. - https://docs.python.org/3/reference/lexical_analysis.html#f-strings - https://pypi.org/project/flynt/ Command used: ``` flynt torch/ -ll 120 flynt scripts/ -ll 120 flynt tools/ -ll 120 ``` and excluded `collect_env.py` Pull Request resolved: https://github.com/pytorch/pytorch/pull/105538 Approved by: https://github.com/ezyang, https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
4c73016ff2
commit
4cc1745b13
@ -37,8 +37,7 @@ def broadcast(a: List[int], b: List[int]):
|
||||
if sizeA != sizeB and sizeA != 1 and sizeB != 1:
|
||||
# TODO: only assertion error is bound in C++ compilation right now
|
||||
raise AssertionError(
|
||||
"The size of tensor a {} must match the size of tensor b ("
|
||||
"{}) at non-singleton dimension {}".format(sizeA, sizeB, i)
|
||||
f"The size of tensor a {sizeA} must match the size of tensor b ({sizeB}) at non-singleton dimension {i}"
|
||||
)
|
||||
|
||||
expandedSizes.append(sizeB if sizeA == 1 else sizeA)
|
||||
@ -81,8 +80,7 @@ def broadcast_inplace(a: List[int], b: List[int]):
|
||||
dimsB = len(b)
|
||||
if dimsB > dimsA:
|
||||
raise AssertionError(
|
||||
"The dims of tensor b ({}) must be less than or equal to"
|
||||
"the dims of tensor a ({}) ".format(dimsB, dimsA)
|
||||
f"The dims of tensor b ({dimsB}) must be less than or equal tothe dims of tensor a ({dimsA}) "
|
||||
)
|
||||
for dimA in range(dimsA):
|
||||
dimB = dimsB - dimsA + dimA
|
||||
|
Reference in New Issue
Block a user