Skip to content

Commit

Permalink
Change ordering of attempted primitive conversions
Browse files Browse the repository at this point in the history
Preferentially check for the same type as requested, before checking
for allowed type conversions
  • Loading branch information
Lunderberg committed Nov 29, 2023
1 parent 0f90e61 commit c214b76
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/tvm/runtime/packed_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,20 +551,20 @@ 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 (auto opt = TryAsBool()) {
if (auto opt = TryAsFloat()) {
return opt.value();
} else if (auto opt = TryAsInt()) {
return opt.value();
} else if (auto opt = TryAsFloat()) {
} else if (auto opt = TryAsBool()) {
return opt.value();
} else {
LOG(FATAL) << TVM_LOG_INCORRECT_TYPE_CODE(type_code_, kDLFloat);
}
}
operator int64_t() const {
if (auto opt = TryAsBool()) {
if (auto opt = TryAsInt()) {
return opt.value();
} else if (auto opt = TryAsInt()) {
} else if (auto opt = TryAsBool()) {
return opt.value();
} else if (IsObjectRef<ObjectRef>()) {
auto obj = AsObjectRef<ObjectRef>();
Expand Down

0 comments on commit c214b76

Please sign in to comment.