xref: /aosp_15_r20/external/pytorch/c10/xpu/XPUException.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #pragma once
2 
3 #include <c10/util/Exception.h>
4 #include <sycl/sycl.hpp>
5 
6 namespace c10::xpu {
7 
8 static inline sycl::async_handler asyncHandler = [](sycl::exception_list el) {
9   if (el.size() == 0) {
10     return;
11   }
12   for (const auto& e : el) {
13     try {
14       std::rethrow_exception(e);
catch(sycl::exception & e)15     } catch (sycl::exception& e) {
16       TORCH_WARN("SYCL Exception: ", e.what());
17     }
18   }
19   throw;
20 };
21 
22 } // namespace c10::xpu
23