@@ -520,18 +520,6 @@ __host__ __device__
520520#endif // C10_USE_ROCM_KERNEL_ASSERT and USE_ROCM
521521#endif // __APPLE__
522522
523- // Compile-time switch to control how assertions are logged inside CUDA kernels.
524- // If C10_CUDA_VERBOSE_ASSERT is defined, CUDA_KERNEL_ASSERT_VERBOSE will
525- // take addition information passed to the macro and forward them to
526- // CUDA_KERNEL_ASSERT_PRINTF If C10_CUDA_VERBOSE_ASSERT is not defined,
527- // CUDA_KERNEL_ASSERT_VERBOSE will behave the same as CUDA_KERNEL_ASSERT.
528- #ifdef C10_ENABLE_VERBOSE_ASSERT
529- #define CUDA_KERNEL_ASSERT_VERBOSE (cond, ...) \
530- CUDA_KERNEL_ASSERT_PRINTF (cond, __VA_ARGS__)
531- #else
532- #define CUDA_KERNEL_ASSERT_VERBOSE (cond, ...) CUDA_KERNEL_ASSERT(cond)
533- #endif
534-
535523#ifdef __APPLE__
536524#include < TargetConditionals.h>
537525#endif
@@ -631,7 +619,10 @@ __host__ __device__
631619// loading custom extensions compiled against different libtorch
632620// versions where these APIs may have changed.
633621
634- // Helper macros to handle 1-3 hidden namespace levels when not windows
622+ // Helper macros for nested namespace expansion
623+ #define _EXPAND (...) __VA_ARGS__
624+
625+ // Macros to handle 1-3 hidden namespace levels when not windows
635626#define _HIDDEN_NS_GET_MACRO (_1, _2, _3, NAME, ...) NAME
636627#define _HIDDEN_NS_1 (n1 ) namespace n1 __attribute__ ((visibility(" hidden" ))) {
637628#define _HIDDEN_NS_2 (n1, n2 ) \
@@ -641,15 +632,13 @@ __host__ __device__
641632 namespace n1 ::n2 { \
642633 namespace n3 __attribute__ ((visibility(" hidden" ))) {
643634
644- // Helper macros to close namespaces when not windows
635+ // Macros to close namespaces when not windows
645636#define _HIDDEN_NS_END_1 (n1 ) }
646637#define _HIDDEN_NS_END_N (n1, ...) \
647638 } \
648639 }
649640
650- // Helper macros to join strs with :: (for win, where symbols are hidden by
651- // default)
652- #define _EXPAND (...) __VA_ARGS__
641+ // Macros to join strs with :: (for win, where symbols are hidden by default)
653642#define _JOIN_GET_MACRO (_1, _2, _3, NAME, ...) NAME
654643#define _JOIN_NS1 (a ) a
655644#define _JOIN_NS2 (a, b ) a::b
@@ -658,8 +647,8 @@ __host__ __device__
658647#if !defined(HIDDEN_NAMESPACE_BEGIN)
659648#if defined(__GNUG__) && !defined(_WIN32)
660649#define HIDDEN_NAMESPACE_BEGIN (...) \
661- _HIDDEN_NS_GET_MACRO ( \
662- __VA_ARGS__, _HIDDEN_NS_3, _HIDDEN_NS_2, _HIDDEN_NS_1)(__VA_ARGS__)
650+ _EXPAND ( _HIDDEN_NS_GET_MACRO ( \
651+ __VA_ARGS__, _HIDDEN_NS_3, _HIDDEN_NS_2, _HIDDEN_NS_1)(__VA_ARGS__))
663652#else
664653#define HIDDEN_NAMESPACE_BEGIN (...) \
665654 namespace _EXPAND ( _JOIN_GET_MACRO ( \
@@ -670,9 +659,9 @@ __host__ __device__
670659#if !defined(HIDDEN_NAMESPACE_END)
671660#if defined(__GNUG__) && !defined(_WIN32)
672661#define HIDDEN_NAMESPACE_END (...) \
673- _HIDDEN_NS_GET_MACRO ( \
662+ _EXPAND ( _HIDDEN_NS_GET_MACRO ( \
674663 __VA_ARGS__, _HIDDEN_NS_END_N, _HIDDEN_NS_END_N, _HIDDEN_NS_END_1)( \
675- __VA_ARGS__)
664+ __VA_ARGS__))
676665#else
677666#define HIDDEN_NAMESPACE_END (...) }
678667#endif
0 commit comments