Lunderberg commented on code in PR #16183:
URL: https://github.com/apache/tvm/pull/16183#discussion_r1409841129
##########
include/tvm/runtime/packed_func.h:
##########
@@ -547,29 +551,43 @@ class TVMPODValue_ {
// Allow automatic conversion from int to float
// This avoids errors when user pass in int from
// the frontend while the API expects a float.
- if (type_code_ == kDLInt) {
- return static_cast<double>(value_.v_int64);
+ if (auto opt = TryAsBool()) {
+ return opt.value();
+ } else if (auto opt = TryAsInt()) {
Review Comment:
Good call, and reordered here and following conversions. For each
conversion operator, it now checks the expected type first, and only falls back
to allowed conversions if the expected type isn't present.
> Would any bool value also work as an int value? Maybe that's the reason
for the ordering given.
Nope, no specific reason for the ordering. These specific `Try*` functions
don't apply any conversions, so the order doesn't matter for correctness.
--
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]