tvm icon indicating copy to clipboard operation
tvm copied to clipboard

[Cleanup] Accept Variant<...> instead of ObjectRef when possible

Open Lunderberg opened this issue 1 year ago • 1 comments

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.

Lunderberg avatar Jun 14 '24 20:06 Lunderberg

This change is split out from https://github.com/apache/tvm/pull/16183 as an independent change for ease of review.

Lunderberg avatar Jun 14 '24 20:06 Lunderberg

Closed, as this was a subset of #16183, which has merged.

Lunderberg avatar Aug 14 '24 18:08 Lunderberg