mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE] Enable ruff's UP rules and autoformat dynamo / functorch and refs (#105432)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/105432 Approved by: https://github.com/ezyang
This commit is contained in:
committed by
PyTorch MergeBot
parent
88f119775d
commit
8a688277a2
@ -108,18 +108,16 @@ def _create_rearrange_callable(
|
||||
|
||||
custom_rearrange_callable_name = "do_rearrange"
|
||||
custom_rearrange_callable_code = (
|
||||
(
|
||||
f"def {custom_rearrange_callable_name}(tensor):\n"
|
||||
f" {comma_separate(first_class_dims)} = dims({n_dims})\n"
|
||||
+ (
|
||||
"".join(f" {dim}.size = {length}\n" for (dim, length) in specified_lengths)
|
||||
if specified_lengths else ""
|
||||
)
|
||||
+ f" tensor = tensor[{comma_separate(left_dims)}].order({comma_separate(right_dims)})\n"
|
||||
+ (
|
||||
f" return tensor.sum({comma_separate([anon_dims])}, keepdim=False)\n"
|
||||
if anon_dims else " return tensor\n"
|
||||
)
|
||||
f"def {custom_rearrange_callable_name}(tensor):\n"
|
||||
f" {comma_separate(first_class_dims)} = dims({n_dims})\n"
|
||||
+ (
|
||||
"".join(f" {dim}.size = {length}\n" for (dim, length) in specified_lengths)
|
||||
if specified_lengths else ""
|
||||
)
|
||||
+ f" tensor = tensor[{comma_separate(left_dims)}].order({comma_separate(right_dims)})\n"
|
||||
+ (
|
||||
f" return tensor.sum({comma_separate([anon_dims])}, keepdim=False)\n"
|
||||
if anon_dims else " return tensor\n"
|
||||
)
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user