struct is_arrayref<c10::ArrayRef<T>> : std::true_type {};
} // namespace detail_
-// CUDA 9.2 and below fail while trying to compile default move constructor
-// see https://github.com/pytorch/csprng/issues/84
-#if (!defined(__CUDA_ARCH__) || !defined(CUDA_VERSION) || CUDA_VERSION > 9200)
template <class T>
using OptionalBase = std::conditional_t<
detail_::is_arrayref<T>::value,
// trivial
// destructor
optional_base<std::remove_const_t<T>>>>>;
-#else
-template <class T>
-using OptionalBase = std::conditional_t<
- detail_::is_arrayref<T>::value,
- arrayref_optional_base<T>,
- std::conditional_t<
- std::is_trivially_destructible<T>::value, // if possible
- constexpr_optional_base<std::remove_const_t<T>>, // use base with
- // trivial destructor
- optional_base<std::remove_const_t<T>>>>;
-#endif
template <class T>
class optional : private OptionalBase<T> {
-// CUDA 9.2 and below fail while trying to compile default move constructor
-// see https://github.com/pytorch/csprng/issues/84
-#if (!defined(__CUDA_ARCH__) || !defined(CUDA_VERSION) || CUDA_VERSION > 9200)
template <class U> // re-declaration for nvcc on Windows.
using OptionalBase = std::conditional_t<
detail_::is_arrayref<U>::value,
// trivial
// destructor
optional_base<std::remove_const_t<U>>>>>;
-#else
- template <class U>
- using OptionalBase = std::conditional_t<
- detail_::is_arrayref<U>::value,
- arrayref_optional_base<U>,
- std::conditional_t<
- std::is_trivially_destructible<U>::value, // if possible
- constexpr_optional_base<std::remove_const_t<U>>, // use base with
- // trivial destructor
- optional_base<std::remove_const_t<U>>>>;
-#endif
static_assert(
!std::is_same<typename std::decay<T>::type, nullopt_t>::value,
constexpr optional(nullopt_t) noexcept : OptionalBase<T>(){};
optional(const optional& rhs) = default;
-
-// CUDA 9.2 and below fail while trying to compile default move constructor
-// see https://github.com/pytorch/csprng/issues/84
-#if (!defined(__CUDA_ARCH__) || !defined(CUDA_VERSION) || CUDA_VERSION > 9200)
optional(optional&& rhs) = default;
-#else
- optional(optional&& rhs) noexcept(
- std::is_nothrow_move_constructible<T>::value) {
- if (rhs.initialized()) {
- ::new (static_cast<void*>(dataptr())) T(std::move(*rhs));
- OptionalBase<T>::setInitialized(true);
- }
- }
-#endif
// see https://github.com/akrzemi1/Optional/issues/16
// and https://en.cppreference.com/w/cpp/utility/optional/optional,
using OpTuple =
std::tuple<at::Tensor (*)(const at::Tensor&), UnaryOpType, std::string>;
- // [Note: explicit tuple type for uniform initialization list]
- // Tuple type must be explicitly specified for each uniform initialization
- // list within the vector to make this code compatible with some old env
- // which we still need to support. eg. gcc 5.4 + cuda 9.2.
std::vector<OpTuple> ops{
- OpTuple{at::abs, UnaryOpType::Abs, "abs"},
- OpTuple{at::acos, UnaryOpType::Acos, "acos"},
- OpTuple{at::asin, UnaryOpType::Asin, "asin"},
- OpTuple{at::atan, UnaryOpType::Atan, "atan"},
+ {at::abs, UnaryOpType::Abs, "abs"},
+ {at::acos, UnaryOpType::Acos, "acos"},
+ {at::asin, UnaryOpType::Asin, "asin"},
+ {at::atan, UnaryOpType::Atan, "atan"},
// There does not appear to be an appropriate ATen function for atanh
- // OpTuple{at::atanh, UnaryOpType::Atanh, "atanh" },
- OpTuple{at::ceil, UnaryOpType::Ceil, "ceil"},
- OpTuple{at::cos, UnaryOpType::Cos, "cos"},
- OpTuple{at::cosh, UnaryOpType::Cosh, "cosh"},
- OpTuple{at::erf, UnaryOpType::Erf, "erf"},
- OpTuple{at::erfc, UnaryOpType::Erfc, "erfc"},
- OpTuple{at::exp, UnaryOpType::Exp, "exp"},
- OpTuple{at::expm1, UnaryOpType::Expm1, "expm1"},
- OpTuple{at::floor, UnaryOpType::Floor, "floor"},
- OpTuple{at::frac, UnaryOpType::Frac, "frac"},
- OpTuple{at::gelu, UnaryOpType::Gelu, "gelu"},
- OpTuple{at::lgamma, UnaryOpType::Lgamma, "lgamma"},
- OpTuple{at::log, UnaryOpType::Log, "log"},
- OpTuple{at::log10, UnaryOpType::Log10, "log10"},
- OpTuple{at::log1p, UnaryOpType::Log1p, "log1p"},
- OpTuple{at::log2, UnaryOpType::Log2, "log2"},
- OpTuple{at::neg, UnaryOpType::Neg, "neg"},
- OpTuple{at::reciprocal, UnaryOpType::Reciprocal, "reciprocal"},
- OpTuple{at::relu, UnaryOpType::Relu, "relu"},
- OpTuple{at::round, UnaryOpType::Round, "round"},
- OpTuple{at::rsqrt, UnaryOpType::Rsqrt, "rsqrt"},
- OpTuple{at::sigmoid, UnaryOpType::Sigmoid, "sigmoid"},
- OpTuple{at::sin, UnaryOpType::Sin, "sin"},
- OpTuple{at::sinh, UnaryOpType::Sinh, "sinh"},
- OpTuple{at::sqrt, UnaryOpType::Sqrt, "sqrt"},
- OpTuple{at::tan, UnaryOpType::Tan, "tan"},
- OpTuple{at::tanh, UnaryOpType::Tanh, "tanh"},
- OpTuple{at::trunc, UnaryOpType::Trunc, "trunc"}};
+ // {at::atanh, UnaryOpType::Atanh, "atanh" },
+ {at::ceil, UnaryOpType::Ceil, "ceil"},
+ {at::cos, UnaryOpType::Cos, "cos"},
+ {at::cosh, UnaryOpType::Cosh, "cosh"},
+ {at::erf, UnaryOpType::Erf, "erf"},
+ {at::erfc, UnaryOpType::Erfc, "erfc"},
+ {at::exp, UnaryOpType::Exp, "exp"},
+ {at::expm1, UnaryOpType::Expm1, "expm1"},
+ {at::floor, UnaryOpType::Floor, "floor"},
+ {at::frac, UnaryOpType::Frac, "frac"},
+ {at::gelu, UnaryOpType::Gelu, "gelu"},
+ {at::lgamma, UnaryOpType::Lgamma, "lgamma"},
+ {at::log, UnaryOpType::Log, "log"},
+ {at::log10, UnaryOpType::Log10, "log10"},
+ {at::log1p, UnaryOpType::Log1p, "log1p"},
+ {at::log2, UnaryOpType::Log2, "log2"},
+ {at::neg, UnaryOpType::Neg, "neg"},
+ {at::reciprocal, UnaryOpType::Reciprocal, "reciprocal"},
+ {at::relu, UnaryOpType::Relu, "relu"},
+ {at::round, UnaryOpType::Round, "round"},
+ {at::rsqrt, UnaryOpType::Rsqrt, "rsqrt"},
+ {at::sigmoid, UnaryOpType::Sigmoid, "sigmoid"},
+ {at::sin, UnaryOpType::Sin, "sin"},
+ {at::sinh, UnaryOpType::Sinh, "sinh"},
+ {at::sqrt, UnaryOpType::Sqrt, "sqrt"},
+ {at::tan, UnaryOpType::Tan, "tan"},
+ {at::tanh, UnaryOpType::Tanh, "tanh"},
+ {at::trunc, UnaryOpType::Trunc, "trunc"}};
std::for_each(ops.begin(), ops.end(), [](OpTuple& op) {
test_op(
using AtenFuncSig = at::Tensor (*)(const at::Tensor&, const at::Tensor&);
using OpTuple = std::tuple<AtenFuncSig, BinaryOpType, std::string>;
- // see [Note: explicit tuple type for uniform initialization list]
std::vector<OpTuple> logic_ops{
- OpTuple{at::eq, BinaryOpType::Eq, "eq"},
- OpTuple{at::ge, BinaryOpType::GE, "ge"},
- OpTuple{at::gt, BinaryOpType::GT, "gt"},
- OpTuple{at::le, BinaryOpType::LE, "le"},
- OpTuple{at::lt, BinaryOpType::LT, "lt"},
- OpTuple{at::ne, BinaryOpType::NE, "ne"}};
+ {at::eq, BinaryOpType::Eq, "eq"},
+ {at::ge, BinaryOpType::GE, "ge"},
+ {at::gt, BinaryOpType::GT, "gt"},
+ {at::le, BinaryOpType::LE, "le"},
+ {at::lt, BinaryOpType::LT, "lt"},
+ {at::ne, BinaryOpType::NE, "ne"}};
std::for_each(logic_ops.begin(), logic_ops.end(), [](OpTuple& op) {
test_op(
std::make_pair(ValType::TensorView, DataType::Float)));
});
- // see [Note: explicit tuple type for uniform initialization list]
std::vector<OpTuple> math_ops{
- OpTuple{at::atan2, BinaryOpType::Atan2, "atan2"},
- OpTuple{at::div, BinaryOpType::Div, "div"},
- OpTuple{at::fmod, BinaryOpType::Fmod, "fmod"},
- OpTuple{at::max, BinaryOpType::Max, "max"},
- OpTuple{at::min, BinaryOpType::Min, "min"},
- OpTuple{at::mul, BinaryOpType::Mul, "mul"},
- OpTuple{at::pow, BinaryOpType::Pow, "pow"},
+ {at::atan2, BinaryOpType::Atan2, "atan2"},
+ {at::div, BinaryOpType::Div, "div"},
+ {at::fmod, BinaryOpType::Fmod, "fmod"},
+ {at::max, BinaryOpType::Max, "max"},
+ {at::min, BinaryOpType::Min, "min"},
+ {at::mul, BinaryOpType::Mul, "mul"},
+ {at::pow, BinaryOpType::Pow, "pow"},
// NOTE: Remainder does not match the Aten impl exactly
// despite using an identical function.
- OpTuple{at::remainder, BinaryOpType::Remainder, "remainder"},
+ {at::remainder, BinaryOpType::Remainder, "remainder"},
};
std::for_each(math_ops.begin(), math_ops.end(), [](OpTuple& op) {