Commit Graph

7 Commits

Author SHA1 Message Date
cyy
38d9b3d937 Remove use of math_compat.h (#116167)
Because  ANDROID>=21 is assumed in CI tests, it is time to remove old workarounds. math_compat.h contains solely wrapper math functions for ANDROID, so we can remove its usage.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/116167
Approved by: https://github.com/ezyang
2024-01-19 03:37:55 +00:00
44cc873fba [PyTorch] Autoformat c10 (#56830)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56830

Opt into formatting on GitHub and format everything. This is a trial run before turning on formatting for more and eventually all of the codebase.

Test Plan: CI

Reviewed By: zertosh

Differential Revision: D27979080

fbshipit-source-id: a80f0c48691c08ae8ca0af06377b87e6a2351151
2021-04-30 21:23:28 -07:00
91a809bbd7 [c10] Adjust macro check that detects if glibc++ use c99 csqrt (#55177)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55177

This fixes `warning: '_GLIBCXX11_USE_C99_COMPLEX' is not defined, evaluates to 0`, that would be raised if https://github.com/pytorch/pytorch/pull/54820 used with libstd++ compiled without USE_C99_COMPLEX support.

In `c++config.h` `_GLIBCXX_USE_C99_COMPLEX` is aliased to either `_GLIBCXX98_USE_C99_COMPLEX` or `_GLIBCXX11_USE_C99_COMPLEX` depending on  `__cplusplus` macro, as shown here:
0cf4813202/libstdc%2B%2B-v3/include/bits/c%2B%2Bconfig (L641-L647)

Abovementioned config file is generated by autoconf, that leaves macro undefined if feature is not used, so using conditional like `defined(_GLIBCXX_USE_C99_COMPLEX) && _GLIBCXX_USE_C99_COMPLEX == 0` would trigger undefined macro preprocessor warning.

Test Plan: CI

Reviewed By: Orvid

Differential Revision: D27517788

fbshipit-source-id: a6db98d21c9bd98205815641363b765a02399678
2021-04-02 13:20:30 -07:00
07602bf7e1 [caffe2] Use the CXX11 version of the USE_C99_COMPLEX macro
Summary: Because the bare CXX version forwards to this without checking if it's defined causing errors for builds with -Wundef enabled

Test Plan: contbuilds

Differential Revision: D27443462

fbshipit-source-id: 554a3c653aae14d19e35038ba000cf5330e6d679
2021-03-31 12:54:47 -07:00
68af6d9565 Use custom sqrt if stdc++ does not fall back to C99 csqrt (#54820)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/54820

template implementation of std::sqrt() in libstdc++ yields incorrect results for `std::complex(-std::abs(x), -0.0)`, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991
For example:
```
#include <iostream>
#include <complex>
int main() {
  std::cout << std::sqrt(std::complex<float>(-1.0f, -0.0f)) << std::endl;
}
```
prints `(0, -1)` if libstdc++ is compiled to use C99 csqrt/csqrtf fallback, but `(0, 1)` if configured not to use it.

Test Plan: CI

Reviewed By: luciang

Differential Revision: D27379302

fbshipit-source-id: 03f614fdb7ff734139736a2a5f6872cee0173bee
2021-03-29 09:05:48 -07:00
4305609d66 Fix complex acos edge cases (#52287)
Summary:
Use `std::acos` even when avx2 is available
Add slow but accurate implementation of complex arc cosine based on
W. Kahan "Branch Cuts for Complex Elementary Functions" paper, where
cacos(z).re = 2*atan2(sqrt(1-z).re(), sqrt(1+z).re())
cacos(z).im = asinh((sqrt(conj(1+z))*sqrt(1-z)).im())

Fixes https://github.com/pytorch/pytorch/issues/42952

Pull Request resolved: https://github.com/pytorch/pytorch/pull/52287

Reviewed By: walterddr

Differential Revision: D26455027

Pulled By: malfet

fbshipit-source-id: a81ce1ba4953eff4d3c2a265ef9199896a67b240
2021-02-17 11:36:09 -08:00
497b772547 Add custom implementation for csqrt if libc++ is used (#52018)
Summary:
libc++ implements csqrt using polar form of the number, which results in higher numerical error, if `arg` is close to 0, pi/2, pi, 3pi/4

Fixes https://github.com/pytorch/pytorch/issues/47500

Pull Request resolved: https://github.com/pytorch/pytorch/pull/52018

Reviewed By: walterddr

Differential Revision: D26359947

Pulled By: malfet

fbshipit-source-id: 8c9f4dc45948cb29c43230dcee9b030c2642d981
2021-02-11 11:53:52 -08:00