You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "tqchen (via GitHub)" <gi...@apache.org> on 2025/06/24 15:28:30 UTC

Re: [PR] [FFI] Provide Field Visit bridge so we can do gradual transition [tvm]

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

   Example
   ```c++
   struct TestAttrs : public AttrsNodeReflAdapter<TestAttrs> {
     int axis;
     String name;
     Array<PrimExpr> padding;
     TypedEnvFunc<int(int)> func;
   
     static void RegisterReflection() {
       namespace refl = tvm::ffi::reflection;
       refl::ObjectDef<TestAttrs>()
           .def_ro("axis", &TestAttrs::axis, "axis field", refl::DefaultValue(10))
           .def_ro("name", &TestAttrs::name, "name")
           .def_ro("padding", &TestAttrs::padding, "padding of input",
                   refl::DefaultValue(Array<PrimExpr>({0, 0})))
           .def_ro("func", &TestAttrs::func, "some random env function",
                   refl::DefaultValue(TypedEnvFunc<int(int)>(nullptr)));
     }
   
     static constexpr const char* _type_key = "attrs.TestAttrs";
     TVM_FFI_DECLARE_FINAL_OBJECT_INFO(TestAttrs, BaseAttrsNode);
   };
   
   TVM_FFI_STATIC_INIT_BLOCK({ 
         // can group multiple such registration
        TestAttrs::RegisterReflection();
   });
   
   // still needed for now for the shash/equal mechanism
   TVM_REGISTER_NODE_TYPE(TestAttrs);
   ```
   


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org