11 #include "ngraph/except.hpp"
15 static inline std::ostream& write_all_to_stream(std::ostream& str) {
return str; }
16 template <
typename T,
typename... TS>
17 static inline std::ostream& write_all_to_stream(std::ostream& str,
const T& arg, TS&&... args)
19 return write_all_to_stream(str << arg, args...);
26 const char* check_string;
34 const std::string& context_info,
35 const std::string& explanation)
36 :
ngraph_error(make_what(check_loc_info, context_info, explanation))
41 static std::string make_what(
const CheckLocInfo& check_loc_info,
42 const std::string& context_info,
43 const std::string& explanation);
112 #define NGRAPH_CHECK_HELPER2(exc_class, ctx, check, ...) \
117 ::std::stringstream ss___; \
118 ::ngraph::write_all_to_stream(ss___, __VA_ARGS__); \
120 (::ngraph::CheckLocInfo{__FILE__, __LINE__, #check}), (ctx), ss___.str()); \
124 #define NGRAPH_CHECK_HELPER1(exc_class, ctx, check) \
129 throw exc_class((::ngraph::CheckLocInfo{__FILE__, __LINE__, #check}), (ctx), ""); \
139 #define NGRAPH_CHECK(...) NGRAPH_CHECK_HELPER(::ngraph::CheckFailure, "", __VA_ARGS__)
145 #define NGRAPH_UNREACHABLE(...) NGRAPH_CHECK(false, "Unreachable: ", __VA_ARGS__)
146 #define NGRAPH_CHECK_HELPER(exc_class, ctx, ...) \
147 CALL_OVERLOAD(NGRAPH_CHECK_HELPER, exc_class, ctx, __VA_ARGS__)
149 #define GLUE(x, y) x y
151 #define RETURN_ARG_COUNT(_1_, \
179 #define EXPAND_ARGS(args) RETURN_ARG_COUNT args
180 #define COUNT_ARGS_MAXN(...) \
181 EXPAND_ARGS((__VA_ARGS__, \
209 #define OVERLOAD_MACRO2(name, count) name##count
210 #define OVERLOAD_MACRO1(name, count) OVERLOAD_MACRO2(name, count)
211 #define OVERLOAD_MACRO(name, count) OVERLOAD_MACRO1(name, count)
213 #define CALL_OVERLOAD(name, exc_class, ctx, ...) \
214 GLUE(OVERLOAD_MACRO(name, COUNT_ARGS_MAXN(__VA_ARGS__)), (exc_class, ctx, __VA_ARGS__))
Base class for check failure exceptions.
Definition: check.hpp:31
Base error for ngraph runtime errors.
Definition: except.hpp:16
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16