HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
common.h File Reference
#include <climits>
#include <cstring>
#include <algorithm>
#include <chrono>
#include <functional>
#include <memory>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
#include "core/common/code_location.h"
#include "core/common/exceptions.h"
#include "core/common/make_string.h"
#include "core/common/status.h"
+ Include dependency graph for common.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  onnxruntime::null_type
 

Namespaces

 onnxruntime
 

Macros

#define ORT_UNUSED_PARAMETER(x)   (void)(x)
 
#define ORT_HAVE_ATTRIBUTE(x)   0
 
#define ORT_ATTRIBUTE_UNUSED
 
#define ORT_IGNORE_RETURN_VALUE(fn)   static_cast<void>(fn)
 
#define ORT_WHERE   ::onnxruntime::CodeLocation(__FILE__, __LINE__, static_cast<const char*>(__FUNCTION__))
 
#define ORT_WHERE_WITH_STACK   ::onnxruntime::CodeLocation(__FILE__, __LINE__, static_cast<const char*>(__PRETTY_FUNCTION__), ::onnxruntime::GetStackTrace())
 
#define ORT_TRY   try
 
#define ORT_CATCH(x)   catch (x)
 
#define ORT_RETHROW   throw;
 
#define ORT_HANDLE_EXCEPTION(func)   func()
 
#define ORT_THROW(...)   throw ::onnxruntime::OnnxRuntimeException(ORT_WHERE_WITH_STACK, ::onnxruntime::MakeString(__VA_ARGS__))
 
#define ORT_NOT_IMPLEMENTED(...)   throw ::onnxruntime::NotImplementedException(::onnxruntime::MakeString(__VA_ARGS__))
 
#define ORT_ENFORCE(condition,...)
 
#define ORT_THROW_EX(ex,...)   throw ex(__VA_ARGS__)
 
#define ORT_MAKE_STATUS(category, code,...)
 
#define ORT_RETURN_IF(condition,...)
 
#define ORT_RETURN_IF_NOT(condition,...)   ORT_RETURN_IF(!(condition), __VA_ARGS__)
 
#define ORT_DISALLOW_COPY(TypeName)   TypeName(const TypeName&) = delete
 
#define ORT_DISALLOW_ASSIGNMENT(TypeName)   TypeName& operator=(const TypeName&) = delete
 
#define ORT_DISALLOW_COPY_AND_ASSIGNMENT(TypeName)
 
#define ORT_DISALLOW_MOVE(TypeName)
 
#define ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(TypeName)
 
#define ORT_RETURN_IF_ERROR_SESSIONID(expr, session_id)
 
#define ORT_RETURN_IF_ERROR_SESSIONID_(expr)   ORT_RETURN_IF_ERROR_SESSIONID(expr, session_id_)
 
#define ORT_RETURN_IF_ERROR(expr)   ORT_RETURN_IF_ERROR_SESSIONID(expr, 0)
 
#define ORT_THROW_IF_ERROR(expr)
 
#define ORT_CHECK_AND_SET_RETVAL(expr)
 

Typedefs

using onnxruntime::TimePoint = std::chrono::high_resolution_clock::time_point
 

Functions

std::vector< std::stringonnxruntime::GetStackTrace ()
 
void onnxruntime::LogRuntimeError (uint32_t session_id, const common::Status &status, const char *file, const char *function, uint32_t line)
 
long long onnxruntime::TimeDiffMicroSeconds (TimePoint start_time)
 
long long onnxruntime::TimeDiffMicroSeconds (TimePoint start_time, TimePoint end_time)
 
std::string onnxruntime::ToUTF8String (const std::string &s)
 
std::string onnxruntime::ToWideString (const std::string &s)
 
template<typename Key , typename... OtherContainerArgs, template< typename...> typename AssociativeContainer, typename LookupKey >
bool onnxruntime::Contains (const AssociativeContainer< Key, OtherContainerArgs...> &container, LookupKey &&key)
 

Variables

constexpr size_t onnxruntime::kMaxStrLen = 2048
 

Macro Definition Documentation

#define ORT_ATTRIBUTE_UNUSED

Definition at line 67 of file common.h.

#define ORT_CATCH (   x)    catch (x)

Definition at line 155 of file common.h.

#define ORT_CHECK_AND_SET_RETVAL (   expr)
Value:
do { \
if (retval.IsOK()) { \
retval = (expr); \
} \
} while (0)
if(num_boxed_items<=0)
Definition: UT_RTreeImpl.h:697

Definition at line 246 of file common.h.

#define ORT_DISALLOW_ASSIGNMENT (   TypeName)    TypeName& operator=(const TypeName&) = delete

Definition at line 210 of file common.h.

#define ORT_DISALLOW_COPY (   TypeName)    TypeName(const TypeName&) = delete

Definition at line 208 of file common.h.

#define ORT_DISALLOW_COPY_AND_ASSIGNMENT (   TypeName)
Value:
ORT_DISALLOW_COPY(TypeName); \
#define ORT_DISALLOW_ASSIGNMENT(TypeName)
Definition: common.h:210
#define ORT_DISALLOW_COPY(TypeName)
Definition: common.h:208

Definition at line 212 of file common.h.

