mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
[Reland] [11/N] Fix clang-tidy warnings in aten/src/ATen (#133758)
Reland of #133298. Remove possible changes that may increase the build time. Pull Request resolved: https://github.com/pytorch/pytorch/pull/133758 Approved by: https://github.com/Skylion007, https://github.com/ezyang
This commit is contained in:
parent
0bde3c4f2f
commit
f8cf1829b5
17 changed files with 44 additions and 49 deletions
|
|
@ -4,9 +4,9 @@
|
|||
#include <ATen/native/DispatchStub.h>
|
||||
#include <ATen/core/IListRef.h>
|
||||
|
||||
namespace at { namespace native {
|
||||
namespace at::native {
|
||||
|
||||
using cat_serial_fn = void(*)(const Tensor &, const MaterializedITensorListRef&, int64_t);
|
||||
DECLARE_DISPATCH(cat_serial_fn, cat_serial_stub);
|
||||
|
||||
}} // namespace at::native
|
||||
} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ namespace at {
|
|||
class TensorBase;
|
||||
}
|
||||
|
||||
namespace at { namespace native {
|
||||
namespace at::native {
|
||||
|
||||
using channel_shuffle_fn = void(*)(TensorBase&, const TensorBase&, int64_t);
|
||||
DECLARE_DISPATCH(channel_shuffle_fn, channel_shuffle_kernel);
|
||||
|
||||
}} // at::native
|
||||
} // at::native
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <ATen/native/TensorIterator.h>
|
||||
|
||||
namespace at {
|
||||
struct TensorIteratorBase;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include <ATen/core/DistributionsHelper.h>
|
||||
#include <ATen/native/TensorIterator.h>
|
||||
#include <ATen/native/cpu/Loops.h>
|
||||
#include <limits>
|
||||
#include <mutex>
|
||||
|
||||
#ifdef CPU_CAPABILITY_AVX2
|
||||
|
|
@ -15,10 +14,10 @@
|
|||
#include <c10/util/irange.h>
|
||||
#endif
|
||||
|
||||
namespace at {
|
||||
namespace native {
|
||||
namespace templates {
|
||||
namespace cpu {
|
||||
|
||||
|
||||
|
||||
namespace at::native::templates::cpu {
|
||||
namespace {
|
||||
|
||||
// ==================================================== Random ========================================================
|
||||
|
|
@ -40,10 +39,10 @@ void random_from_to_kernel(TensorIteratorBase& iter, uint64_t range, int64_t bas
|
|||
template<typename RNG>
|
||||
void random_full_64_bits_range_kernel(TensorIteratorBase& iter, RNG generator) {
|
||||
AT_DISPATCH_ALL_TYPES_AND(at::ScalarType::BFloat16, iter.dtype(), "random_full_64_bits_range_kernel_cpu", [&] {
|
||||
if constexpr (std::is_same<scalar_t, int64_t>::value ||
|
||||
std::is_same<scalar_t, double>::value ||
|
||||
std::is_same<scalar_t, float>::value ||
|
||||
std::is_same<scalar_t, at::BFloat16>::value) {
|
||||
if constexpr (std::is_same_v<scalar_t, int64_t> ||
|
||||
std::is_same_v<scalar_t, double> ||
|
||||
std::is_same_v<scalar_t, float> ||
|
||||
std::is_same_v<scalar_t, at::BFloat16>) {
|
||||
std::lock_guard<std::mutex> lock(generator->mutex_);
|
||||
cpu_serial_kernel(iter, [generator]() -> scalar_t {
|
||||
uniform_int_full_range_distribution<scalar_t> random;
|
||||
|
|
@ -423,4 +422,4 @@ struct BernoulliKernel {
|
|||
}
|
||||
};
|
||||
|
||||
}}}}}
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace at {
|
|||
class TensorBase;
|
||||
}
|
||||
|
||||
namespace at { namespace native {
|
||||
namespace at::native {
|
||||
|
||||
using forward_2d_fn = void (*) (
|
||||
const TensorBase &output,
|
||||
|
|
@ -31,4 +31,4 @@ using backward_2d_fn = void (*) (
|
|||
DECLARE_DISPATCH(forward_2d_fn, grid_sampler_2d_cpu_kernel);
|
||||
DECLARE_DISPATCH(backward_2d_fn, grid_sampler_2d_backward_cpu_kernel);
|
||||
|
||||
}} // namespace at::native
|
||||
} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
#include <ATen/native/TensorIterator.h>
|
||||
#include <c10/util/irange.h>
|
||||
|
||||
namespace at {
|
||||
namespace native {
|
||||
namespace at::native {
|
||||
|
||||
namespace {
|
||||
static bool is_constant_index(int ntensor, const int64_t* strides) {
|
||||
|
|
@ -85,4 +84,4 @@ void cpu_index_kernel(TensorIteratorBase& iter, IntArrayRef index_size, IntArray
|
|||
}
|
||||
}
|
||||
} // at
|
||||
} // native
|
||||
// native
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
namespace at { namespace native { inline namespace CPU_CAPABILITY {
|
||||
namespace at::native { inline namespace CPU_CAPABILITY {
|
||||
|
||||
// n: number of function arguments (arity)
|
||||
// traits: function_traits (see FunctionTraits.h)
|
||||
|
|
@ -59,4 +59,4 @@ static inline bool is_contiguous_scalar(const int64_t* strides) {
|
|||
return IsContiguous<traits::arity, traits::arity, traits, s>::eval(strides);
|
||||
}
|
||||
|
||||
}}}
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include <c10/util/complex.h>
|
||||
#include <ATen/NumericUtils.h>
|
||||
|
||||
namespace at { namespace native {
|
||||
namespace at::native {
|
||||
inline namespace CPU_CAPABILITY {
|
||||
|
||||
// custom min and max to be used in logcumsumexp for complex arguments
|
||||
|
|
@ -58,4 +58,4 @@ c10::complex<scalar_t> _log_add_exp_helper(const c10::complex<scalar_t>& x, cons
|
|||
}
|
||||
|
||||
} // end namespace
|
||||
}} //end at::native
|
||||
} //end at::native
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ namespace at {
|
|||
class TensorBase;
|
||||
}
|
||||
|
||||
namespace at { namespace native {
|
||||
namespace at::native {
|
||||
|
||||
using pixel_shuffle_fn = void(*)(TensorBase&, const TensorBase&, int64_t);
|
||||
DECLARE_DISPATCH(pixel_shuffle_fn, pixel_shuffle_kernel);
|
||||
DECLARE_DISPATCH(pixel_shuffle_fn, pixel_unshuffle_kernel);
|
||||
|
||||
}} // at::native
|
||||
} // at::native
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
#include <ATen/core/Tensor.h>
|
||||
#include <ATen/native/DispatchStub.h>
|
||||
|
||||
namespace at { namespace native {
|
||||
namespace at::native {
|
||||
|
||||
using sampled_addmm_sparse_csr_fn = void(*)(const Tensor&, const Tensor&, const Scalar&, const Scalar&, const Tensor&);
|
||||
|
||||
DECLARE_DISPATCH(sampled_addmm_sparse_csr_fn, sampled_addmm_sparse_csr_stub);
|
||||
|
||||
}} // at::native
|
||||
} // at::native
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include <ATen/cpu/vec/vec.h>
|
||||
#include <c10/util/irange.h>
|
||||
|
||||
namespace at { namespace native { namespace detail {
|
||||
namespace at::native::detail {
|
||||
|
||||
struct InputMeta {
|
||||
void* data_ptr;
|
||||
|
|
@ -143,4 +143,4 @@ struct CanUseNativeSerialStack<TensorListType, true> {
|
|||
}
|
||||
};
|
||||
|
||||
}}} // namespace at::native::detail
|
||||
} // namespace at::native::detail
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
#include <ATen/core/Tensor.h>
|
||||
#include <ATen/native/DispatchStub.h>
|
||||
|
||||
namespace at { namespace native {
|
||||
namespace at::native {
|
||||
|
||||
using stack_serial_fn = void(*)(Tensor &, TensorList, int64_t);
|
||||
DECLARE_DISPATCH(stack_serial_fn, stack_serial_stub);
|
||||
|
||||
}} // namespace at::native
|
||||
} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace at {
|
|||
class TensorBase;
|
||||
}
|
||||
|
||||
namespace at { namespace native {
|
||||
namespace at::native {
|
||||
|
||||
using weight_norm_fn = void(*)(
|
||||
TensorBase&, TensorBase&, const TensorBase&, const TensorBase&, int64_t);
|
||||
|
|
@ -17,4 +17,4 @@ using weight_norm_backward_fn = void(*)(
|
|||
DECLARE_DISPATCH(weight_norm_fn, weight_norm_stub);
|
||||
DECLARE_DISPATCH(weight_norm_backward_fn, weight_norm_backward_stub);
|
||||
|
||||
}} // namespace at::native
|
||||
} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <ATen/core/Tensor.h>
|
||||
|
||||
namespace at { namespace native {
|
||||
namespace at::native {
|
||||
|
||||
inline ScalarType first_type() {
|
||||
return ScalarType::Undefined;
|
||||
|
|
@ -38,4 +38,4 @@ inline ScalarType param_scalar_type(const Tensor& t, bool is_mixed_type) {
|
|||
return is_mixed_type ? ScalarType::Float : t.scalar_type();
|
||||
}
|
||||
|
||||
}} // namespace at::native
|
||||
} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include <numeric>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <ATen/Parallel.h>
|
||||
#include <ATen/OpMathType.h>
|
||||
|
|
@ -13,8 +11,7 @@
|
|||
#include <c10/util/SmallVector.h>
|
||||
#include <c10/util/irange.h>
|
||||
|
||||
namespace at {
|
||||
namespace native {
|
||||
namespace at::native {
|
||||
inline namespace CPU_CAPABILITY {
|
||||
|
||||
template<typename T> using opmath_t = at::opmath_type<T>;
|
||||
|
|
@ -56,7 +53,7 @@ C10_ALWAYS_INLINE void AddMomentsVec(
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline typename std::enable_if<std::is_same<T, opmath_t<T>>::value, void>::type
|
||||
inline std::enable_if_t<std::is_same_v<T, opmath_t<T>>, void>
|
||||
UpdateMomentsVec(
|
||||
int64_t m0,
|
||||
const T* X_ptr,
|
||||
|
|
@ -79,7 +76,7 @@ UpdateMomentsVec(
|
|||
// each bfloat16/half vector will be converted to two float vectors,
|
||||
// and accumulated successively on m1_stk0/m2_stk0.
|
||||
template <typename T>
|
||||
inline typename std::enable_if<!std::is_same<T, at::opmath_type<T>>::value, void>::type
|
||||
inline std::enable_if_t<!std::is_same_v<T, at::opmath_type<T>>, void>
|
||||
UpdateMomentsVec(
|
||||
int64_t m0,
|
||||
const T* X_ptr,
|
||||
|
|
@ -202,5 +199,4 @@ std::pair<opmath_t<T>, opmath_t<T>> RowwiseMoments(const T* X, int64_t N, int64_
|
|||
}
|
||||
|
||||
} // namespace CPU_CAPABILITY
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <ATen/Parallel.h>
|
||||
#include <ATen/core/TensorAccessor.h>
|
||||
#include <ATen/cpu/vec/vec.h>
|
||||
#include <c10/util/llvmMathExtras.h>
|
||||
|
||||
|
|
@ -8,8 +9,7 @@
|
|||
#include <fbgemm/Fbgemm.h>
|
||||
#endif
|
||||
|
||||
namespace at {
|
||||
namespace native {
|
||||
namespace at::native {
|
||||
|
||||
template <typename T>
|
||||
inline void _store(T* dst, at::vec::Vectorized<T> src) {
|
||||
|
|
@ -203,5 +203,4 @@ inline void parallel_sparse_csr(
|
|||
|
||||
} // namespace utils
|
||||
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <c10/util/MathConstants.h>
|
||||
#include<ATen/NumericUtils.h>
|
||||
|
||||
namespace at { namespace native {
|
||||
namespace at::native {
|
||||
inline namespace CPU_CAPABILITY {
|
||||
|
||||
template <typename SCALAR_TYPE, typename VALUE_TYPE=SCALAR_TYPE>
|
||||
|
|
@ -247,4 +247,4 @@ inline TYPE min_impl (TYPE a, TYPE b) {
|
|||
}
|
||||
|
||||
} // end namespace
|
||||
}} //end at::native
|
||||
} //end at::native
|
||||
|
|
|
|||
Loading…
Reference in a new issue