mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
This reverts commit eaa449fbf0.
Reverted https://github.com/pytorch/pytorch/pull/133779 on behalf of https://github.com/ZainRizvi due to This is still failing internally with the same error about 'Graph break due to unsupported builtin _functools.reduce' ([comment](https://github.com/pytorch/pytorch/pull/133778#issuecomment-2321787968))
31 lines
573 B
Python
31 lines
573 B
Python
"""
|
|
Python polyfills for builtins
|
|
"""
|
|
|
|
import builtins
|
|
from typing import Iterable
|
|
|
|
from ..decorators import substitute_in_graph
|
|
|
|
|
|
__all__ = [
|
|
"all",
|
|
"any",
|
|
]
|
|
|
|
|
|
@substitute_in_graph(builtins.all, can_constant_fold_through=True)
|
|
def all(iterable: Iterable[object], /) -> bool:
|
|
for elem in iterable:
|
|
if not elem:
|
|
return False
|
|
return True
|
|
|
|
|
|
@substitute_in_graph(builtins.any, can_constant_fold_through=True)
|
|
def any(iterable: Iterable[object], /) -> bool:
|
|
for elem in iterable:
|
|
if elem:
|
|
return True
|
|
return False
|