mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
[BE][Ez]: Optimize unnecessary lambda with operator (#154722)
Automated edits performed by FURB118. Operator is implemented in C and way faster when passed to another C method like sorted, max etc as a `key=` Pull Request resolved: https://github.com/pytorch/pytorch/pull/154722 Approved by: https://github.com/jansel
This commit is contained in:
committed by
PyTorch MergeBot
parent
0f3db20132
commit
bbda22e648
@ -1,6 +1,7 @@
|
||||
# mypy: allow-untyped-defs
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates
|
||||
import logging
|
||||
import operator
|
||||
from typing import Any, Optional
|
||||
|
||||
import torch
|
||||
@ -46,7 +47,7 @@ class _LossReducer(_CustomReducer):
|
||||
pass
|
||||
|
||||
|
||||
sum_reducer = _LossReducer(torch.tensor(0.0), lambda a, b: a + b)
|
||||
sum_reducer = _LossReducer(torch.tensor(0.0), operator.add)
|
||||
|
||||
# Default chunking dimension is 0. This is used for the case where the user did
|
||||
# not specify a chunking dimension.
|
||||
|
Reference in New Issue
Block a user