The GitHub Actions job "mainline-only" on tvm-ffi.git/main has failed.
Run started by GitHub user tqchen (triggered by tqchen).

Head commit for run:
98d0029dd4e002da1516d43f9b92e792f139e709 / Tianqi Chen 
<[email protected]>
[FEAT][FFI] Add ostream operator<< for Any/ObjectRef/Variant/Optional (#596)

## Summary

The four type-erased FFI value containers (`ffi::Any`, `ffi::ObjectRef`,
`ffi::Variant<Ts...>`, `ffi::Optional<T>`) have no `operator<<` for
`std::ostream`, requiring manual `.ToString()` / `ReprPrint()` calls.
This PR adds four inline overloads in
`include/tvm/ffi/extra/dataclass.h` that delegate to the existing
`ReprPrint(Any)` machinery, so `std::cout << x` and `LOG(INFO) << x`
just work.

- `operator<<(ostream&, const Any&)` — delegates to `ReprPrint(value)`
- `operator<<(ostream&, const ObjectRef&)` — delegates to
`ReprPrint(Any(value))`; derived types still print their type-specific
repr via runtime `type_index` dispatch
- `operator<<(ostream&, const Variant<Ts...>&)` — delegates to
`ReprPrint(Any(value))`
- `operator<<(ostream&, const Optional<T>&)` — prints `"None"` for empty
(Python convention), otherwise `ReprPrint(Any(value))`

Pre-existing `String` and `Shape` `operator<<` overloads are unaffected:
`Shape` (a derived `ObjectRef`) wins over the generic `const ObjectRef&`
overload via overload resolution; `String` is not an `ObjectRef`
subclass and has no conflict.

Report URL: https://github.com/apache/tvm-ffi/actions/runs/26515569096

With regards,
GitHub Actions via GitBox


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

Reply via email to