[BE] Nested namespace in ATen/native headers (#103753)

Use nested namespace and `enum class` in `ATen/native` headers.
In particular, it helps avoid polluting global namespace with `MAX`,`MIN` enum values.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/103753
Approved by: https://github.com/atalman, https://github.com/Skylion007
This commit is contained in:
Nikita Shulga
2023-06-16 19:51:43 +00:00
committed by PyTorch MergeBot
parent fd4beb7a05
commit f1b367c418
74 changed files with 226 additions and 291 deletions

View File

@ -15,24 +15,24 @@ using namespace vec;
#define AT_DISPATCH_REDUCTION_TYPES(op, ...) \
[&] { \
switch (op) { \
case SUM: { \
static constexpr ReductionType reduce = SUM; \
case ReductionType::SUM: { \
static constexpr auto reduce = ReductionType::SUM; \
return __VA_ARGS__(); \
} \
case MEAN: { \
static constexpr ReductionType reduce = MEAN; \
case ReductionType::MEAN: { \
static constexpr auto reduce = ReductionType::MEAN; \
return __VA_ARGS__(); \
} \
case MIN: { \
static constexpr ReductionType reduce = MIN; \
case ReductionType::MIN: { \
static constexpr auto reduce = ReductionType::MIN; \
return __VA_ARGS__(); \
} \
case MAX: { \
static constexpr ReductionType reduce = MAX; \
case ReductionType::MAX: { \
static constexpr auto reduce = ReductionType::MAX; \
return __VA_ARGS__(); \
} \
case PROD: { \
static constexpr ReductionType reduce = PROD; \
case ReductionType::PROD: { \
static constexpr auto reduce = ReductionType::PROD; \
return __VA_ARGS__(); \
} \
} \