Dynamic dispatch functor based on TracedObject.
More...
#include <traced_object_functor.h>
|
template<class TObjectRef > |
R | operator() (const String &token, TracedObject< TObjectRef > traced_object, Args... args) const |
| Call the dispatch function. More...
|
|
TSelf & | set_dispatch (String token, uint32_t type_index, runtime::PackedFunc f) |
| Set the dispatch function. More...
|
|
template<typename TObjectRef , typename TCallable , typename = std::enable_if_t<IsDispatchFunction<TObjectRef, TCallable>::value>> |
TSelf & | set_dispatch (String token, TCallable f) |
| Set the dispatch function. More...
|
|
template<typename TObjectRef , typename TCallable , typename = std::enable_if_t<IsDispatchFunction<TObjectRef, TCallable>::value>> |
TSelf & | set_dispatch (TCallable &&f) |
| Set the default dispatch function. More...
|
|
void | remove_dispatch (String token, uint32_t type_index) |
| Remove dispatch function. More...
|
|
template<typename R, typename... Args>
class tvm::script::printer::TracedObjectFunctor< R, Args >
Dynamic dispatch functor based on TracedObject.
This functor dispatches based on the type of object ref inside the input TracedObject, and the input dispatch token.
◆ operator()()
template<typename R , typename... Args>
template<class TObjectRef >
Call the dispatch function.
- Parameters
-
token | The dispatch token. |
traced_object | The traced object. |
args | Other args. |
- Returns
- The return value of the dispatch function
If the TObjectRef isn't registered with the token, it will try to find dispatch function for TObjectRef with kDefaultDispatchToken.
◆ remove_dispatch()
template<typename R , typename... Args>
Remove dispatch function.
- Parameters
-
token | The dispatch token. |
type_index | The TVM object type index for the dispatch function to be removed. |
This is useful when dispatch function comes from other language's runtime, and those function should be removed before that language runtime shuts down.
◆ set_dispatch() [1/3]
template<typename R , typename... Args>
Set the dispatch function.
- Parameters
-
token | The dispatch token. |
type_index | The TVM object type index for this dispatch function. |
f | The dispatch function. |
This takes a type-erased packed function as input. It should be used through FFI boundary, for example, registering dispatch function from Python.
◆ set_dispatch() [2/3]
template<typename R , typename... Args>
template<typename TObjectRef , typename TCallable , typename = std::enable_if_t<IsDispatchFunction<TObjectRef, TCallable>::value>>
Set the dispatch function.
- Parameters
-
token | The dispatch token. |
f | The dispatch function. |
The diaptch function should have signature R(TracedObject<TObjectRef>, Args...)
.
◆ set_dispatch() [3/3]
template<typename R , typename... Args>
template<typename TObjectRef , typename TCallable , typename = std::enable_if_t<IsDispatchFunction<TObjectRef, TCallable>::value>>
Set the default dispatch function.
- Parameters
-
Default dispatch function will be used if there is no function registered with the requested dispatch token.
Default dispatch function has an empty string as dispatch token.
The documentation for this class was generated from the following file: