tp-nan opened a new issue, #338:
URL: https://github.com/apache/tvm-ffi/issues/338

   
   Currently, `tvm::ffi::Any` only accepts FFI-compatible types. When passing 
certain types that fall outside the FFI system, developers must handle them 
separately or manually re-implement commonly used types to be 
FFI-compatible—both of which are cumbersome.
   
   This proposal suggests improving the inclusiveness of `tvm::ffi::Any` to 
support non-FFI-compatible types as well.
   
   **Approach without altering existing APIs(For discussion purposes only):**
   
   A. Introduce an FFI-compatible ObjectRef `tvm::ffi::extra::Any`, which acts 
as a wrapper around `std::any`.
   
   B. Introduce a `make_any` function, for example:
   
   ```cpp
   template <typename T>
   tvm::ffi::Any make_any(T&& value) {
     if constexpr (
         ::tvm::ffi::TypeTraits<std::decay_t<T>>::convert_enabled ||
         std::is_same_v<std::decay_t<T>, ::tvm::ffi::Any>) {
       return ::tvm::ffi::Any(std::forward<T>(value));
     }
     else if constexpr (std::is_same_v<std::decay_t<T>, tvm::ffi::extra::Any>) {
       return ::tvm::ffi::Any(std::forward<T>(value));
     }
     else {
       tvm::ffi::extra::Any wrapper(std::forward<T>(value));
       return ::tvm::ffi::Any(std::move(wrapper));
     }
   }
   ```
   C. Add template utilities such as `type_equal` and `any_cast`.
   
   
   >  Modifications could equivalently be achieved by modifying `tvm::ffi::Any`.


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to