XPUException.h 728 B

12345678910111213141516171819202122232425262728
  1. #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
  2. #pragma once
  3. #include <c10/util/Exception.h>
  4. #include <sycl/sycl.hpp>
  5. namespace c10::xpu {
  6. static inline sycl::async_handler asyncHandler =
  7. [](const sycl::exception_list& el) {
  8. if (el.size() == 0) {
  9. return;
  10. }
  11. for (const auto& e : el) {
  12. try {
  13. std::rethrow_exception(e);
  14. } catch (sycl::exception& e) {
  15. TORCH_WARN("SYCL Exception: ", e.what());
  16. }
  17. }
  18. throw;
  19. };
  20. } // namespace c10::xpu
  21. #else
  22. #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
  23. #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)