#define ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE (   TypeName)
Value:
#define ORT_DISALLOW_COPY_AND_ASSIGNMENT(TypeName)
Definition: common.h:212
#define ORT_DISALLOW_MOVE(TypeName)
Definition: common.h:216

Definition at line 220 of file common.h.

#define ORT_DISALLOW_MOVE (   TypeName)
Value:
TypeName(TypeName&&) = delete; \
TypeName& operator=(TypeName&&) = delete

Definition at line 216 of file common.h.

#define ORT_ENFORCE (   condition,
  ... 
)
Value:
do { \
if (!(condition)) { \
throw ::onnxruntime::OnnxRuntimeException(ORT_WHERE_WITH_STACK, #condition, \
::onnxruntime::MakeString(__VA_ARGS__)); \
} \
} while (false)
std::string MakeString(const Args &...args)
Definition: make_string.h:81
#define ORT_WHERE_WITH_STACK
Definition: common.h:96
if(num_boxed_items<=0)
Definition: UT_RTreeImpl.h:697

Definition at line 173 of file common.h.

#define ORT_HANDLE_EXCEPTION (   func)    func()

Definition at line 158 of file common.h.

#define ORT_HAVE_ATTRIBUTE (   x)    0

Definition at line 55 of file common.h.

#define ORT_IGNORE_RETURN_VALUE (   fn)    static_cast<void>(fn)

Definition at line 79 of file common.h.

#define ORT_MAKE_STATUS (   category,
  code,
  ... 
)
Value:
::onnxruntime::common::Status(::onnxruntime::common::category, \
::onnxruntime::common::code, \
::onnxruntime::MakeString(__VA_ARGS__))
std::string MakeString(const Args &...args)
Definition: make_string.h:81

Definition at line 186 of file common.h.

#define ORT_NOT_IMPLEMENTED (   ...)    throw ::onnxruntime::NotImplementedException(::onnxruntime::MakeString(__VA_ARGS__))

Definition at line 167 of file common.h.

#define ORT_RETHROW   throw;

Definition at line 156 of file common.h.

#define ORT_RETURN_IF (   condition,
  ... 
)
Value:
do { \
if (condition) { \
::onnxruntime::MakeString(ORT_WHERE.ToString(), " ", __VA_ARGS__)); \
} \
} while (false)
std::string MakeString(const Args &...args)
Definition: make_string.h:81
#define ORT_WHERE
Definition: common.h:94
if(num_boxed_items<=0)
Definition: UT_RTreeImpl.h:697

Definition at line 192 of file common.h.

#define ORT_RETURN_IF_ERROR (   expr)    ORT_RETURN_IF_ERROR_SESSIONID(expr, 0)

Definition at line 234 of file common.h.

#define ORT_RETURN_IF_ERROR_SESSIONID (   expr,
  session_id 
)
Value:
do { \
auto _status = (expr); \
if ((!_status.IsOK())) { \
::onnxruntime::LogRuntimeError(session_id, _status, __FILE__, static_cast<const char*>(__FUNCTION__), __LINE__); \
return _status; \
} \
} while (0)
void LogRuntimeError(uint32_t session_id, const common::Status &status, const char *file, const char *function, uint32_t line)
if(num_boxed_items<=0)
Definition: UT_RTreeImpl.h:697

Definition at line 224 of file common.h.

#define ORT_RETURN_IF_ERROR_SESSIONID_ (   expr)    ORT_RETURN_IF_ERROR_SESSIONID(expr, session_id_)

Definition at line 233 of file common.h.

#define ORT_RETURN_IF_NOT (   condition,
  ... 
)    ORT_RETURN_IF(!(condition), __VA_ARGS__)

Definition at line 202 of file common.h.

#define ORT_THROW (   ...)    throw ::onnxruntime::OnnxRuntimeException(ORT_WHERE_WITH_STACK, ::onnxruntime::MakeString(__VA_ARGS__))

Definition at line 163 of file common.h.

#define ORT_THROW_EX (   ex,
  ... 
)    throw ex(__VA_ARGS__)

Definition at line 181 of file common.h.

#define ORT_THROW_IF_ERROR (   expr)
Value:
do { \
auto _status = (expr); \
if ((!_status.IsOK())) { \
::onnxruntime::LogRuntimeError(0, _status, __FILE__, static_cast<const char*>(__FUNCTION__), __LINE__); \
ORT_THROW(_status); \
} \
} while (0)
#define ORT_THROW(...)
Definition: common.h:163
void LogRuntimeError(uint32_t session_id, const common::Status &status, const char *file, const char *function, uint32_t line)
if(num_boxed_items<=0)
Definition: UT_RTreeImpl.h:697

Definition at line 236 of file common.h.

#define ORT_TRY   try

Definition at line 154 of file common.h.

#define ORT_UNUSED_PARAMETER (   x)    (void)(x)

Definition at line 48 of file common.h.

#define ORT_WHERE   ::onnxruntime::CodeLocation(__FILE__, __LINE__, static_cast<const char*>(__FUNCTION__))

Definition at line 94 of file common.h.

#define ORT_WHERE_WITH_STACK   ::onnxruntime::CodeLocation(__FILE__, __LINE__, static_cast<const char*>(__PRETTY_FUNCTION__), ::onnxruntime::GetStackTrace())

Definition at line 96 of file common.h.