From c214b768d5cf56aecc7e6d771da2cb9b19d3da97 Mon Sep 17 00:00:00 2001 From: Eric Lunderberg Date: Wed, 29 Nov 2023 14:41:54 -0600 Subject: [PATCH] Change ordering of attempted primitive conversions Preferentially check for the same type as requested, before checking for allowed type conversions --- include/tvm/runtime/packed_func.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/tvm/runtime/packed_func.h b/include/tvm/runtime/packed_func.h index ae9b7818446d5..213dcc52e5467 100644 --- a/include/tvm/runtime/packed_func.h +++ b/include/tvm/runtime/packed_func.h @@ -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()) { auto obj = AsObjectRef();