diff --git a/3rdparty/tvm-ffi b/3rdparty/tvm-ffi index 3e07df45afbc..b03cc7845ae9 160000 --- a/3rdparty/tvm-ffi +++ b/3rdparty/tvm-ffi @@ -1 +1 @@ -Subproject commit 3e07df45afbc8ea968ef03c34d84dc348ba6dfb0 +Subproject commit b03cc7845ae92060881e14c4f50a4b6da4d9f982 diff --git a/apps/android_rpc/app/src/main/jni/tvm_runtime.h b/apps/android_rpc/app/src/main/jni/tvm_runtime.h index 6bda78cef0db..a522f0e9968a 100644 --- a/apps/android_rpc/app/src/main/jni/tvm_runtime.h +++ b/apps/android_rpc/app/src/main/jni/tvm_runtime.h @@ -34,6 +34,7 @@ #define TVM_LOG_CUSTOMIZE 1 #define TVM_FFI_USE_LIBBACKTRACE 0 +#include "../3rdparty/tvm-ffi/src/ffi/backtrace.cc" #include "../3rdparty/tvm-ffi/src/ffi/container.cc" #include "../3rdparty/tvm-ffi/src/ffi/dtype.cc" #include "../3rdparty/tvm-ffi/src/ffi/error.cc" @@ -45,7 +46,6 @@ #include "../3rdparty/tvm-ffi/src/ffi/function.cc" #include "../3rdparty/tvm-ffi/src/ffi/object.cc" #include "../3rdparty/tvm-ffi/src/ffi/tensor.cc" -#include "../3rdparty/tvm-ffi/src/ffi/traceback.cc" #include "../src/runtime/cpu_device_api.cc" #include "../src/runtime/device_api.cc" #include "../src/runtime/file_utils.cc" diff --git a/include/tvm/runtime/logging.h b/include/tvm/runtime/logging.h index e9482a99070a..f39a07b3d968 100644 --- a/include/tvm/runtime/logging.h +++ b/include/tvm/runtime/logging.h @@ -206,7 +206,7 @@ class InternalError : public Error { */ InternalError(std::string file, int lineno, std::string message) : Error(DetectKind(message), DetectMessage(message), - TVMFFITraceback(file.c_str(), lineno, "", 0)) {} + TVMFFIBacktrace(file.c_str(), lineno, "", 0)) {} private: // try to detect the kind of error from the message when the error type diff --git a/python/tvm/relax/transform/transform.py b/python/tvm/relax/transform/transform.py index c945732a6dfc..b3c4e7110157 100644 --- a/python/tvm/relax/transform/transform.py +++ b/python/tvm/relax/transform/transform.py @@ -219,7 +219,7 @@ def main_adjoint( # return value: (orig_return_values, tuple(adjoints)) return ((lv1, lv2), (x_adjoint, y_adjoint)) """ - if require_grads is not None and not isinstance(require_grads, list): + if require_grads is not None and not isinstance(require_grads, (list, tvm_ffi.Array)): require_grads = [require_grads] return _ffi_api.Gradient(func_name, require_grads, target_index) # type: ignore diff --git a/src/target/target.cc b/src/target/target.cc index c23b8bd7570f..23ee76fc898d 100644 --- a/src/target/target.cc +++ b/src/target/target.cc @@ -404,7 +404,7 @@ Any TargetInternal::ParseType(const std::string& str, const TargetKindNode::Valu result.push_back(parsed); } catch (const Error& e) { std::string index = "[" + std::to_string(result.size()) + "]"; - throw Error(e.kind(), e.message() + index, e.traceback()); + throw Error(e.kind(), e.message() + index, e.backtrace()); } } return ffi::Array(result); @@ -450,7 +450,7 @@ Any TargetInternal::ParseType(const Any& obj, const TargetKindNode::ValueTypeInf result.push_back(TargetInternal::ParseType(e, *info.key)); } catch (const Error& e) { std::string index = '[' + std::to_string(result.size()) + ']'; - throw Error(e.kind(), index + e.message(), e.traceback()); + throw Error(e.kind(), index + e.message(), e.backtrace()); } } return ffi::Array(result); @@ -463,14 +463,14 @@ Any TargetInternal::ParseType(const Any& obj, const TargetKindNode::ValueTypeInf try { key = TargetInternal::ParseType(kv.first, *info.key); } catch (const Error& e) { - throw Error(e.kind(), e.message() + ", during parse key of map", e.traceback()); + throw Error(e.kind(), e.message() + ", during parse key of map", e.backtrace()); } try { val = TargetInternal::ParseType(kv.second, *info.val); } catch (const Error& e) { std::ostringstream os; os << ", during parseing value of map[\"" << key << "\"]"; - throw Error(e.kind(), e.message() + os.str(), e.traceback()); + throw Error(e.kind(), e.message() + os.str(), e.backtrace()); } result[key] = val; } @@ -579,7 +579,7 @@ Target::Target(const ffi::String& tag_or_config_or_target_str) { } catch (const Error& e) { std::ostringstream os; os << ". Target creation from string failed: " << tag_or_config_or_target_str; - throw Error("ValueError", e.message() + os.str(), e.traceback()); + throw Error("ValueError", e.message() + os.str(), e.backtrace()); } data_ = std::move(target); } @@ -591,7 +591,7 @@ Target::Target(const ffi::Map& config) { } catch (const Error& e) { std::ostringstream os; os << ". Target creation from config dict failed: " << config; - throw Error("ValueError", std::string(e.message()) + os.str(), e.traceback()); + throw Error("ValueError", std::string(e.message()) + os.str(), e.backtrace()); } data_ = std::move(target); } @@ -810,7 +810,7 @@ ObjectPtr TargetInternal::FromRawString(const ffi::String& target_st iter += ParseKVPair(RemovePrefixDashes(options[iter]), s_next, &key, &value); } catch (const Error& e) { throw Error(e.kind(), e.message() + ", during parsing target `" + target_str + "`", - e.traceback()); + e.backtrace()); } try { // check if `key` has been used @@ -820,7 +820,7 @@ ObjectPtr TargetInternal::FromRawString(const ffi::String& target_st config[key] = TargetInternal::ParseType(value, TargetInternal::FindTypeInfo(kind, key)); } catch (const Error& e) { throw Error(e.kind(), std::string(e.message()) + ", during parsing target[\"" + key + "\"]", - e.traceback()); + e.backtrace()); } } return TargetInternal::FromConfig(config); @@ -927,7 +927,7 @@ ObjectPtr TargetInternal::FromConfig(ffi::Map attrs[key] = TargetInternal::ParseType(value, info); } catch (const Error& e) { throw Error(e.kind(), std::string(e.message()) + ", during parsing target[\"" + key + "\"]", - e.traceback()); + e.backtrace()); } } diff --git a/src/tir/schedule/error.h b/src/tir/schedule/error.h index 093e5519dbd7..39c9cc203fcf 100644 --- a/src/tir/schedule/error.h +++ b/src/tir/schedule/error.h @@ -31,7 +31,7 @@ class ScheduleError : public tvm::runtime::Error { public: /*! \brief Base constructor */ ScheduleError() - : tvm::runtime::Error("ScheduleError", "", TVMFFITraceback(nullptr, 0, nullptr, 0)) {} + : tvm::runtime::Error("ScheduleError", "", TVMFFIBacktrace(nullptr, 0, nullptr, 0)) {} /*! \brief The error occurred in this IRModule */ virtual IRModule mod() const = 0; /*! \brief The locations of interest that we want to point out */ diff --git a/web/emcc/wasm_runtime.cc b/web/emcc/wasm_runtime.cc index 35f3a4dc4d1e..31547269e121 100644 --- a/web/emcc/wasm_runtime.cc +++ b/web/emcc/wasm_runtime.cc @@ -48,6 +48,7 @@ #include "src/runtime/tensor.cc" #include "src/runtime/workspace_pool.cc" // relax setup +#include "3rdparty/tvm-ffi/src/ffi/backtrace.cc" #include "3rdparty/tvm-ffi/src/ffi/container.cc" #include "3rdparty/tvm-ffi/src/ffi/dtype.cc" #include "3rdparty/tvm-ffi/src/ffi/error.cc" @@ -58,7 +59,6 @@ #include "3rdparty/tvm-ffi/src/ffi/function.cc" #include "3rdparty/tvm-ffi/src/ffi/object.cc" #include "3rdparty/tvm-ffi/src/ffi/tensor.cc" -#include "3rdparty/tvm-ffi/src/ffi/traceback.cc" #include "src/runtime/memory/memory_manager.cc" #include "src/runtime/nvtx.cc" #include "src/runtime/vm/attn_backend.cc"