/usr/local/lib64/python3.6/site-packages/torch/include/c10/util
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/c10/util/MathConstants.h (858B)
#pragma once
#include
#include
#include
namespace c10 {
// TODO: Replace me with inline constexpr variable when C++17 becomes available
namespace detail {
template
C10_HOST_DEVICE inline constexpr T pi() {
return static_cast(3.14159265358979323846L);
}
template <>
C10_HOST_DEVICE inline constexpr BFloat16 pi() {
// According to
// https://en.wikipedia.org/wiki/Bfloat16_floating-point_format#Special_values
// pi is encoded as 4049
return BFloat16(0x4049, BFloat16::from_bits());
}
template <>
C10_HOST_DEVICE inline constexpr Half pi() {
return Half(0x4248, Half::from_bits());
}
} // namespace detail
// TODO: Replace me with std::numbers::pi when C++20 is there
template
constexpr T pi = c10::detail::pi();
} // namespace c10