xref: /aosp_15_r20/external/pytorch/torch/csrc/profiler/unwind/unwind_error.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #pragma once
2 #include <fmt/format.h>
3 #include <optional>
4 #include <stdexcept>
5 
6 namespace torch::unwind {
7 
8 struct UnwindError : public std::runtime_error {
9   using std::runtime_error::runtime_error;
10 };
11 
12 #define UNWIND_CHECK(cond, fmtstring, ...)                          \
13   do {                                                              \
14     if (!(cond)) {                                                  \
15       throw unwind::UnwindError(fmt::format(                        \
16           "{}:{}: " fmtstring, __FILE__, __LINE__, ##__VA_ARGS__)); \
17     }                                                               \
18   } while (0)
19 
20 // #define LOG_INFO(...) fmt::print(__VA_ARGS__)
21 #define LOG_INFO(...)
22 
23 // #define PRINT_INST(...) LOG_INFO(__VA_ARGS__)
24 #define PRINT_INST(...)
25 
26 // #define PRINT_LINE_TABLE(...) LOG_INFO(__VA_ARGS__)
27 #define PRINT_LINE_TABLE(...)
28 
29 } // namespace torch::unwind
30