tvm
Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
tvm::runtime::SessionObj Class Referenceabstract

A Disco interactive session. It allows users to interact with the Disco command queue with various PackedFunc calling convention. More...

#include <session.h>

Inheritance diagram for tvm::runtime::SessionObj:
Collaboration diagram for tvm::runtime::SessionObj:

Public Member Functions

virtual ~SessionObj ()=default
 
template<typename... Args>
DRef TVM_ALWAYS_INLINE CallPacked (const DRef &func, Args &&... args)
 Call a PackedFunc on workers providing variadic arguments. More...
 
virtual DRef CallWithPacked (const TVMArgs &args)=0
 Call packed function on each worker using a packed sequence. The calling convention: The first element must be DiscoAction::kCallPacked, The second element must be 0, which will later be updated by the session to return reg_id The thirtd element is the function to be called. More...
 
virtual DRef GetGlobalFunc (const std::string &name)=0
 Get a global functions on workers. More...
 
virtual void CopyFromWorker0 (const NDArray &host_array, const DRef &remote_array)=0
 Copy an NDArray from worker-0 to the controler-side NDArray. More...
 
virtual void CopyToWorker0 (const NDArray &host_array, const DRef &remote_array)=0
 Copy the controler-side NDArray to worker-0. More...
 
virtual void SyncWorker (int worker_id)=0
 Synchrnoize the controler with a worker, and it will wait until worker finishes executing this instruction. More...
 
virtual void Shutdown ()=0
 Signal all the workers to shutdown. More...
 
virtual void InitCCL (String ccl, IntTuple device_ids)=0
 Initialize the data plane between workers. More...
 
virtual TVMRetValue DebugGetFromRemote (int64_t reg_id, int worker_id)=0
 Get the value of a register from a remote worker. More...
 
virtual void DebugSetRegister (int64_t reg_id, TVMArgValue value, int worker_id)=0
 Set the value of a register on a remote worker. More...
 
 TVM_DECLARE_BASE_OBJECT_INFO (SessionObj, Object)
 
template<typename... Args>
DRef CallPacked (const DRef &func, Args &&... args)
 
- Public Member Functions inherited from tvm::runtime::Object
uint32_t type_index () const
 
std::string GetTypeKey () const
 
size_t GetTypeKeyHash () const
 
template<typename TargetType >
bool IsInstance () const
 
bool unique () const
 
 Object ()
 
 Object (const Object &other)
 
 Object (Object &&other)
 
Objectoperator= (const Object &other)
 
Objectoperator= (Object &&other)
 

Static Public Attributes

static constexpr const char * _type_key = "runtime.disco.Session"
 
- Static Public Attributes inherited from tvm::runtime::Object
static constexpr const char * _type_key = "runtime.Object"
 
static constexpr bool _type_final = false
 
static constexpr uint32_t _type_child_slots = 0
 
static constexpr bool _type_child_slots_can_overflow = true
 
static constexpr bool _type_has_method_visit_attrs = true
 
static constexpr bool _type_has_method_sequal_reduce = false
 
static constexpr bool _type_has_method_shash_reduce = false
 
static constexpr uint32_t _type_index = TypeIndex::kDynamic
 

Protected Member Functions

virtual void DeallocReg (int reg_id)=0
 Deallocate a register id, kill it on all workers, and append it to free_regs_. More...
 
- Protected Member Functions inherited from tvm::runtime::Object
void IncRef ()
 developer function, increases reference counter. More...
 
void DecRef ()
 developer function, decrease reference counter. More...
 

Friends

struct SessionObj::FFI
 
class DRefObj
 

Additional Inherited Members

- Public Types inherited from tvm::runtime::Object
typedef void(* FDeleter) (Object *self)
 Object deleter. More...
 
using RefCounterType = std::atomic< int32_t >
 
- Static Public Member Functions inherited from tvm::runtime::Object
static std::string TypeIndex2Key (uint32_t tindex)
 Get the type key of the corresponding index from runtime. More...
 
static size_t TypeIndex2KeyHash (uint32_t tindex)
 Get the type key hash of the corresponding index from runtime. More...
 
static uint32_t TypeKey2Index (const std::string &key)
 Get the type index of the corresponding key from runtime. More...
 
static uint32_t _GetOrAllocRuntimeTypeIndex ()
 
static uint32_t RuntimeTypeIndex ()
 
- Static Protected Member Functions inherited from tvm::runtime::Object
static uint32_t GetOrAllocRuntimeTypeIndex (const std::string &key, uint32_t static_tindex, uint32_t parent_tindex, uint32_t type_child_slots, bool type_child_slots_can_overflow)
 Get the type index using type key. More...
 
- Protected Attributes inherited from tvm::runtime::Object
uint32_t type_index_ {0}
 Type index(tag) that indicates the type of the object. More...
 
