tqchen commented on PR #18111:
URL: https://github.com/apache/tvm/pull/18111#issuecomment-3032399058

   New example
   
   ```c++
   TVM_FFI_STATIC_INIT_BLOCK({
     namespace refl = tvm::ffi::reflection;
     refl::GlobalDef()
       .def_packed("ffi.Array", [](ffi::PackedArgs args, Any* ret) {
         *ret = Array<Any>(args.data(), args.data() + args.size());
       })
       .def("ffi.ArrayGetItem", [](const ffi::ArrayObj* n, int64_t i) -> Any { 
return n->at(i); })
       .def("ffi.ArraySize", [](const ffi::ArrayObj* n) -> int64_t {
         return static_cast<int64_t>(n->size());
       })
       .def_packed("ffi.Map", [](ffi::PackedArgs args, Any* ret) {
         TVM_FFI_ICHECK_EQ(args.size() % 2, 0);
         Map<Any, Any> data;
         for (int i = 0; i < args.size(); i += 2) {
           data.Set(args[i], args[i + 1]);
         }
         *ret = data;
       })
       .def("ffi.MapSize", [](const ffi::MapObj* n) -> int64_t {
         return static_cast<int64_t>(n->size());
       })
       .def("ffi.MapGetItem", [](const ffi::MapObj* n, const Any& k) -> Any { 
return n->at(k); })
       .def("ffi.MapCount", [](const ffi::MapObj* n, const Any& k) -> int64_t { 
return n->count(k); })
       .def("ffi.MapForwardIterFunctor", [](const ffi::MapObj* n) -> 
ffi::Function {
         return ffi::Function::FromTyped(MapForwardIterFunctor(n->begin(), 
n->end()));
       });
   });
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to