/usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/utils
NameSizeModeActions
auto_gil.h10340644editdlrm
byte_order.h24840644editdlrm
crash_handler.h11460644editdlrm
cuda_enabled.h1540644editdlrm
cuda_lazy_init.h9740644editdlrm
disable_torch_function.h8630644editdlrm
disallow_copy.h1030644editdlrm
init.h3240644editdlrm
invalid_arguments.h3020644editdlrm
memory.h11730644editdlrm
numpy_stub.h3990644editdlrm
object_ptr.h13290644editdlrm
out_types.h2940644editdlrm
pybind.h79660644editdlrm
pycfunction_helpers.h2090644editdlrm
python_arg_parser.h307530644editdlrm
python_compat.h29040644editdlrm
python_dispatch.h1740644editdlrm
python_numbers.h50640644editdlrm
python_scalars.h29280644editdlrm
python_strings.h45920644editdlrm
python_stub.h560644editdlrm
python_tuples.h6840644editdlrm
six.h14250644editdlrm
structseq.h1530644editdlrm
tensor_apply.h4310644editdlrm
tensor_dtypes.h2440644editdlrm
tensor_flatten.h27800644editdlrm
tensor_layouts.h1070644editdlrm
tensor_list.h1960644editdlrm
tensor_memoryformats.h1130644editdlrm
tensor_new.h18070644editdlrm
tensor_numpy.h5420644editdlrm
tensor_qschemes.h1860644editdlrm
tensor_types.h4910644editdlrm
throughput_benchmark-inl.h52100644editdlrm
throughput_benchmark.h68680644editdlrm
variadic.h43940644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/utils/variadic.h (4394B)
#pragma once #include #include #include #include #include #include #include namespace torch { using at::IterArgs; struct CountTensors : IterArgs { size_t out = 0; void operator()(const at::Tensor& x) { out += 1; } void operator()(const c10::optional& x) { out += x.has_value(); } void operator()(at::ArrayRef xs) { out += xs.size(); } }; template size_t count_tensors(Args&&... args) { return CountTensors().apply(std::forward(args)...).out; } struct CountVariables : IterArgs { size_t out = 0; void operator()(const autograd::Variable& x) { out += 1; } void operator()(at::ArrayRef xs) { out += xs.size(); } }; template inline size_t count_variables(Args&&... args) { return CountVariables().apply(std::forward(args)...).out; } //===----------------------------------------------------------------------===// // std::index_sequence shim for C++11 //===----------------------------------------------------------------------===// // A container of type-template parameter indices. template struct Indices {}; // Decrements the index N, adds N-1 to the list of indices and forwards // whatever we already have. template struct MakeIndices : MakeIndices {}; // Partial specialization that forms our base case. When N is zero, we stop // and define a typedef that will be visible to earlier classes due to // inheritance. The typedef we define is an index list containing the numbers // 0 through N-1. template struct MakeIndices<0, Is...> { using indices = Indices; }; //===----------------------------------------------------------------------===// // Utilities //===----------------------------------------------------------------------===// template using enable_if_t = typename std::enable_if::type; template using disable_if_t = enable_if_t; template using decay_t = typename std::decay::type; namespace detail { template struct pack; } // namespace detail template struct all_of : std::is_same< detail::pack, detail::pack> {}; template struct any_of; template <> struct any_of<> : std::false_type {}; template struct any_of { static constexpr bool value = head || any_of::value; }; template struct none_of { static constexpr bool value = !any_of::value; }; template using enable_if_all_of_t = enable_if_t::value>; template using disable_if_contains_t = enable_if_all_of_t<(!std::is_same>::value)...>; template void apply(Function function, Ts&&... ts) { // https://stackoverflow.com/questions/13978916/inserting-a-variadic-argument-list-into-a-vector // Creates a dummy array, so that each function call is evaluated in order. // `(function(), 0)` is because `function` should (!) return `void`, so // according to the comma operator, it is evaluated and its result (`void`) // is discarded. Then the zero is evaluated and used as an element in the // array. The first zero ensures the array is not empty. // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays) int _[]{0, (function(std::forward(ts)), 0)...}; (void)_; } template ReturnType unpack(Function function, Accessor accessor) { return ReturnType(unpack( std::move(function), std::move(accessor), typename MakeIndices::indices())); } template ReturnType unpack(Function function, Accessor accessor, Indices) { return ReturnType(function(accessor.template operator()(Is)...)); } } // namespace torch