24 #ifndef TVM_TARGET_GENERIC_FUNC_H_
25 #define TVM_TARGET_GENERIC_FUNC_H_
32 #include <unordered_map>
38 class GenericFuncNode;
80 template <
typename... Args>
123 template <
typename... Args>
125 const int kNumArgs =
sizeof...(Args);
126 const int kArraySize = kNumArgs > 0 ? kNumArgs : 1;
128 int type_codes[kArraySize];
130 std::forward<Args>(args)...);
158 #define TVM_GENERIC_FUNC_REG_VAR_DEF static TVM_ATTRIBUTE_UNUSED ::tvm::GenericFunc& __mk_##TVM
167 #define TVM_REGISTER_GENERIC_FUNC(name) \
168 TVM_STR_CONCAT(TVM_GENERIC_FUNC_REG_VAR_DEF, __COUNTER__) = ::tvm::GenericFunc::Get(#name)
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
Represents a generic function that can be specialized on a per-target basis.
Definition: generic_func.h:139
void VisitAttrs(AttrVisitor *v)
Definition: generic_func.h:148
TVM_DECLARE_FINAL_OBJECT_INFO(GenericFuncNode, Object)
static constexpr const char * _type_key
Definition: generic_func.h:150
runtime::PackedFunc generic_func_
Definition: generic_func.h:144
std::string name_
name of the function
Definition: generic_func.h:142
std::unordered_map< std::string, runtime::PackedFunc > dispatch_dict_
Definition: generic_func.h:146
Generic function that can be specialized on a per-target basis.
Definition: generic_func.h:43
friend struct Manager
Definition: generic_func.h:117
GenericFunc & register_func(const std::vector< std::string > &tags, const runtime::PackedFunc value, bool allow_override=false)
Register a specialized function.
GenericFunc(ObjectPtr< Object > n)
Definition: generic_func.h:46
GenericFuncNode * operator->()
access the internal node container
Definition: generic_func.h:154
void CallPacked(runtime::TVMArgs args, runtime::TVMRetValue *ret) const
Invoke the relevant function for the current target context, set by set_target_context....
static GenericFunc Get(const std::string &name)
Find or register the GenericFunc instance corresponding to the give name.
static void RegisterGenericFunc(GenericFunc func, const std::string &name)
Add a GenericFunc instance to the registry.
GenericFunc & set_default(const runtime::PackedFunc value, bool allow_override=false)
Set the default function implementaiton.
PackedFunc GetPacked() const
Get the packed function specified for the current target context.
GenericFunc()
Definition: generic_func.h:45
runtime::TVMRetValue operator()(Args &&... args) const
Call generic function by directly passing in unpacked format.
Definition: generic_func.h:124
A custom smart pointer for Object.
Definition: object.h:362
Base class of all object reference.
Definition: object.h:519
Object * get_mutable() const
Definition: object.h:607
base class of all object containers.
Definition: object.h:171
Packed function is a type-erased function. The arguments are passed by packed format.
Definition: packed_func.h:141
Definition: packed_func.h:1824
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
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
PrimExpr ret(PrimExpr value, Span span=Span())
Return the value.
Type-erased function used across TVM API.
Compilation target object.
Union type of values being passed through API and function calls.
Definition: c_runtime_api.h:210
RAII wrapper function to enter and exit a context object similar to python's with syntax.