8
8
#include < torch/csrc/autograd/variable.h>
9
9
#include < vector>
10
10
11
- namespace torch {
12
- namespace autograd {
11
+ namespace torch ::autograd {
13
12
14
13
using optional_variable_list = std::vector<c10::optional<Variable>>;
15
14
using _jvp_fn_t = std::function<variable_list(variable_list, variable_list)>;
@@ -97,7 +96,7 @@ struct TORCH_API Function {
97
96
// the parameter X.
98
97
template <typename X = T, typename ... Args>
99
98
static auto apply (Args&&... args)
100
- -> std::enable_if_t<std::is_same <X, T>::value , forward_t<X, Args...>>;
99
+ -> std::enable_if_t<std::is_same_v <X, T>, forward_t<X, Args...>>;
101
100
};
102
101
103
102
// / Context to save information during `forward` that can be accessed in
@@ -228,8 +227,8 @@ inline void extract_vars(
228
227
}
229
228
230
229
template <typename T>
231
- typename std::enable_if <std::is_same <T, variable_list>::value , T>::type
232
- to_output_type ( std::vector<c10::optional<Variable>>& output_list) {
230
+ std::enable_if_t <std::is_same_v <T, variable_list>, T> to_output_type (
231
+ std::vector<c10::optional<Variable>>& output_list) {
233
232
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
234
233
variable_list result;
235
234
std::transform (
@@ -241,8 +240,8 @@ to_output_type(std::vector<c10::optional<Variable>>& output_list) {
241
240
}
242
241
243
242
template <typename T>
244
- typename std::enable_if <std::is_same <T, Variable>::value , T>::type
245
- to_output_type ( std::vector<c10::optional<Variable>>& output_list) {
243
+ std::enable_if_t <std::is_same_v <T, Variable>, T> to_output_type (
244
+ std::vector<c10::optional<Variable>>& output_list) {
246
245
return *output_list[0 ];
247
246
}
248
247
@@ -264,7 +263,7 @@ inline std::vector<c10::optional<Variable>> to_optional(variable_list& output) {
264
263
template <class T >
265
264
template <typename X, typename ... Args>
266
265
auto Function<T>::apply(Args&&... args)
267
- -> std::enable_if_t <std::is_same <X, T>::value , forward_t <X, Args...>> {
266
+ -> std::enable_if_t <std::is_same_v <X, T>, forward_t <X, Args...>> {
268
267
const auto & functorch_tls = at::functorch::functorchTLSAccessor ();
269
268
if (functorch_tls) {
270
269
// Function support for functorch is handled in Python.
@@ -434,5 +433,4 @@ void CppNode<T>::set_ctx_grad_fn(const std::shared_ptr<Node>& node) {
434
433
ctx_.grad_fn_ = node;
435
434
}
436
435
437
- } // namespace autograd
438
- } // namespace torch
436
+ } // namespace torch::autograd
0 commit comments