RefCounterType ref_counter_ {0}
 The internal reference counter. More...
 
FDeleter deleter_ = nullptr
 deleter of this object to enable customized allocation. If the deleter is nullptr, no deletion will be performed. The creator of the object must always set the deleter field properly. More...
 

Detailed Description

A Disco interactive session. It allows users to interact with the Disco command queue with various PackedFunc calling convention.

Constructor & Destructor Documentation

◆ ~SessionObj()

virtual tvm::runtime::SessionObj::~SessionObj ( )
virtualdefault

Member Function Documentation

◆ CallPacked() [1/2]

template<typename... Args>
DRef TVM_ALWAYS_INLINE tvm::runtime::SessionObj::CallPacked ( const DRef func,
Args &&...  args 
)

Call a PackedFunc on workers providing variadic arguments.

Template Parameters
ArgsIn the variadic arguments, the supported types include:
Parameters
funcThe function to be called.
argsThe variadic arguments.
Returns
The return value of function call

◆ CallPacked() [2/2]

template<typename... Args>
DRef tvm::runtime::SessionObj::CallPacked ( const DRef func,
Args &&...  args 
)

◆ CallWithPacked()

virtual DRef tvm::runtime::SessionObj::CallWithPacked ( const TVMArgs args)
pure virtual

Call packed function on each worker using a packed sequence. The calling convention: The first element must be DiscoAction::kCallPacked, The second element must be 0, which will later be updated by the session to return reg_id The thirtd element is the function to be called.

◆ CopyFromWorker0()

virtual void tvm::runtime::SessionObj::CopyFromWorker0 ( const NDArray host_array,
const DRef remote_array 
)
pure virtual

Copy an NDArray from worker-0 to the controler-side NDArray.

Parameters
host_arrayThe array to be copied to worker-0
remote_arrayThe NDArray on worker-0

◆ CopyToWorker0()

virtual void tvm::runtime::SessionObj::CopyToWorker0 ( const NDArray host_array,
const DRef remote_array 
)
pure virtual

Copy the controler-side NDArray to worker-0.

Parameters
host_arrayThe array to be copied to worker-0
remote_arrayThe NDArray on worker-0

◆ DeallocReg()

virtual void tvm::runtime::SessionObj::DeallocReg ( int  reg_id)
protectedpure virtual

Deallocate a register id, kill it on all workers, and append it to free_regs_.

◆ DebugGetFromRemote()

virtual TVMRetValue tvm::runtime::SessionObj::DebugGetFromRemote ( int64_t  reg_id,
int  worker_id 
)
pure virtual

Get the value of a register from a remote worker.

Parameters
reg_idThe id of the register to be fetched.
worker_idThe id of the worker to be fetched from.
Returns
The value of the register.

◆ DebugSetRegister()

virtual void tvm::runtime::SessionObj::DebugSetRegister ( int64_t  reg_id,
TVMArgValue  value,
int  worker_id 
)
pure virtual

Set the value of a register on a remote worker.

Parameters
reg_idThe id of the register to be set.
valueThe value to be set.
worker_idThe id of the worker to be set.

◆ GetGlobalFunc()

virtual DRef tvm::runtime::SessionObj::GetGlobalFunc ( const std::string &  name)
pure virtual

Get a global functions on workers.

◆ InitCCL()

virtual void tvm::runtime::SessionObj::InitCCL ( String  ccl,
IntTuple  device_ids 
)
pure virtual

Initialize the data plane between workers.

Parameters
cclThe name of the communication backend, e.g., nccl, rccl, mpi.
device_idsThe device ids of the workers.

◆ Shutdown()

virtual void tvm::runtime::SessionObj::Shutdown ( )
pure virtual

Signal all the workers to shutdown.

◆ SyncWorker()

virtual void tvm::runtime::SessionObj::SyncWorker ( int  worker_id)
pure virtual

Synchrnoize the controler with a worker, and it will wait until worker finishes executing this instruction.

Parameters
worker_idThe id of the worker to be synced with.
Note
This function is usually used for worker-0, because it is the only worker that is assumed to collocate with the controler. Syncing with other workers may not be supported.

◆ TVM_DECLARE_BASE_OBJECT_INFO()

tvm::runtime::SessionObj::TVM_DECLARE_BASE_OBJECT_INFO ( SessionObj  ,
Object   
)

Friends And Related Function Documentation

◆ DRefObj

friend class DRefObj
friend

◆ SessionObj::FFI

friend struct SessionObj::FFI
friend

Member Data Documentation

◆ _type_key

constexpr const char* tvm::runtime::SessionObj::_type_key = "runtime.disco.Session"
staticconstexpr

The documentation for this class was generated from the following file: