tvm
tvm copied to clipboard
[Cleanup] Accept Variant<...> instead of ObjectRef when possible
Prior to the implementation of Variant<...> in https://github.com/apache/tvm/pull/15672, functions that were polymorphic over an argument type would typically accept an ObjectRef argument, then downcast to an allowed type. This delays the catching of an error, and can accidentally omit automatic conversions applied by the FFI.
This commit updates several locations using this pattern to instead accept a Variant, templated over the allowed types. This enables C++ type checking for C++ callers, standardizes the type-checking in the FFI for non-C++ callers, and ensures that FFI type conversions are uniformly applied.
This change is split out from https://github.com/apache/tvm/pull/16183 as an independent change for ease of review.
Closed, as this was a subset of #16183, which has merged.