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 66 of file common.h.

#define ORT_CATCH (   x)    catch (x)

Definition at line 154 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 245 of file common.h.

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

Definition at line 209 of file common.h.

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

Definition at line 207 of file common.h.

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

Definition at line 211 of file common.h.

#define ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE (   TypeName)
Value:
#define ORT_DISALLOW_COPY_AND_ASSIGNMENT(TypeName)
Definition: common.h:211
#define ORT_DISALLOW_MOVE(TypeName)
Definition: common.h:215

Definition at line 219 of file common.h.

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

Definition at line 215 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:95
if(num_boxed_items<=0)
Definition: UT_RTreeImpl.h:697

Definition at line 172 of file common.h.

#define ORT_HANDLE_EXCEPTION (   func)    func()

Definition at line 157 of file common.h.

#define ORT_HAVE_ATTRIBUTE (   x)    0

Definition at line 54 of file common.h.

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

Definition at line 78 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 185 of file common.h.

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

Definition at line 166 of file common.h.

#define ORT_RETHROW   throw;

Definition at line 155 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:93
if(num_boxed_items<=0)
Definition: UT_RTreeImpl.h:697

Definition at line 191 of file common.h.

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

Definition at line 233 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 223 of file common.h.

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

Definition at line 232 of file common.h.

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

Definition at line 201 of file common.h.

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

Definition at line 162 of file common.h.

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

Definition at line 180 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:162
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 235 of file common.h.

#define ORT_TRY   try

Definition at line 153 of file common.h.

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

Definition at line 47 of file common.h.

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

Definition at line 93 of file common.h.

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

Definition at line 95 of file common.h.