:github_url: https://github.com/pytorch/pytorch .. _program_listing_file_torch_csrc_stable_macros.h: Program Listing for File macros.h ================================= |exhale_lsh| :ref:`Return to documentation for file ` (``torch/csrc/stable/macros.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #include #include #include #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // Users of this macro are expected to include cuda_runtime.h #define STD_CUDA_CHECK(EXPR) \ do { \ const cudaError_t __err = EXPR; \ char* __error_msg = nullptr; \ torch_c10_cuda_check_msg( \ static_cast(__err), \ __FILE__, \ __func__, \ static_cast(__LINE__), \ true, \ &__error_msg); \ if (__error_msg != nullptr) { \ std::string __msg(__error_msg); \ torch_c10_cuda_free_error_msg(__error_msg); \ throw std::runtime_error(__msg); \ } \ } while (0) // Users of this macro are expected to include cuda_runtime.h #define STD_CUDA_KERNEL_LAUNCH_CHECK() STD_CUDA_CHECK(cudaGetLastError()) #endif