// This file is modified from LLVM, see the following copyright information // // -*- C++ -*- //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include #include namespace at::cuda { // copy-pasted from some llvm files: // - https://github.com/llvm/llvm-project/blob/main/libcxx/include/type_traits // - https://github.com/llvm/llvm-project/blob/main/clang/test/Headers/Inputs/include/type_traits const std::string traits = R"ESCAPE( namespace std { template _Tp&& __declval(int); template _Tp __declval(long); template decltype(__declval<_Tp>(0)) declval() noexcept; template struct integral_constant { static const _Tp value = __v; typedef _Tp value_type; typedef integral_constant type; }; typedef integral_constant true_type; typedef integral_constant false_type; // is_same, functional template struct is_same : public false_type {}; template struct is_same<_Tp, _Tp> : public true_type {}; // is_integral, for some types. template struct is_integral : public integral_constant {}; template <> struct is_integral : public integral_constant {}; template <> struct is_integral : public integral_constant {}; template <> struct is_integral : public integral_constant {}; template <> struct is_integral : public integral_constant {}; template <> struct is_integral : public integral_constant {}; template <> struct is_integral : public integral_constant {}; // enable_if, functional template struct enable_if{}; template struct enable_if{ using type = _Tp; }; template using enable_if_t = typename enable_if::type; template struct remove_const {typedef _Tp type;}; template struct remove_const {typedef _Tp type;}; template using remove_const_t = typename remove_const<_Tp>::type; template struct remove_volatile {typedef _Tp type;}; template struct remove_volatile {typedef _Tp type;}; template using remove_volatile_t = typename remove_volatile<_Tp>::type; template struct remove_cv {typedef typename remove_volatile::type>::type type;}; template using remove_cv_t = typename remove_cv<_Tp>::type; template struct __libcpp_is_floating_point : public false_type {}; template <> struct __libcpp_is_floating_point : public true_type {}; template <> struct __libcpp_is_floating_point : public true_type {}; template <> struct __libcpp_is_floating_point : public true_type {}; template struct is_floating_point : public __libcpp_is_floating_point::type> {}; template struct is_arithmetic : public integral_constant::value || is_floating_point<_Tp>::value> {}; template inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; template struct __numeric_type { static void __test(...); static float __test(float); static double __test(char); static double __test(int); static double __test(unsigned); static double __test(long); static double __test(unsigned long); static double __test(long long); static double __test(unsigned long long); static double __test(double); static long double __test(long double); typedef decltype(__test(declval<_Tp>())) type; static const bool value = !is_same::value; }; template <> struct __numeric_type { static const bool value = true; }; // __promote template ::value && __numeric_type<_A2>::value && __numeric_type<_A3>::value> class __promote_imp { public: static const bool value = false; }; template class __promote_imp<_A1, _A2, _A3, true> { private: typedef typename __promote_imp<_A1>::type __type1; typedef typename __promote_imp<_A2>::type __type2; typedef typename __promote_imp<_A3>::type __type3; public: typedef decltype(__type1() + __type2() + __type3()) type; static const bool value = true; }; template class __promote_imp<_A1, _A2, void, true> { private: typedef typename __promote_imp<_A1>::type __type1; typedef typename __promote_imp<_A2>::type __type2; public: typedef decltype(__type1() + __type2()) type; static const bool value = true; }; template class __promote_imp<_A1, void, void, true> { public: typedef typename __numeric_type<_A1>::type type; static const bool value = true; }; template class __promote : public __promote_imp<_A1, _A2, _A3> {}; } // namespace std )ESCAPE"; const std::string &get_traits_string() { return traits; } // This is copy-pasted from the following llvm file: // - https://github.com/llvm/llvm-project/blob/main/libcxx/include/cmath const std::string cmath = R"ESCAPE( namespace std { using ::signbit; using ::isfinite; using ::isinf; using ::isnan; using ::abs; using ::acos; using ::acosf; using ::asin; using ::asinf; using ::atan; using ::atanf; using ::atan2; using ::atan2f; using ::ceil; using ::ceilf; using ::cos; using ::cosf; using ::cosh; using ::coshf; using ::exp; using ::expf; using ::fabs; using ::fabsf; using ::floor; using ::floorf; using ::fmod; using ::fmodf; using ::frexp; using ::frexpf; using ::ldexp; using ::ldexpf; using ::log; using ::logf; using ::log10; using ::log10f; using ::modf; using ::modff; using ::pow; using ::powf; using ::sin; using ::sinf; using ::sinh; using ::sinhf; using ::sqrt; using ::sqrtf; using ::tan; using ::tanf; using ::tanh; using ::tanhf; using ::acosh; using ::acoshf; using ::asinh; using ::asinhf; using ::atanh; using ::atanhf; using ::cbrt; using ::cbrtf; using ::copysign; using ::copysignf; using ::erf; using ::erff; using ::erfc; using ::erfcf; using ::exp2; using ::exp2f; using ::expm1; using ::expm1f; using ::fdim; using ::fdimf; using ::fmaf; using ::fma; using ::fmax; using ::fmaxf; using ::fmin; using ::fminf; using ::hypot; using ::hypotf; using ::ilogb; using ::ilogbf; using ::lgamma; using ::lgammaf; using ::llrint; using ::llrintf; using ::llround; using ::llroundf; using ::log1p; using ::log1pf; using ::log2; using ::log2f; using ::logb; using ::logbf; using ::lrint; using ::lrintf; using ::lround; using ::lroundf; using ::nan; using ::nanf; using ::nearbyint; using ::nearbyintf; using ::nextafter; using ::nextafterf; using ::remainder; using ::remainderf; using ::remquo; using ::remquof; using ::rint; using ::rintf; using ::round; using ::roundf; using ::scalbln; using ::scalblnf; using ::scalbn; using ::scalbnf; using ::tgamma; using ::tgammaf; using ::trunc; using ::truncf; } // namespace std )ESCAPE"; const std::string &get_cmath_string() { return cmath; } } // namespace at::cuda