This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 97a34a9a04 [REFACTOR][RUNTIME] Macro cleanup — TVM_DLL alignment,
[[maybe_unused]], logging.h legacy macros (#19457)
97a34a9a04 is described below
commit 97a34a9a049009757b22a7470ee0455a69f13b38
Author: Tianqi Chen <[email protected]>
AuthorDate: Mon Apr 27 18:18:19 2026 -0400
[REFACTOR][RUNTIME] Macro cleanup — TVM_DLL alignment, [[maybe_unused]],
logging.h legacy macros (#19457)
---
apps/android_rpc/app/src/main/jni/Application.mk | 2 +-
apps/android_rpc/app/src/main/jni/tvm_runtime.h | 3 +-
apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj | 2 -
include/tvm/ir/op.h | 2 +-
include/tvm/ir/transform.h | 2 +-
include/tvm/node/functor.h | 2 +-
include/tvm/runtime/base.h | 76 ++++++++++++---------
include/tvm/runtime/disco/session.h | 2 +-
include/tvm/runtime/logging.h | 79 +++-------------------
include/tvm/s_tir/schedule/instruction.h | 2 +-
include/tvm/target/tag.h | 2 +-
include/tvm/target/target_kind.h | 2 +-
src/relax/transform/fold_constant.cc | 2 +-
src/runtime/disco/bcast_session.cc | 4 +-
src/runtime/hexagon/hexagon_common.cc | 2 +-
src/runtime/memory/pooled_allocator.h | 2 +-
src/runtime/opencl/opencl_device_api.cc | 2 +-
src/runtime/rpc/rpc_device_api.cc | 2 +-
src/runtime/rpc/rpc_endpoint.cc | 4 +-
src/runtime/rpc/rpc_module.cc | 6 +-
src/runtime/rpc/rpc_session.h | 2 +-
src/runtime/vm/module_utils.h | 8 +--
src/runtime/vm/vm.cc | 4 +-
.../meta_schedule/schedule_rule/add_rfactor.cc | 2 +-
src/s_tir/meta_schedule/utils.h | 2 +-
src/s_tir/schedule/error.h | 6 +-
src/s_tir/schedule/instruction_traits.h | 22 +++---
src/s_tir/schedule/primitive/compute_at.cc | 4 +-
src/s_tir/schedule/primitive/compute_inline.cc | 4 +-
src/s_tir/schedule/primitive/decompose_padding.cc | 2 +-
.../schedule/primitive/loop_transformation.cc | 10 +--
src/s_tir/schedule/trace.cc | 6 +-
src/s_tir/schedule/transform.cc | 2 +-
src/script/printer/utils.h | 2 +-
src/target/llvm/codegen_hexagon.cc | 2 +-
src/target/target.cc | 8 +--
tests/cpp/ir_functor_test.cc | 2 +-
tests/cpp/target_test.cc | 2 +-
web/emcc/tvmjs_support.cc | 1 -
web/emcc/wasm_runtime.cc | 1 -
web/emcc/webgpu_runtime.cc | 1 -
41 files changed, 117 insertions(+), 176 deletions(-)
diff --git a/apps/android_rpc/app/src/main/jni/Application.mk
b/apps/android_rpc/app/src/main/jni/Application.mk
index df560863f0..a7996548eb 100644
--- a/apps/android_rpc/app/src/main/jni/Application.mk
+++ b/apps/android_rpc/app/src/main/jni/Application.mk
@@ -31,7 +31,7 @@ include $(config)
APP_ABI ?= armeabi-v7a arm64-v8a x86 x86_64 mips
APP_STL := c++_shared
-APP_CPPFLAGS += -DTVM_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++17 -Oz -frtti
+APP_CPPFLAGS += -DTVM4J_ANDROID=1 -std=c++17 -Oz -frtti
ifeq ($(USE_OPENCL), 1)
APP_CPPFLAGS += -DTVM_OPENCL_RUNTIME=1
endif
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 035d8b980e..460bca0bc7 100644
--- a/apps/android_rpc/app/src/main/jni/tvm_runtime.h
+++ b/apps/android_rpc/app/src/main/jni/tvm_runtime.h
@@ -25,7 +25,6 @@
#include <fstream>
-#define TVM_USE_LIBBACKTRACE 0
/* Enable custom logging - this will cause TVM to use a custom implementation
* of tvm::runtime::detail::LogMessage. We use this to pass TVM log messages to
* Android logcat.
@@ -102,7 +101,7 @@ namespace detail {
[[noreturn]] void LogFatalImpl(const std::string& file, int lineno, const
std::string& message) {
std::string m = file + ":" + std::to_string(lineno) + ": " + message;
__android_log_write(ANDROID_LOG_FATAL, "TVM_RUNTIME", m.c_str());
- throw InternalError(file, lineno, message);
+ throw tvm::ffi::Error("InternalError", message,
TVMFFIBacktrace(file.c_str(), lineno, "", 0));
}
void LogMessageImpl(const std::string& file, int lineno, int level, const
std::string& message) {
std::string m = file + ":" + std::to_string(lineno) + ": " + message;
diff --git a/apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj
b/apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj
index c2948edcf1..27e0d7be35 100644
--- a/apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj
+++ b/apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj
@@ -284,7 +284,6 @@
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
- "TVM_USE_LIBBACKTRACE=0",
"TVM_LOG_CUSTOMIZE=1",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -332,7 +331,6 @@
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
- "TVM_USE_LIBBACKTRACE=0",
"TVM_LOG_CUSTOMIZE=1",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
diff --git a/include/tvm/ir/op.h b/include/tvm/ir/op.h
index 9171a9e6d2..062ac3116f 100644
--- a/include/tvm/ir/op.h
+++ b/include/tvm/ir/op.h
@@ -293,7 +293,7 @@ class OpAttrMap : public AttrRegistryMap<Op, ValueType> {
};
// internal macros to make
-#define TVM_OP_REGISTER_VAR_DEF static TVM_ATTRIBUTE_UNUSED ::tvm::OpRegEntry&
__make_##Op
+#define TVM_OP_REGISTER_VAR_DEF [[maybe_unused]] static ::tvm::OpRegEntry&
__make_##Op
/*!
* \def TVM_REGISTER_OP
diff --git a/include/tvm/ir/transform.h b/include/tvm/ir/transform.h
index 97c98ccbf4..2ef8113ff9 100644
--- a/include/tvm/ir/transform.h
+++ b/include/tvm/ir/transform.h
@@ -300,7 +300,7 @@ class PassContext : public ObjectRef {
friend class With<PassContext>;
};
-#define TVM_PASS_CTX_CONFIG_VAR_DEF static TVM_ATTRIBUTE_UNUSED uint32_t
__make_PassContext_tid
+#define TVM_PASS_CTX_CONFIG_VAR_DEF [[maybe_unused]] static uint32_t
__make_PassContext_tid
/*!
* \brief Helper macro to register the object type to runtime.
diff --git a/include/tvm/node/functor.h b/include/tvm/node/functor.h
index 3f0babdbd0..bb507beb3c 100644
--- a/include/tvm/node/functor.h
+++ b/include/tvm/node/functor.h
@@ -154,7 +154,7 @@ class NodeFunctor<R(const ObjectRef& n, Args...)> {
}
};
-#define TVM_REG_FUNC_VAR_DEF(ClsName) static TVM_ATTRIBUTE_UNUSED auto&
__make_functor##_##ClsName
+#define TVM_REG_FUNC_VAR_DEF(ClsName) [[maybe_unused]] static auto&
__make_functor##_##ClsName
/*!
* \brief Useful macro to set NodeFunctor dispatch in a global static field.
diff --git a/include/tvm/runtime/base.h b/include/tvm/runtime/base.h
index 58daedfc7c..bdb64a66f5 100644
--- a/include/tvm/runtime/base.h
+++ b/include/tvm/runtime/base.h
@@ -31,52 +31,62 @@
// TVM version
#define TVM_VERSION "0.24.dev0"
-// define extra macros for TVM DLL exprt
+// TVM ships two shared libraries: libtvm_compiler and libtvm_runtime.
+// Each exposes its own DLL macro pair. The two families are defined
+// independently so that each can be overridden separately by downstream
+// embedders who need custom visibility on only one of the two libraries.
+//
+// TVM_DLL / TVM_DLL_EXPORT: symbols in libtvm_compiler.
+// - TVM_DLL is dllexport when TVM_EXPORTS is defined (compiler build),
+// dllimport otherwise (downstream consumers, runtime TUs).
+// - TVM_DLL_EXPORT is always dllexport.
+//
+// TVM_RUNTIME_DLL / TVM_RUNTIME_DLL_EXPORT: symbols in libtvm_runtime.
+// - TVM_RUNTIME_DLL is dllexport when TVM_RUNTIME_EXPORTS is defined
+// (runtime build), dllimport otherwise.
+// - TVM_RUNTIME_DLL_EXPORT is always dllexport.
+//
+// On non-MSVC platforms the import/export decision is made by the dynamic
+// loader, so all four macros expand to visibility("default"). Under
+// Emscripten they expand to EMSCRIPTEN_KEEPALIVE.
#ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h>
-#define TVM_DLL EMSCRIPTEN_KEEPALIVE
#endif
-// helper macro to suppress unused warning
-#if defined(__GNUC__)
-#define TVM_ATTRIBUTE_UNUSED __attribute__((unused))
-#else
-#define TVM_ATTRIBUTE_UNUSED
+// --- TVM_DLL family (libtvm_compiler) ---
+#if !defined(TVM_DLL) && defined(__EMSCRIPTEN__)
+#define TVM_DLL EMSCRIPTEN_KEEPALIVE
+#define TVM_DLL_EXPORT EMSCRIPTEN_KEEPALIVE
#endif
-
-// Two distinct DLL macros are needed because TVM ships TWO shared libraries:
-//
-// - ``TVM_RUNTIME_DLL`` marks symbols defined in ``libtvm_runtime``. They are
-// exported when ``TVM_RUNTIME_EXPORTS`` is set (the runtime build) and
-// imported otherwise (compiler-side TUs or downstream consumers).
-// - ``TVM_DLL`` marks symbols defined in ``libtvm_compiler``. Exported when
-// ``TVM_EXPORTS`` is set (the compiler build), imported otherwise.
-//
-// On non-MSVC platforms both expand to ``visibility("default")`` — symbol
-// imports vs exports are decided by the runtime dynamic loader, not the
-// compiler.
-#ifndef TVM_RUNTIME_DLL
-#ifdef _WIN32
-#ifdef TVM_RUNTIME_EXPORTS
-#define TVM_RUNTIME_DLL __declspec(dllexport)
+#if !defined(TVM_DLL) && defined(_MSC_VER)
+#ifdef TVM_EXPORTS
+#define TVM_DLL __declspec(dllexport)
#else
-#define TVM_RUNTIME_DLL __declspec(dllimport)
+#define TVM_DLL __declspec(dllimport)
#endif
-#else
-#define TVM_RUNTIME_DLL __attribute__((visibility("default")))
+#define TVM_DLL_EXPORT __declspec(dllexport)
#endif
+#ifndef TVM_DLL
+#define TVM_DLL __attribute__((visibility("default")))
+#define TVM_DLL_EXPORT __attribute__((visibility("default")))
#endif
-#ifndef TVM_DLL
-#ifdef _WIN32
-#ifdef TVM_EXPORTS
-#define TVM_DLL __declspec(dllexport)
-#else
-#define TVM_DLL __declspec(dllimport)
+// --- TVM_RUNTIME_DLL family (libtvm_runtime) ---
+#if !defined(TVM_RUNTIME_DLL) && defined(__EMSCRIPTEN__)
+#define TVM_RUNTIME_DLL EMSCRIPTEN_KEEPALIVE
+#define TVM_RUNTIME_DLL_EXPORT EMSCRIPTEN_KEEPALIVE
#endif
+#if !defined(TVM_RUNTIME_DLL) && defined(_MSC_VER)
+#ifdef TVM_RUNTIME_EXPORTS
+#define TVM_RUNTIME_DLL __declspec(dllexport)
#else
-#define TVM_DLL __attribute__((visibility("default")))
+#define TVM_RUNTIME_DLL __declspec(dllimport)
+#endif
+#define TVM_RUNTIME_DLL_EXPORT __declspec(dllexport)
#endif
+#ifndef TVM_RUNTIME_DLL
+#define TVM_RUNTIME_DLL __attribute__((visibility("default")))
+#define TVM_RUNTIME_DLL_EXPORT __attribute__((visibility("default")))
#endif
#endif // TVM_RUNTIME_BASE_H_
diff --git a/include/tvm/runtime/disco/session.h
b/include/tvm/runtime/disco/session.h
index 34fd7bccd7..daae2954af 100644
--- a/include/tvm/runtime/disco/session.h
+++ b/include/tvm/runtime/disco/session.h
@@ -199,7 +199,7 @@ class SessionObj : public Object {
* \return The return value of function call
*/
template <typename... Args>
- DRef TVM_ALWAYS_INLINE CallPacked(const DRef& func, Args&&... args);
+ TVM_FFI_INLINE DRef CallPacked(const DRef& func, Args&&... args);
/*!
* \brief Call packed function on each worker using a packed sequence. The
calling convention:
* The first element must be DiscoAction::kCallPacked,
diff --git a/include/tvm/runtime/logging.h b/include/tvm/runtime/logging.h
index 3fceb02224..d051a01da4 100644
--- a/include/tvm/runtime/logging.h
+++ b/include/tvm/runtime/logging.h
@@ -48,52 +48,6 @@
#include <unordered_map>
#include <vector>
-/*!
- * \brief Macro helper to force a function not to be inlined.
- * It is only used in places that we know not inlining is good,
- * e.g. some logging functions.
- */
-#if defined(_MSC_VER)
-#define TVM_NO_INLINE __declspec(noinline)
-#else
-#define TVM_NO_INLINE __attribute__((noinline))
-#endif
-
-/*!
- * \brief Macro helper to force a function to be inlined.
- * It is only used in places that we know inline is important,
- * e.g. some template expansion cases.
- */
-#ifdef _MSC_VER
-#define TVM_ALWAYS_INLINE __forceinline
-#else
-#define TVM_ALWAYS_INLINE inline __attribute__((always_inline))
-#endif
-
-/*!
- * \brief Macro helper for exception throwing.
- */
-#define TVM_THROW_EXCEPTION noexcept(false)
-
-/*!
- * \brief Whether or not enable backtrace logging during a
- * fatal error.
- *
- * \note TVM won't depend on LIBBACKTRACE or other exec_info
- * library when this option is disabled.
- */
-#ifndef TVM_LOG_STACK_TRACE
-#define TVM_LOG_STACK_TRACE 1
-#endif
-
-/*!
- * \brief Whether or not use libbacktrace library
- * for getting backtrace information
- */
-#ifndef TVM_USE_LIBBACKTRACE
-#define TVM_USE_LIBBACKTRACE 0
-#endif
-
/*!
* \brief Whether or not customize the logging output.
* If log customize is enabled, the user must implement
@@ -107,20 +61,6 @@ namespace tvm {
namespace runtime {
using ffi::EnvErrorAlreadySet;
-using ffi::Error;
-
-/*!
- * \brief Error type for errors from LOG(FATAL). This error
- * contains a backtrace of where it occurred.
- *
- * \note LOG(FATAL) always throws InternalError. For typed errors,
- * use TVM_FFI_THROW(ErrorKind) instead.
- */
-class InternalError : public Error {
- public:
- InternalError(std::string file, int lineno, std::string message)
- : Error("InternalError", std::move(message),
TVMFFIBacktrace(file.c_str(), lineno, "", 0)) {}
-};
/*! \brief Internal implementation */
namespace detail {
@@ -153,7 +93,7 @@ class LogFatal {
#pragma warning(push)
#pragma warning(disable : 4722)
#endif
- [[noreturn]] ~LogFatal() TVM_THROW_EXCEPTION { LogFatalImpl(file_, lineno_,
stream_.str()); }
+ [[noreturn]] ~LogFatal() noexcept(false) { LogFatalImpl(file_, lineno_,
stream_.str()); }
#ifdef _MSC_VER
#pragma warning(pop)
#endif
@@ -193,12 +133,12 @@ class LogMessage {
*/
class LogFatal {
public:
- TVM_NO_INLINE LogFatal(const char* file, int lineno) { GetEntry().Init(file,
lineno); }
+ TVM_FFI_NO_INLINE LogFatal(const char* file, int lineno) {
GetEntry().Init(file, lineno); }
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4722)
#endif
- [[noreturn]] ~LogFatal() TVM_THROW_EXCEPTION {
+ [[noreturn]] ~LogFatal() noexcept(false) {
GetEntry().Finalize();
throw;
}
@@ -214,8 +154,9 @@ class LogFatal {
this->file_ = file;
this->lineno_ = lineno;
}
- [[noreturn]] TVM_NO_INLINE Error Finalize() TVM_THROW_EXCEPTION {
- InternalError error(file_, lineno_, stream_.str());
+ [[noreturn]] TVM_FFI_NO_INLINE ffi::Error Finalize() noexcept(false) {
+ ffi::Error error("InternalError", stream_.str(),
+ TVMFFIBacktrace(file_.c_str(), lineno_, "", 0));
throw error;
}
std::ostringstream stream_;
@@ -223,7 +164,7 @@ class LogFatal {
int lineno_;
};
- TVM_RUNTIME_DLL TVM_NO_INLINE static Entry& GetEntry();
+ TVM_FFI_NO_INLINE TVM_RUNTIME_DLL static Entry& GetEntry();
};
/*!
@@ -245,7 +186,7 @@ class LogMessage {
stream_ << "[" << std::put_time(std::localtime(&t), "%H:%M:%S") << "] " <<
file << ":" << lineno
<< kLevelStrings[level];
}
- TVM_NO_INLINE ~LogMessage() { std::cerr << stream_.str() << std::endl; }
+ TVM_FFI_NO_INLINE ~LogMessage() { std::cerr << stream_.str() << std::endl; }
std::ostringstream& stream() { return stream_; }
private:
@@ -459,9 +400,5 @@ class VLogContextEntry {
<< ::tvm::runtime::detail::ThreadLocalVLogContext()->str()
} // namespace runtime
-// Re-export error types
-using runtime::Error;
-using runtime::InternalError;
-
} // namespace tvm
#endif // TVM_RUNTIME_LOGGING_H_
diff --git a/include/tvm/s_tir/schedule/instruction.h
b/include/tvm/s_tir/schedule/instruction.h
index cfd7196329..495a5a1b95 100644
--- a/include/tvm/s_tir/schedule/instruction.h
+++ b/include/tvm/s_tir/schedule/instruction.h
@@ -208,7 +208,7 @@ class Instruction : public runtime::ObjectRef {
* \sa TVM_REGISTER_INST_KIND
*/
#define TVM_INST_KIND_REGISTER_VAR_DEF \
- static TVM_ATTRIBUTE_UNUSED ::tvm::s_tir::InstructionKindRegEntry&
__make_##InstructionKind
+ [[maybe_unused]] static ::tvm::s_tir::InstructionKindRegEntry&
__make_##InstructionKind
/*!
* \brief Register an InstructionKind
diff --git a/include/tvm/target/tag.h b/include/tvm/target/tag.h
index c6c828e2df..4557d20740 100644
--- a/include/tvm/target/tag.h
+++ b/include/tvm/target/tag.h
@@ -157,7 +157,7 @@ inline TargetTagRegEntry& TargetTagRegEntry::set_name() {
}
#define TVM_TARGET_TAG_REGISTER_VAR_DEF \
- static TVM_ATTRIBUTE_UNUSED ::tvm::TargetTagRegEntry& __make_##TargetTag
+ [[maybe_unused]] static ::tvm::TargetTagRegEntry& __make_##TargetTag
/*!
* \def TVM_REGISTER_TARGET_TAG
diff --git a/include/tvm/target/target_kind.h b/include/tvm/target/target_kind.h
index 86f55a2410..48c670ef2c 100644
--- a/include/tvm/target/target_kind.h
+++ b/include/tvm/target/target_kind.h
@@ -280,7 +280,7 @@ inline TargetKindRegEntry& TargetKindRegEntry::set_name() {
}
#define TVM_TARGET_KIND_REGISTER_VAR_DEF \
- static TVM_ATTRIBUTE_UNUSED ::tvm::TargetKindRegEntry& __make_##TargetKind
+ [[maybe_unused]] static ::tvm::TargetKindRegEntry& __make_##TargetKind
/*!
* \def TVM_REGISTER_TARGET_KIND
diff --git a/src/relax/transform/fold_constant.cc
b/src/relax/transform/fold_constant.cc
index f699775af9..cc4705f271 100644
--- a/src/relax/transform/fold_constant.cc
+++ b/src/relax/transform/fold_constant.cc
@@ -121,7 +121,7 @@ class ConstantFolder : public ExprMutator {
func = WithAttr(func, tvm::attr::kGlobalSymbol,
ffi::String("tir_function"));
ffi::Module rt_module = pf(func, eval_cpu_target).cast<ffi::Module>();
build_func = rt_module->GetFunction("tir_function");
- } catch (const tvm::Error& err) {
+ } catch (const tvm::ffi::Error& err) {
// build failure may happen in which case we skip
DLOG(WARNING) << "Build failure for function " << func << ", Error
message: " << err.what();
}
diff --git a/src/runtime/disco/bcast_session.cc
b/src/runtime/disco/bcast_session.cc
index 8828bdfae8..46716b411f 100644
--- a/src/runtime/disco/bcast_session.cc
+++ b/src/runtime/disco/bcast_session.cc
@@ -28,8 +28,8 @@ namespace runtime {
struct BcastSessionObj::Internal {
template <typename... Args>
- static void TVM_ALWAYS_INLINE BroadcastUnpacked(BcastSessionObj* self,
DiscoAction action,
- int64_t reg_id, Args&&...
args) {
+ TVM_FFI_INLINE static void BroadcastUnpacked(BcastSessionObj* self,
DiscoAction action,
+ int64_t reg_id, Args&&... args)
{
constexpr int kNumArgs = 2 + sizeof...(Args);
ffi::AnyView packed_args[kNumArgs];
ffi::PackedArgs::Fill(packed_args, static_cast<int>(action), reg_id,
diff --git a/src/runtime/hexagon/hexagon_common.cc
b/src/runtime/hexagon/hexagon_common.cc
index 61c7e4972b..442ec5ff56 100644
--- a/src/runtime/hexagon/hexagon_common.cc
+++ b/src/runtime/hexagon/hexagon_common.cc
@@ -81,7 +81,7 @@ void HexagonLog(const std::string& file, int lineno, int
level, const std::strin
namespace detail {
[[noreturn]] void LogFatalImpl(const std::string& file, int lineno, const
std::string& message) {
HexagonLog(file, lineno, TVM_LOG_LEVEL_FATAL, message);
- throw InternalError(file, lineno, message);
+ throw tvm::ffi::Error("InternalError", message,
TVMFFIBacktrace(file.c_str(), lineno, "", 0));
}
void LogMessageImpl(const std::string& file, int lineno, int level, const
std::string& message) {
HexagonLog(file, lineno, level, message);
diff --git a/src/runtime/memory/pooled_allocator.h
b/src/runtime/memory/pooled_allocator.h
index 13c16f7ace..6203934668 100644
--- a/src/runtime/memory/pooled_allocator.h
+++ b/src/runtime/memory/pooled_allocator.h
@@ -61,7 +61,7 @@ class PooledAllocator : public Allocator {
buf.alloc_type = kPooled;
try {
buf.data = DeviceAllocDataSpace(dev, size, alignment, type_hint);
- } catch (InternalError& err) {
+ } catch (tvm::ffi::Error& err) {
LOG(WARNING) << "PooledAllocator got InternalError during allocation: "
<< err.what();
LOG(WARNING) << "Trying to release all unused memory and reallocate...";
ReleaseAll();
diff --git a/src/runtime/opencl/opencl_device_api.cc
b/src/runtime/opencl/opencl_device_api.cc
index 8820585bb6..a4f7daf532 100644
--- a/src/runtime/opencl/opencl_device_api.cc
+++ b/src/runtime/opencl/opencl_device_api.cc
@@ -842,7 +842,7 @@ class OpenCLPooledAllocator final : public
memory::PooledAllocator {
buf.alloc_type = AllocatorType::kPooled;
try {
buf.data = DeviceAllocDataSpace(dev, size, alignment, type_hint);
- } catch (InternalError& err) {
+ } catch (tvm::ffi::Error& err) {
LOG(WARNING) << "PooledAllocator got InternalError during allocation: "
<< err.what();
LOG(WARNING) << "Trying to release all unused memory and reallocate...";
ReleaseAll();
diff --git a/src/runtime/rpc/rpc_device_api.cc
b/src/runtime/rpc/rpc_device_api.cc
index dd4b199314..579b45abb3 100644
--- a/src/runtime/rpc/rpc_device_api.cc
+++ b/src/runtime/rpc/rpc_device_api.cc
@@ -72,7 +72,7 @@ class RPCDeviceAPI final : public DeviceAPI {
auto remote_dev = RemoveRPCSessionMask(dev);
try {
GetSess(dev)->GetDeviceAPI(remote_dev)->FreeDataSpace(remote_dev,
space->data);
- } catch (const Error& e) {
+ } catch (const ffi::Error& e) {
// fault tolerance to remote close.
}
delete space;
diff --git a/src/runtime/rpc/rpc_endpoint.cc b/src/runtime/rpc/rpc_endpoint.cc
index 24687e504c..052ca2eb7c 100644
--- a/src/runtime/rpc/rpc_endpoint.cc
+++ b/src/runtime/rpc/rpc_endpoint.cc
@@ -625,7 +625,7 @@ class RPCEndpoint::EventHandler : public support::Stream {
try {
fconstructor->CallPacked(constructor_args, &con_ret);
- } catch (const Error& e) {
+ } catch (const ffi::Error& e) {
TVM_FFI_THROW(InternalError)
<< "Server[" << name_ << "]:"
<< " Error caught from session constructor " << constructor_name
<< ":\n"
@@ -830,7 +830,7 @@ void RPCEndpoint::Shutdown() {
writer_.bytes_available());
if (n == 0) break;
}
- } catch (const Error& e) {
+ } catch (const ffi::Error& e) {
}
channel_.reset(nullptr);
}
diff --git a/src/runtime/rpc/rpc_module.cc b/src/runtime/rpc/rpc_module.cc
index 34be3556a9..ad8f1967db 100644
--- a/src/runtime/rpc/rpc_module.cc
+++ b/src/runtime/rpc/rpc_module.cc
@@ -66,7 +66,7 @@ Tensor
TensorFromRemoteOpaqueHandle(std::shared_ptr<RPCSession> sess, void* hand
if (space_.object_handle != nullptr) {
try {
space_.sess->FreeHandle(space_.object_handle);
- } catch (const Error& e) {
+ } catch (const ffi::Error& e) {
// fault tolerance to remote close
}
}
@@ -153,7 +153,7 @@ class RPCWrappedFunc : public Object {
~RPCWrappedFunc() {
try {
sess_->FreeHandle(handle_);
- } catch (const Error& e) {
+ } catch (const ffi::Error& e) {
// fault tolerance to remote close
}
}
@@ -188,7 +188,7 @@ class RPCModuleNode final : public ffi::ModuleObj {
if (module_handle_ != nullptr) {
try {
sess_->FreeHandle(module_handle_);
- } catch (const Error& e) {
+ } catch (const ffi::Error& e) {
// fault tolerance to remote close
}
module_handle_ = nullptr;
diff --git a/src/runtime/rpc/rpc_session.h b/src/runtime/rpc/rpc_session.h
index 096ab2bdf9..a8ea0e6092 100644
--- a/src/runtime/rpc/rpc_session.h
+++ b/src/runtime/rpc/rpc_session.h
@@ -311,7 +311,7 @@ class RPCObjectRefObj : public Object {
if (object_handle_ != nullptr && sess_ != nullptr) {
try {
sess_->FreeHandle(object_handle_);
- } catch (const Error& e) {
+ } catch (const ffi::Error& e) {
// fault tolerance to remote close
}
object_handle_ = nullptr;
diff --git a/src/runtime/vm/module_utils.h b/src/runtime/vm/module_utils.h
index f6c69c49dd..2897cdf327 100644
--- a/src/runtime/vm/module_utils.h
+++ b/src/runtime/vm/module_utils.h
@@ -48,7 +48,7 @@ struct ModuleVTableEntryHelper {};
template <typename T, typename R, typename... Args>
struct ModuleVTableEntryHelper<R (T::*)(Args...) const> {
using MemFnType = R (T::*)(Args...) const;
- static TVM_ALWAYS_INLINE void Call(ffi::Any* rv, T* self, MemFnType f,
ffi::PackedArgs args) {
+ TVM_FFI_INLINE static void Call(ffi::Any* rv, T* self, MemFnType f,
ffi::PackedArgs args) {
auto wrapped = [self, f](Args... args) -> R { return
(self->*f)(std::forward<Args>(args)...); };
ffi::details::unpack_call<R>(std::make_index_sequence<sizeof...(Args)>{},
nullptr, wrapped,
args.data(), args.size(), rv);
@@ -58,7 +58,7 @@ struct ModuleVTableEntryHelper<R (T::*)(Args...) const> {
template <typename T, typename R, typename... Args>
struct ModuleVTableEntryHelper<R (T::*)(Args...)> {
using MemFnType = R (T::*)(Args...);
- static TVM_ALWAYS_INLINE void Call(ffi::Any* rv, T* self, MemFnType f,
ffi::PackedArgs args) {
+ TVM_FFI_INLINE static void Call(ffi::Any* rv, T* self, MemFnType f,
ffi::PackedArgs args) {
auto wrapped = [self, f](Args... args) -> R { return
(self->*f)(std::forward<Args>(args)...); };
ffi::details::unpack_call<R>(std::make_index_sequence<sizeof...(Args)>{},
nullptr, wrapped,
args.data(), args.size(), rv);
@@ -68,7 +68,7 @@ struct ModuleVTableEntryHelper<R (T::*)(Args...)> {
template <typename T, typename... Args>
struct ModuleVTableEntryHelper<void (T::*)(Args...) const> {
using MemFnType = void (T::*)(Args...) const;
- static TVM_ALWAYS_INLINE void Call(ffi::Any* rv, T* self, MemFnType f,
ffi::PackedArgs args) {
+ TVM_FFI_INLINE static void Call(ffi::Any* rv, T* self, MemFnType f,
ffi::PackedArgs args) {
auto wrapped = [self, f](Args... args) -> void {
(self->*f)(std::forward<Args>(args)...); };
ffi::details::unpack_call<void>(std::make_index_sequence<sizeof...(Args)>{},
nullptr, wrapped,
args.data(), args.size(), rv);
@@ -78,7 +78,7 @@ struct ModuleVTableEntryHelper<void (T::*)(Args...) const> {
template <typename T, typename... Args>
struct ModuleVTableEntryHelper<void (T::*)(Args...)> {
using MemFnType = void (T::*)(Args...);
- static TVM_ALWAYS_INLINE void Call(ffi::Any* rv, T* self, MemFnType f,
ffi::PackedArgs args) {
+ TVM_FFI_INLINE static void Call(ffi::Any* rv, T* self, MemFnType f,
ffi::PackedArgs args) {
auto wrapped = [self, f](Args... args) -> void {
(self->*f)(std::forward<Args>(args)...); };
ffi::details::unpack_call<void>(std::make_index_sequence<sizeof...(Args)>{},
nullptr, wrapped,
args.data(), args.size(), rv);
diff --git a/src/runtime/vm/vm.cc b/src/runtime/vm/vm.cc
index cc336ea696..f7d6765e6a 100644
--- a/src/runtime/vm/vm.cc
+++ b/src/runtime/vm/vm.cc
@@ -361,7 +361,7 @@ class VirtualMachineImpl : public VirtualMachine {
* \param reg The register to write to.
* \param obj The object to write to.
*/
- TVM_ALWAYS_INLINE void WriteRegister(VMFrame* frame, RegName reg, const
RegType& obj) {
+ TVM_FFI_INLINE void WriteRegister(VMFrame* frame, RegName reg, const
RegType& obj) {
TVM_FFI_ICHECK_LT(reg, frame->register_file.size());
frame->register_file[reg] = obj;
}
@@ -371,7 +371,7 @@ class VirtualMachineImpl : public VirtualMachine {
* \param reg The register to read from.
* \return The value of the register.
*/
- TVM_ALWAYS_INLINE RegType ReadRegister(VMFrame* frame, RegName reg) {
+ TVM_FFI_INLINE RegType ReadRegister(VMFrame* frame, RegName reg) {
if (reg < Instruction::kBeginSpecialReg) {
return frame->register_file[reg];
}
diff --git a/src/s_tir/meta_schedule/schedule_rule/add_rfactor.cc
b/src/s_tir/meta_schedule/schedule_rule/add_rfactor.cc
index e66e6400c8..f305d94c83 100644
--- a/src/s_tir/meta_schedule/schedule_rule/add_rfactor.cc
+++ b/src/s_tir/meta_schedule/schedule_rule/add_rfactor.cc
@@ -117,7 +117,7 @@ ffi::Array<s_tir::Schedule> AddRFactorNode::Apply(const
s_tir::Schedule& sch,
// be considered by the rule Random-Compute-Location.
sch_tmp->Annotate(block_rv,
s_tir::attr::meta_schedule_random_compute_producer, Integer(1));
res.push_back(sch_tmp);
- } catch (const tvm::runtime::Error& e) {
+ } catch (const tvm::ffi::Error& e) {
}
}
diff --git a/src/s_tir/meta_schedule/utils.h b/src/s_tir/meta_schedule/utils.h
index ec2ece6713..cd0eee04c9 100644
--- a/src/s_tir/meta_schedule/utils.h
+++ b/src/s_tir/meta_schedule/utils.h
@@ -91,7 +91,7 @@ class PyLogMessage {
explicit PyLogMessage(const char* filename, int lineno, ffi::Function
logger, Level logging_level)
: filename_(filename), lineno_(lineno), logger_(logger),
logging_level_(logging_level) {}
- TVM_NO_INLINE ~PyLogMessage() {
+ TVM_FFI_NO_INLINE ~PyLogMessage() {
TVM_FFI_ICHECK(logging_level_ != Level::CLEAR)
<< "Cannot use CLEAR as logging level in TVM_PY_LOG, please use
TVM_PY_LOG_CLEAR_SCREEN.";
if (this->logger_ != nullptr) {
diff --git a/src/s_tir/schedule/error.h b/src/s_tir/schedule/error.h
index 965ba143f1..180dd39110 100644
--- a/src/s_tir/schedule/error.h
+++ b/src/s_tir/schedule/error.h
@@ -18,6 +18,7 @@
*/
#ifndef TVM_S_TIR_SCHEDULE_ERROR_H_
#define TVM_S_TIR_SCHEDULE_ERROR_H_
+#include <tvm/ffi/error.h>
#include <tvm/s_tir/schedule/state.h>
#include <string>
@@ -28,11 +29,10 @@ namespace s_tir {
using namespace tvm::tirx;
/*! \brief Error that happens during TensorIR scheduling */
-class ScheduleError : public tvm::runtime::Error {
+class ScheduleError : public tvm::ffi::Error {
public:
/*! \brief Base constructor */
- ScheduleError()
- : tvm::runtime::Error("ScheduleError", "", TVMFFIBacktrace(nullptr, 0,
nullptr, 0)) {}
+ ScheduleError() : tvm::ffi::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/src/s_tir/schedule/instruction_traits.h
b/src/s_tir/schedule/instruction_traits.h
index 067af37721..239a37582c 100644
--- a/src/s_tir/schedule/instruction_traits.h
+++ b/src/s_tir/schedule/instruction_traits.h
@@ -172,12 +172,12 @@ struct UnpackedInstTraits {
protected:
template <size_t index_offset>
- static TVM_ALWAYS_INLINE void _SetInputs(AnyView* packed_args, const
ffi::Array<Any>& inputs);
+ TVM_FFI_INLINE static void _SetInputs(AnyView* packed_args, const
ffi::Array<Any>& inputs);
template <size_t index_offset>
- static TVM_ALWAYS_INLINE void _SetAttrs(AnyView* packed_args, const
ffi::Array<Any>& attrs);
+ TVM_FFI_INLINE static void _SetAttrs(AnyView* packed_args, const
ffi::Array<Any>& attrs);
template <size_t index_offset>
- static TVM_ALWAYS_INLINE void _SetDecision(AnyView* packed_args, const Any&
decision);
- static TVM_ALWAYS_INLINE ffi::Array<Any> _ConvertOutputs(const ffi::Any& rv);
+ TVM_FFI_INLINE static void _SetDecision(AnyView* packed_args, const Any&
decision);
+ TVM_FFI_INLINE static ffi::Array<Any> _ConvertOutputs(const ffi::Any& rv);
};
/*!
@@ -363,8 +363,8 @@ ffi::String UnpackedInstTraits<TTraits>::AsPython(const
ffi::Array<Any>& inputs,
template <class TTraits>
template <size_t index_offset>
-TVM_ALWAYS_INLINE void UnpackedInstTraits<TTraits>::_SetInputs(AnyView*
packed_args,
- const
ffi::Array<Any>& inputs) {
+TVM_FFI_INLINE void UnpackedInstTraits<TTraits>::_SetInputs(AnyView*
packed_args,
+ const
ffi::Array<Any>& inputs) {
constexpr size_t kNumInputs = TTraits::kNumInputs;
TVM_FFI_CHECK_EQ(kNumInputs, inputs.size(), ValueError)
<< "Incorrect kNumInputs for instruction: " << TTraits::kName;
@@ -375,8 +375,8 @@ TVM_ALWAYS_INLINE void
UnpackedInstTraits<TTraits>::_SetInputs(AnyView* packed_a
template <class TTraits>
template <size_t index_offset>
-TVM_ALWAYS_INLINE void UnpackedInstTraits<TTraits>::_SetAttrs(AnyView*
packed_args,
- const
ffi::Array<Any>& attrs) {
+TVM_FFI_INLINE void UnpackedInstTraits<TTraits>::_SetAttrs(AnyView*
packed_args,
+ const
ffi::Array<Any>& attrs) {
constexpr size_t kNumAttrs = TTraits::kNumAttrs;
TVM_FFI_CHECK_EQ(kNumAttrs, attrs.size(), ValueError)
<< "Incorrect kNumAttrs for instruction: " << TTraits::kName;
@@ -387,8 +387,8 @@ TVM_ALWAYS_INLINE void
UnpackedInstTraits<TTraits>::_SetAttrs(AnyView* packed_ar
template <class TTraits>
template <size_t index_offset>
-TVM_ALWAYS_INLINE void UnpackedInstTraits<TTraits>::_SetDecision(AnyView*
packed_args,
- const Any&
decision) {
+TVM_FFI_INLINE void UnpackedInstTraits<TTraits>::_SetDecision(AnyView*
packed_args,
+ const Any&
decision) {
constexpr size_t kNumDecisions = TTraits::kNumDecisions;
static_assert(kNumDecisions <= 1, "an instruction is supposed to have at
most 1 decision");
if (kNumDecisions == 1) {
@@ -399,7 +399,7 @@ TVM_ALWAYS_INLINE void
UnpackedInstTraits<TTraits>::_SetDecision(AnyView* packed
}
template <class TTraits>
-TVM_ALWAYS_INLINE ffi::Array<Any>
UnpackedInstTraits<TTraits>::_ConvertOutputs(const ffi::Any& rv) {
+TVM_FFI_INLINE ffi::Array<Any>
UnpackedInstTraits<TTraits>::_ConvertOutputs(const ffi::Any& rv) {
using method_type = decltype(TTraits::UnpackedApplyToSchedule);
using return_type = details::ReturnType<method_type>;
constexpr int is_array = details::IsTVMArray<return_type>;
diff --git a/src/s_tir/schedule/primitive/compute_at.cc
b/src/s_tir/schedule/primitive/compute_at.cc
index f099796bad..1c25c94952 100644
--- a/src/s_tir/schedule/primitive/compute_at.cc
+++ b/src/s_tir/schedule/primitive/compute_at.cc
@@ -783,7 +783,7 @@ bool CanComputeAt(const ScheduleState& self, const
StmtSRef& block_sref, const S
try {
ComputeAtOrReverseComputeAtImpl<true>(self, block_sref, loop_sref,
preserve_unit_loops,
&analyzer, true);
- } catch (const tvm::runtime::Error& e) {
+ } catch (const tvm::ffi::Error& e) {
return false;
}
return true;
@@ -795,7 +795,7 @@ bool CanReverseComputeAt(const ScheduleState& self, const
StmtSRef& block_sref,
try {
ComputeAtOrReverseComputeAtImpl<false>(self, block_sref, loop_sref,
preserve_unit_loops,
&analyzer, true);
- } catch (const tvm::runtime::Error& e) {
+ } catch (const tvm::ffi::Error& e) {
return false;
}
return true;
diff --git a/src/s_tir/schedule/primitive/compute_inline.cc
b/src/s_tir/schedule/primitive/compute_inline.cc
index d2b28b1a1f..2f2c779810 100644
--- a/src/s_tir/schedule/primitive/compute_inline.cc
+++ b/src/s_tir/schedule/primitive/compute_inline.cc
@@ -921,7 +921,7 @@ void ComputeInline(ScheduleState self, const StmtSRef&
producer_block_sref) {
bool CanComputeInline(const ScheduleState& self, const StmtSRef&
producer_block_sref) {
try {
ComputeInlineImpl(self, producer_block_sref, true);
- } catch (const tvm::runtime::Error& e) {
+ } catch (const tvm::ffi::Error& e) {
return false;
}
return true;
@@ -977,7 +977,7 @@ void ReverseComputeInlineImpl(ScheduleState self, const
StmtSRef& consumer_block
bool CanReverseComputeInline(const ScheduleState& self, const StmtSRef&
block_sref) {
try {
ReverseComputeInlineImpl(self, block_sref, true);
- } catch (const tvm::runtime::Error& e) {
+ } catch (const tvm::ffi::Error& e) {
return false;
}
return true;
diff --git a/src/s_tir/schedule/primitive/decompose_padding.cc
b/src/s_tir/schedule/primitive/decompose_padding.cc
index 7d57cde137..79767edf1c 100644
--- a/src/s_tir/schedule/primitive/decompose_padding.cc
+++ b/src/s_tir/schedule/primitive/decompose_padding.cc
@@ -527,7 +527,7 @@ bool CanDecomposePadding(ScheduleState self, const
StmtSRef& block_sref,
const StmtSRef& loop_sref) {
try {
DecomposePaddingImpl(self, block_sref, loop_sref, true);
- } catch (const tvm::runtime::Error& e) {
+ } catch (const tvm::ffi::Error& e) {
return false;
}
return true;
diff --git a/src/s_tir/schedule/primitive/loop_transformation.cc
b/src/s_tir/schedule/primitive/loop_transformation.cc
index f43b1f2a2e..20f00f2f06 100644
--- a/src/s_tir/schedule/primitive/loop_transformation.cc
+++ b/src/s_tir/schedule/primitive/loop_transformation.cc
@@ -1187,7 +1187,7 @@ struct SplitTraits : public
UnpackedInstTraits<SplitTraits> {
static constexpr size_t kNumDecisions = 0;
template <size_t delta>
- static TVM_ALWAYS_INLINE void _SetInputs(AnyView* packed_args, const
ffi::Array<Any>& inputs) {
+ TVM_FFI_INLINE static void _SetInputs(AnyView* packed_args, const
ffi::Array<Any>& inputs) {
thread_local Any loop_rv{nullptr};
thread_local ffi::Array<Any> factors{nullptr};
loop_rv = inputs[0];
@@ -1230,7 +1230,7 @@ struct LoopPartitionTraits : public
UnpackedInstTraits<LoopPartitionTraits> {
static constexpr size_t kNumDecisions = 0;
template <size_t delta>
- static TVM_ALWAYS_INLINE void _SetInputs(AnyView* packed_args, const
ffi::Array<Any>& inputs) {
+ TVM_FFI_INLINE static void _SetInputs(AnyView* packed_args, const
ffi::Array<Any>& inputs) {
thread_local Any loop_rv{nullptr};
thread_local ffi::Array<Any> factors{nullptr};
loop_rv = inputs[0];
@@ -1269,7 +1269,7 @@ struct MergeTraits : public
UnpackedInstTraits<MergeTraits> {
static constexpr size_t kNumDecisions = 0;
template <size_t delta>
- static TVM_ALWAYS_INLINE void _SetInputs(AnyView* packed_args, const
ffi::Array<Any>& inputs) {
+ TVM_FFI_INLINE static void _SetInputs(AnyView* packed_args, const
ffi::Array<Any>& inputs) {
packed_args[delta] = inputs;
}
@@ -1301,7 +1301,7 @@ struct FuseTraits : public UnpackedInstTraits<FuseTraits>
{
static constexpr size_t kNumDecisions = 0;
template <size_t delta>
- static TVM_ALWAYS_INLINE void _SetInputs(AnyView* packed_args, const
ffi::Array<Any>& inputs) {
+ TVM_FFI_INLINE static void _SetInputs(AnyView* packed_args, const
ffi::Array<Any>& inputs) {
packed_args[delta] = inputs;
}
@@ -1335,7 +1335,7 @@ struct ReorderTraits : public
UnpackedInstTraits<ReorderTraits> {
static constexpr size_t kNumDecisions = 0;
template <size_t delta>
- static TVM_ALWAYS_INLINE void _SetInputs(AnyView* packed_args, const
ffi::Array<Any>& inputs) {
+ TVM_FFI_INLINE static void _SetInputs(AnyView* packed_args, const
ffi::Array<Any>& inputs) {
packed_args[delta] = inputs;
}
diff --git a/src/s_tir/schedule/trace.cc b/src/s_tir/schedule/trace.cc
index fae3279e90..a7e92915df 100644
--- a/src/s_tir/schedule/trace.cc
+++ b/src/s_tir/schedule/trace.cc
@@ -396,7 +396,7 @@ void Trace::ApplyJSONToSchedule(ObjectRef json, Schedule
sch) {
TVM_FFI_ICHECK(arr0 && arr1);
json_insts = ffi::GetRef<ffi::Array<Any>>(arr0);
json_decisions = ffi::GetRef<ffi::Array<Any>>(arr1);
- } catch (const tvm::Error& e) {
+ } catch (const tvm::ffi::Error& e) {
TVM_FFI_THROW(ValueError) << "The json entry of a trace should contain two
arrays, an array of "
"instructions and an array of decisions, but
gets: "
<< json;
@@ -414,7 +414,7 @@ void Trace::ApplyJSONToSchedule(ObjectRef json, Schedule
sch) {
TVM_FFI_ICHECK(arr0);
index = arr0.value()->value;
decision = arr->at(1);
- } catch (const tvm::Error& e) {
+ } catch (const tvm::ffi::Error& e) {
TVM_FFI_THROW(ValueError) << "Each entry of a json decision should be a
tuple [index, "
"decision], but gets: "
<< decision_entry;
@@ -439,7 +439,7 @@ void Trace::ApplyJSONToSchedule(ObjectRef json, Schedule
sch) {
inputs = arr->at(1).cast<ffi::Array<Any>>();
attrs = arr->at(2).cast<ffi::Array<Any>>();
outputs = arr->at(3).cast<ffi::Array<ffi::String>>();
- } catch (const tvm::Error& e) {
+ } catch (const tvm::ffi::Error& e) {
TVM_FFI_THROW(ValueError) << "Each entry of a json instruction should be
a tuple [inst_name, "
"inputs, attrs, outputs], but gets: "
<< inst_entry << "\nThe error is: " <<
e.what();
diff --git a/src/s_tir/schedule/transform.cc b/src/s_tir/schedule/transform.cc
index a401eba5e7..9e7e2e5415 100644
--- a/src/s_tir/schedule/transform.cc
+++ b/src/s_tir/schedule/transform.cc
@@ -537,7 +537,7 @@ ffi::Optional<ObjectRef> NormalizePrimFunc(Schedule sch) {
}
try {
sch->TransformBlockLayout(block, IndexMap(index_map_inputs,
index_map_outputs));
- } catch (tvm::runtime::Error& e) {
+ } catch (tvm::ffi::Error& e) {
// Skip layout transformation when not transformable.
}
block_loops.push_back(sch->GetLoops(block));
diff --git a/src/script/printer/utils.h b/src/script/printer/utils.h
index 1ec51450e3..6f35533533 100644
--- a/src/script/printer/utils.h
+++ b/src/script/printer/utils.h
@@ -51,7 +51,7 @@ namespace printer {
inline std::string RedirectedReprPrinterMethod(const ObjectRef& obj) {
try {
return TVMScriptPrinter::Script(obj, std::nullopt);
- } catch (const tvm::Error& e) {
+ } catch (const tvm::ffi::Error& e) {
LOG(WARNING) << "TVMScript printer falls back to the basic address printer
with the error:\n"
<< e.what();
std::ostringstream os;
diff --git a/src/target/llvm/codegen_hexagon.cc
b/src/target/llvm/codegen_hexagon.cc
index ac9c1a4b91..28fa7f1edd 100644
--- a/src/target/llvm/codegen_hexagon.cc
+++ b/src/target/llvm/codegen_hexagon.cc
@@ -402,7 +402,7 @@ llvm::Value* CodeGenHexagon::VectorLookupLoad(Buffer
buffer, DataType buffer_typ
}
namespace {
-TVM_ATTRIBUTE_UNUSED std::ostream& operator<<(std::ostream& os, const
llvm::Module& m) {
+[[maybe_unused]] std::ostream& operator<<(std::ostream& os, const
llvm::Module& m) {
std::string ms;
llvm::raw_string_ostream sos(ms);
sos << m;
diff --git a/src/target/target.cc b/src/target/target.cc
index 3a414d40ba..9d0e4a58e2 100644
--- a/src/target/target.cc
+++ b/src/target/target.cc
@@ -111,10 +111,10 @@ Target::Target(const ffi::String&
tag_or_config_or_target_str) {
ObjectPtr<Object> target;
try {
target = TargetInternal::FromString(tag_or_config_or_target_str);
- } catch (const Error& e) {
+ } catch (const ffi::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.backtrace());
+ throw ffi::Error("ValueError", e.message() + os.str(), e.backtrace());
}
data_ = std::move(target);
}
@@ -123,10 +123,10 @@ Target::Target(const ffi::Map<ffi::String, ffi::Any>&
config) {
ObjectPtr<Object> target;
try {
target = TargetInternal::FromConfig(config);
- } catch (const Error& e) {
+ } catch (const ffi::Error& e) {
std::ostringstream os;
os << ". Target creation from config dict failed: " << config;
- throw Error("ValueError", std::string(e.message()) + os.str(),
e.backtrace());
+ throw ffi::Error("ValueError", std::string(e.message()) + os.str(),
e.backtrace());
}
data_ = std::move(target);
}
diff --git a/tests/cpp/ir_functor_test.cc b/tests/cpp/ir_functor_test.cc
index cc0efbea20..8ad1a17377 100644
--- a/tests/cpp/ir_functor_test.cc
+++ b/tests/cpp/ir_functor_test.cc
@@ -109,7 +109,7 @@ TEST(IRF, ExprTransform) {
try {
f(z - 1, 2);
TVM_FFI_THROW(InternalError) << "should fail";
- } catch (Error&) {
+ } catch (tvm::ffi::Error&) {
}
}
diff --git a/tests/cpp/target_test.cc b/tests/cpp/target_test.cc
index 74b282d2a7..9e19dceb39 100644
--- a/tests/cpp/target_test.cc
+++ b/tests/cpp/target_test.cc
@@ -274,7 +274,7 @@ TEST(TargetCreationFail, UnknownNonFeatureKeyStillFails) {
{"mcpu", ffi::String("woof")},
{"unknown_key", ffi::String("bad")},
};
- ASSERT_THROW({ Target{config}; }, tvm::Error);
+ ASSERT_THROW({ Target{config}; }, tvm::ffi::Error);
}
TVM_REGISTER_TARGET_KIND("TestStringKind", kDLCPU)
diff --git a/web/emcc/tvmjs_support.cc b/web/emcc/tvmjs_support.cc
index 6b559f628e..0522bdff45 100644
--- a/web/emcc/tvmjs_support.cc
+++ b/web/emcc/tvmjs_support.cc
@@ -25,7 +25,6 @@
*/
// configurations for tvm logging
-#define TVM_LOG_STACK_TRACE 0
#define TVM_LOG_DEBUG 0
#define TVM_LOG_CUSTOMIZE 1
#define TVM_FFI_ALWAYS_LOG_BEFORE_THROW 1
diff --git a/web/emcc/wasm_runtime.cc b/web/emcc/wasm_runtime.cc
index f112a48b8e..baaff6b8ca 100644
--- a/web/emcc/wasm_runtime.cc
+++ b/web/emcc/wasm_runtime.cc
@@ -23,7 +23,6 @@
*/
// configurations for tvm logging
-#define TVM_LOG_STACK_TRACE 0
#define TVM_LOG_DEBUG 0
#define TVM_LOG_CUSTOMIZE 1
#define TVM_FFI_USE_LIBBACKTRACE 0
diff --git a/web/emcc/webgpu_runtime.cc b/web/emcc/webgpu_runtime.cc
index 7471ad592e..cae88552ef 100644
--- a/web/emcc/webgpu_runtime.cc
+++ b/web/emcc/webgpu_runtime.cc
@@ -23,7 +23,6 @@
*/
// configurations for tvm logging
-#define TVM_LOG_STACK_TRACE 0
#define TVM_LOG_DEBUG 0
#define TVM_LOG_CUSTOMIZE 1
#define TVM_FFI_ALWAYS_LOG_BEFORE_THROW 1