Template Function tvm::ffi::reflection::init

Template Function tvm::ffi::reflection::init#

Function Documentation#

template<typename T, typename ...Args>
inline ObjectRef tvm::ffi::reflection::init(Args&&... args)#

Invokes the constructor of a particular object type and returns an ObjectRef.

Example

class ExampleObject : public Object {
 public:
   int64_t v_i64;
   int32_t v_i32;

   ExampleObject(int64_t v_i64, int32_t v_i32) : v_i64(v_i64), v_i32(v_i32) {}
   TVM_FFI_DECLARE_OBJECT_INFO("example.ExampleObject", ExampleObject, Object);
};
refl::ObjectDef<ExampleObject>()
   .def_static("__init__", refl::init<ExampleObject, int64_t, int32_t>);

Note

This is usually used in FFI reflection boundary to register __init__ methods.

Template Parameters:
  • T – The object type to be constructed.

  • Args – The argument types.

Parameters:

args – The arguments to be passed to the constructor.

Returns:

The constructed object wrapped in an ObjectRef.