43 #ifndef TVM_RUNTIME_REGISTRY_H_
44 #define TVM_RUNTIME_REGISTRY_H_
49 #include <type_traits>
137 operator bool() {
return python_obj_; }
142 void* python_obj_ =
nullptr;
157 template <
typename TCallable,
158 typename =
typename std::enable_if_t<
160 !std::is_base_of<PackedFunc, TCallable>::value>>
187 template <
typename FLambda>
189 using FType =
typename detail::function_signature<FLambda>::FType;
213 template <
typename T,
typename R,
typename... Args>
215 using R_ =
typename std::remove_reference<R>::type;
216 auto fwrap = [f](T target, Args... params) -> R_ {
218 return (target.*f)(params...);
244 template <
typename T,
typename R,
typename... Args>
246 auto fwrap = [f](
const T target, Args... params) -> R {
248 return (target.*f)(params...);
284 template <
typename TObjectRef,
typename TNode,
typename R,
typename... Args,
285 typename =
typename std::enable_if<std::is_base_of<ObjectRef, TObjectRef>::value>::type>
287 auto fwrap = [f](TObjectRef ref, Args... params) {
288 TNode* target = ref.operator->();
290 return (target->*f)(params...);
326 template <
typename TObjectRef,
typename TNode,
typename R,
typename... Args,
327 typename =
typename std::enable_if<std::is_base_of<ObjectRef, TObjectRef>::value>::type>
329 auto fwrap = [f](TObjectRef ref, Args... params) {
330 const TNode* target = ref.operator->();
332 return (target->*f)(params...);
374 #define TVM_FUNC_REG_VAR_DEF static TVM_ATTRIBUTE_UNUSED ::tvm::runtime::Registry& __mk_##TVM
384 #define TVM_REGISTER_GLOBAL(OpName) \
385 TVM_STR_CONCAT(TVM_FUNC_REG_VAR_DEF, __COUNTER__) = ::tvm::runtime::Registry::Register(OpName)
387 #define TVM_STRINGIZE_DETAIL(x) #x
388 #define TVM_STRINGIZE(x) TVM_STRINGIZE_DETAIL(x)
389 #define TVM_DESCRIBE(...) describe(__VA_ARGS__ "\n\nFrom:" __FILE__ ":" TVM_STRINGIZE(__LINE__))
393 #define TVM_ADD_FILELINE "\n\nDefined in " __FILE__ ":L" TVM_STRINGIZE(__LINE__)
Packed function is a type-erased function. The arguments are passed by packed format.
Definition: packed_func.h:141
Registry for global function.
Definition: registry.h:146
Registry & set_body_method(R(TNode::*f)(Args...) const)
set the body of the function to be the passed method pointer. Used when calling a method on a Node su...
Definition: registry.h:328
friend struct Manager
Definition: registry.h:371
static bool Remove(const String &name)
Erase global function from registry, if exist.
Registry & set_body(TCallable f)
set the body of the function to be f
Definition: registry.h:161
Registry & set_body_typed(FLambda f)
set the body of the function to the given function. Note that this will ignore default arg values and...
Definition: registry.h:188
static std::vector< String > ListNames()
Get the names of currently registered global function.
static Registry & Register(const String &name, bool override=false)
Register a function with given name.
PackedFunc func_
internal packed function
Definition: registry.h:370
String name_
name of the function
Definition: registry.h:364
static const PackedFunc * Get(const String &name)
Get the global function by name.
Registry & set_body_method(R(T::*f)(Args...) const)
set the body of the function to be the passed method pointer. Note that this will ignore default arg ...
Definition: registry.h:245
Registry & set_body_method(R(T::*f)(Args...))
set the body of the function to be the passed method pointer. Note that this will ignore default arg ...
Definition: registry.h:214
Registry & set_body_method(R(TNode::*f)(Args...))
set the body of the function to be the passed method pointer. Used when calling a method on a Node su...
Definition: registry.h:286
Registry & set_body(PackedFunc f)
set the body of the function to be f
Reference to string objects.
Definition: string.h:97
Arguments into TVM functions.
Definition: packed_func.h:394
Return Value container, Unlike TVMArgValue, which only holds reference and do not delete the underlyi...
Definition: packed_func.h:946
Please refer to TypedPackedFunc<R(Args..)>.
Definition: packed_func.h:63
A class that wraps a Python object and preserves its ownership.
Definition: registry.h:106
void * raw_pointer()
Definition: registry.h:139
~WrappedPythonObject()
Drop ownership of a python object.
WrappedPythonObject & operator=(const WrappedPythonObject &)
WrappedPythonObject(WrappedPythonObject &&)
WrappedPythonObject(void *python_obj)
Take ownership of a python object.
WrappedPythonObject()
Construct a wrapper that doesn't own anything.
Definition: registry.h:109
WrappedPythonObject & operator=(WrappedPythonObject &&)
WrappedPythonObject(const WrappedPythonObject &)
WrappedPythonObject & operator=(std::nullptr_t)
WrappedPythonObject(std::nullptr_t)
Conversion constructor from nullptr.
Definition: registry.h:112
void EnvCheckSignals()
Check if signals have been sent to the process and if so invoke the registered signal handler in the ...
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
Type-erased function used across TVM API.
Runtime String container types.