Files
pytorch/torch/_numpy/_unary_ufuncs_impl.py
Xuehai Pan e7eeee473c [BE][Easy][14/19] enforce style for empty lines in import segments in torch/_[a-c]*/ and torch/_[e-h]*/ and torch/_[j-z]*/ (#129765)
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501. Most changes are auto-generated by linter.

You can review these PRs via:

```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129765
Approved by: https://github.com/ezyang
2024-07-31 10:42:50 +00:00

73 lines
1.1 KiB
Python

# mypy: ignore-errors
"""Export torch work functions for unary ufuncs, rename/tweak to match numpy.
This listing is further exported to public symbols in the `_numpy/_ufuncs.py` module.
"""
import torch
from torch import ( # noqa: F401
absolute as fabs,
arccos,
arccosh,
arcsin,
arcsinh,
arctan,
arctanh,
bitwise_not,
bitwise_not as invert,
ceil,
conj_physical as conjugate,
cos,
cosh,
deg2rad,
deg2rad as radians,
exp,
exp2,
expm1,
floor,
isfinite,
isinf,
isnan,
log,
log10,
log1p,
log2,
logical_not,
negative,
rad2deg,
rad2deg as degrees,
reciprocal,
round as fix,
round as rint,
sign,
signbit,
sin,
sinh,
sqrt,
square,
tan,
tanh,
trunc,
)
# special cases: torch does not export these names
def cbrt(x):
return torch.pow(x, 1 / 3)
def positive(x):
return +x
def absolute(x):
# work around torch.absolute not impl for bools
if x.dtype == torch.bool:
return x
return torch.absolute(x)
# TODO set __name__ and __qualname__
abs = absolute
conj = conjugate