diff --git a/3rdparty/cutlass_fpA_intB_gemm b/3rdparty/cutlass_fpA_intB_gemm index 3e07e778d78f..412a22bded66 160000 --- a/3rdparty/cutlass_fpA_intB_gemm +++ b/3rdparty/cutlass_fpA_intB_gemm @@ -1 +1 @@ -Subproject commit 3e07e778d78f0fcd047533c1fdaed571a68a396f +Subproject commit 412a22bded6631d02fa40e3994a8096a5b8a6c7c diff --git a/apps/hexagon_launcher/launcher_core.cc b/apps/hexagon_launcher/launcher_core.cc index aebde97a51f4..56242082cca3 100644 --- a/apps/hexagon_launcher/launcher_core.cc +++ b/apps/hexagon_launcher/launcher_core.cc @@ -21,7 +21,6 @@ #include #include -#include #include #include diff --git a/apps/hexagon_launcher/launcher_core.h b/apps/hexagon_launcher/launcher_core.h index ae9e4108cd57..5e62774607ba 100644 --- a/apps/hexagon_launcher/launcher_core.h +++ b/apps/hexagon_launcher/launcher_core.h @@ -22,10 +22,10 @@ #include #include +#include #include #include #include -#include #include #include diff --git a/apps/ios_rpc/tvmrpc/RPCServer.mm b/apps/ios_rpc/tvmrpc/RPCServer.mm index 4717d7103254..da689d4c7064 100644 --- a/apps/ios_rpc/tvmrpc/RPCServer.mm +++ b/apps/ios_rpc/tvmrpc/RPCServer.mm @@ -24,7 +24,6 @@ #import "RPCServer.h" #include -#include #include #include diff --git a/docs/arch/runtime.rst b/docs/arch/runtime.rst index 55c523cb4cc4..f1642827cd48 100644 --- a/docs/arch/runtime.rst +++ b/docs/arch/runtime.rst @@ -52,7 +52,7 @@ The following code block provides an example in C++ .. code:: c - #include + #include void MyAdd(ffi::PackedArgs args, ffi::Any* rv) { // automatically convert arguments to desired type. diff --git a/ffi/include/tvm/ffi/any.h b/ffi/include/tvm/ffi/any.h index 7897d628988c..5b56b003e8cc 100644 --- a/ffi/include/tvm/ffi/any.h +++ b/ffi/include/tvm/ffi/any.h @@ -583,5 +583,11 @@ struct AnyEqual { }; } // namespace ffi + +// Expose to the tvm namespace for usability +// Rationale: no ambiguity even in root +using tvm::ffi::Any; +using tvm::ffi::AnyView; + } // namespace tvm #endif // TVM_FFI_ANY_H_ diff --git a/ffi/include/tvm/ffi/c_api.h b/ffi/include/tvm/ffi/c_api.h index df8265d0b9c7..996eaa369b3b 100644 --- a/ffi/include/tvm/ffi/c_api.h +++ b/ffi/include/tvm/ffi/c_api.h @@ -34,9 +34,14 @@ #define TVM_FFI_WEAK __attribute__((weak)) #endif +// Defines two macros +// TVM_FFI_DLL: marks the function as a DLL export/import +// depending on whether TVM_FFI_EXPORTS is defined +// TVM_FFI_DLL_EXPORT: always marks the function as a DLL export #if !defined(TVM_FFI_DLL) && defined(__EMSCRIPTEN__) #include #define TVM_FFI_DLL EMSCRIPTEN_KEEPALIVE +#define TVM_FFI_DLL_EXPORT EMSCRIPTEN_KEEPALIVE #endif #if !defined(TVM_FFI_DLL) && defined(_MSC_VER) #ifdef TVM_FFI_EXPORTS @@ -44,9 +49,11 @@ #else #define TVM_FFI_DLL __declspec(dllimport) #endif +#define TVM_FFI_DLL_EXPORT __declspec(dllexport) #endif #ifndef TVM_FFI_DLL #define TVM_FFI_DLL __attribute__((visibility("default"))) +#define TVM_FFI_DLL_EXPORT __attribute__((visibility("default"))) #endif #ifdef __cplusplus diff --git a/ffi/include/tvm/ffi/function.h b/ffi/include/tvm/ffi/function.h index 753d4f50f19c..128c67830e84 100644 --- a/ffi/include/tvm/ffi/function.h +++ b/ffi/include/tvm/ffi/function.h @@ -910,6 +910,54 @@ inline int32_t TypeKeyToIndex(std::string_view type_key) { #define TVM_FFI_REGISTER_GLOBAL(OpName) \ TVM_FFI_STR_CONCAT(TVM_FFI_FUNC_REG_VAR_DEF, __COUNTER__) = ::tvm::ffi::Function::Registry(OpName) +/*! + * \brief Export typed function as a SafeCallType symbol. + * + * \param ExportName The symbol name to be exported. + * \param Function The typed function. + * \note ExportName and Function must be different, + * see code examples below. + * + * \sa ffi::TypedFunction + * + * \code + * + * int AddOne_(int x) { + * return x + 1; + * } + * + * // Expose the function as "AddOne" + * TVM_FFI_DLL_EXPORT_TYPED_FUNC(AddOne, AddOne_); + * + * // Expose the function as "SubOne" + * TVM_FFI_DLL_EXPORT_TYPED_FUNC(SubOne, [](int x) { + * return x - 1; + * }); + * + * // The following code will cause compilation error. + * // Because the same Function and ExportName + * // TVM_FFI_DLL_EXPORT_TYPED_FUNC(AddOne_, AddOne_); + * + * // The following code is OK, assuming the macro + * // is in a different namespace from xyz + * // TVM_FFI_DLL_EXPORT_TYPED_FUNC(AddOne_, xyz::AddOne_); + * + * \endcode + */ +#define TVM_FFI_DLL_EXPORT_TYPED_FUNC(ExportName, Function) \ + extern "C" { \ + TVM_FFI_DLL_EXPORT int ExportName(void* self, TVMFFIAny* args, int32_t num_args, \ + TVMFFIAny* result) { \ + TVM_FFI_SAFE_CALL_BEGIN(); \ + using FuncInfo = ::tvm::ffi::details::FunctionInfo; \ + static std::string name = #ExportName; \ + ::tvm::ffi::details::unpack_call( \ + std::make_index_sequence{}, &name, Function, \ + reinterpret_cast(args), num_args, \ + reinterpret_cast<::tvm::ffi::Any*>(result)); \ + TVM_FFI_SAFE_CALL_END(); \ + } \ + } } // namespace ffi } // namespace tvm #endif // TVM_FFI_FUNCTION_H_ diff --git a/include/tvm/ir/attrs.h b/include/tvm/ir/attrs.h index dc8e99fcebd5..6378d6f74ac2 100644 --- a/include/tvm/ir/attrs.h +++ b/include/tvm/ir/attrs.h @@ -46,10 +46,10 @@ #include #include +#include #include #include #include -#include #include #include diff --git a/include/tvm/ir/env_func.h b/include/tvm/ir/env_func.h index 52fab116360c..ab5cf31c6c86 100644 --- a/include/tvm/ir/env_func.h +++ b/include/tvm/ir/env_func.h @@ -24,8 +24,8 @@ #ifndef TVM_IR_ENV_FUNC_H_ #define TVM_IR_ENV_FUNC_H_ +#include #include -#include #include #include @@ -142,8 +142,8 @@ class TypedEnvFunc : public ObjectRef { if constexpr (std::is_same_v) { n->func(std::forward(args)...); } else { - Any res = n->func(std::forward(args)...); - if constexpr (std::is_same_v) { + ffi::Any res = n->func(std::forward(args)...); + if constexpr (std::is_same_v) { return res; } else { return std::move(res).cast(); diff --git a/include/tvm/ir/source_map.h b/include/tvm/ir/source_map.h index 2752d9951a3f..83e2f4f375bf 100644 --- a/include/tvm/ir/source_map.h +++ b/include/tvm/ir/source_map.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/include/tvm/meta_schedule/builder.h b/include/tvm/meta_schedule/builder.h index 5ac1fd1753f7..24e136f9d345 100644 --- a/include/tvm/meta_schedule/builder.h +++ b/include/tvm/meta_schedule/builder.h @@ -21,13 +21,13 @@ #include #include +#include #include #include #include #include #include #include -#include #include namespace tvm { diff --git a/include/tvm/meta_schedule/cost_model.h b/include/tvm/meta_schedule/cost_model.h index a3386df5e90e..300f53e113bd 100644 --- a/include/tvm/meta_schedule/cost_model.h +++ b/include/tvm/meta_schedule/cost_model.h @@ -21,13 +21,13 @@ #define TVM_META_SCHEDULE_COST_MODEL_H_ #include +#include #include #include #include #include #include #include -#include #include #include diff --git a/include/tvm/meta_schedule/database.h b/include/tvm/meta_schedule/database.h index 15d92c4e3c2a..570da2cf0650 100644 --- a/include/tvm/meta_schedule/database.h +++ b/include/tvm/meta_schedule/database.h @@ -20,13 +20,13 @@ #define TVM_META_SCHEDULE_DATABASE_H_ #include +#include #include #include #include #include #include #include -#include #include #include #include diff --git a/include/tvm/meta_schedule/feature_extractor.h b/include/tvm/meta_schedule/feature_extractor.h index 8eecb2e58245..e45cb4eab195 100644 --- a/include/tvm/meta_schedule/feature_extractor.h +++ b/include/tvm/meta_schedule/feature_extractor.h @@ -21,12 +21,12 @@ #define TVM_META_SCHEDULE_FEATURE_EXTRACTOR_H_ #include +#include #include #include #include #include #include -#include namespace tvm { namespace meta_schedule { diff --git a/include/tvm/meta_schedule/measure_callback.h b/include/tvm/meta_schedule/measure_callback.h index 1b3bbb0f5c8a..3a3d83cbf996 100644 --- a/include/tvm/meta_schedule/measure_callback.h +++ b/include/tvm/meta_schedule/measure_callback.h @@ -21,6 +21,7 @@ #define TVM_META_SCHEDULE_MEASURE_CALLBACK_H_ #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include #include -#include namespace tvm { namespace meta_schedule { diff --git a/include/tvm/meta_schedule/mutator.h b/include/tvm/meta_schedule/mutator.h index 525c812f90d2..0f8e446784f3 100644 --- a/include/tvm/meta_schedule/mutator.h +++ b/include/tvm/meta_schedule/mutator.h @@ -20,10 +20,10 @@ #ifndef TVM_META_SCHEDULE_MUTATOR_H_ #define TVM_META_SCHEDULE_MUTATOR_H_ +#include #include #include #include -#include #include #include #include diff --git a/include/tvm/meta_schedule/postproc.h b/include/tvm/meta_schedule/postproc.h index 5a2b96caf81f..e8648f038e61 100644 --- a/include/tvm/meta_schedule/postproc.h +++ b/include/tvm/meta_schedule/postproc.h @@ -20,9 +20,9 @@ #ifndef TVM_META_SCHEDULE_POSTPROC_H_ #define TVM_META_SCHEDULE_POSTPROC_H_ +#include #include #include -#include #include namespace tvm { diff --git a/include/tvm/meta_schedule/profiler.h b/include/tvm/meta_schedule/profiler.h index b9905cf06fae..6f8072b3f367 100644 --- a/include/tvm/meta_schedule/profiler.h +++ b/include/tvm/meta_schedule/profiler.h @@ -20,12 +20,12 @@ #define TVM_META_SCHEDULE_PROFILER_H_ #include +#include #include #include #include #include #include -#include #include #include diff --git a/include/tvm/meta_schedule/runner.h b/include/tvm/meta_schedule/runner.h index 64974d16c6a6..c8331a3a60e3 100644 --- a/include/tvm/meta_schedule/runner.h +++ b/include/tvm/meta_schedule/runner.h @@ -20,13 +20,13 @@ #define TVM_META_SCHEDULE_RUNNER_H_ #include +#include #include #include #include #include #include #include -#include namespace tvm { namespace meta_schedule { diff --git a/include/tvm/meta_schedule/schedule_rule.h b/include/tvm/meta_schedule/schedule_rule.h index 2d369656b026..1a759c1b50fc 100644 --- a/include/tvm/meta_schedule/schedule_rule.h +++ b/include/tvm/meta_schedule/schedule_rule.h @@ -22,12 +22,12 @@ #include #include +#include #include #include #include #include #include -#include #include namespace tvm { diff --git a/include/tvm/meta_schedule/search_strategy.h b/include/tvm/meta_schedule/search_strategy.h index ed08f5729ec1..c0b4677f84b5 100644 --- a/include/tvm/meta_schedule/search_strategy.h +++ b/include/tvm/meta_schedule/search_strategy.h @@ -20,6 +20,7 @@ #define TVM_META_SCHEDULE_SEARCH_STRATEGY_H_ #include +#include #include #include #include @@ -28,7 +29,6 @@ #include #include #include -#include #include namespace tvm { diff --git a/include/tvm/meta_schedule/space_generator.h b/include/tvm/meta_schedule/space_generator.h index efdca187ca46..4ba3c0b089fc 100644 --- a/include/tvm/meta_schedule/space_generator.h +++ b/include/tvm/meta_schedule/space_generator.h @@ -20,13 +20,13 @@ #define TVM_META_SCHEDULE_SPACE_GENERATOR_H_ #include +#include #include #include #include #include #include #include -#include #include #include diff --git a/include/tvm/meta_schedule/task_scheduler.h b/include/tvm/meta_schedule/task_scheduler.h index 8c0e35f6396f..7bf36873b3ce 100644 --- a/include/tvm/meta_schedule/task_scheduler.h +++ b/include/tvm/meta_schedule/task_scheduler.h @@ -20,6 +20,7 @@ #define TVM_META_SCHEDULE_TASK_SCHEDULER_H_ #include +#include #include #include #include @@ -28,7 +29,6 @@ #include #include #include -#include #include #include diff --git a/include/tvm/meta_schedule/tune_context.h b/include/tvm/meta_schedule/tune_context.h index 24f06c9d5c53..9045d4188ac1 100644 --- a/include/tvm/meta_schedule/tune_context.h +++ b/include/tvm/meta_schedule/tune_context.h @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -31,7 +32,6 @@ #include #include #include -#include #include #include diff --git a/include/tvm/node/reflection.h b/include/tvm/node/reflection.h index ab197078f317..e56639570e37 100644 --- a/include/tvm/node/reflection.h +++ b/include/tvm/node/reflection.h @@ -24,6 +24,7 @@ #define TVM_NODE_REFLECTION_H_ #include +#include #include #include #include @@ -31,7 +32,6 @@ #include #include #include -#include #include #include @@ -164,7 +164,7 @@ class ReflectionVTable { * \param kwargs The field arguments. * \return The created object. */ - TVM_DLL ObjectRef CreateObject(const std::string& type_key, const Map& kwargs); + TVM_DLL ObjectRef CreateObject(const std::string& type_key, const Map& kwargs); /*! * \brief Get an field object by the attr name. * \param self The pointer to the object. diff --git a/include/tvm/node/script_printer.h b/include/tvm/node/script_printer.h index 5ee6b177f0f2..721ae0932cdd 100644 --- a/include/tvm/node/script_printer.h +++ b/include/tvm/node/script_printer.h @@ -23,6 +23,7 @@ #ifndef TVM_NODE_SCRIPT_PRINTER_H_ #define TVM_NODE_SCRIPT_PRINTER_H_ +#include #include #include #include @@ -151,7 +152,7 @@ class PrinterConfigNode : public Object { class PrinterConfig : public ObjectRef { public: - explicit PrinterConfig(Map config_dict = Map()); + explicit PrinterConfig(Map config_dict = Map()); TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(PrinterConfig, runtime::ObjectRef, PrinterConfigNode); diff --git a/include/tvm/relax/dataflow_matcher.h b/include/tvm/relax/dataflow_matcher.h index d5a0de049303..80359135c200 100644 --- a/include/tvm/relax/dataflow_matcher.h +++ b/include/tvm/relax/dataflow_matcher.h @@ -24,9 +24,9 @@ #ifndef TVM_RELAX_DATAFLOW_MATCHER_H_ #define TVM_RELAX_DATAFLOW_MATCHER_H_ +#include #include #include -#include #include diff --git a/include/tvm/runtime/disco/disco_worker.h b/include/tvm/runtime/disco/disco_worker.h index c7aeb4e284ad..078c061b7b82 100644 --- a/include/tvm/runtime/disco/disco_worker.h +++ b/include/tvm/runtime/disco/disco_worker.h @@ -25,8 +25,8 @@ #ifndef TVM_RUNTIME_DISCO_DISCO_WORKER_H_ #define TVM_RUNTIME_DISCO_DISCO_WORKER_H_ +#include #include -#include #include diff --git a/include/tvm/runtime/disco/session.h b/include/tvm/runtime/disco/session.h index 9d213312c88c..0c1ed7ca0aaf 100644 --- a/include/tvm/runtime/disco/session.h +++ b/include/tvm/runtime/disco/session.h @@ -72,9 +72,10 @@ #ifndef TVM_RUNTIME_DISCO_SESSION_H_ #define TVM_RUNTIME_DISCO_SESSION_H_ +#include #include +#include #include -#include #include #include @@ -243,7 +244,7 @@ class SessionObj : public Object { * \param value The value to be set. * \param worker_id The id of the worker to be set. */ - TVM_DLL virtual void DebugSetRegister(int64_t reg_id, AnyView value, int worker_id) = 0; + TVM_DLL virtual void DebugSetRegister(int64_t reg_id, ffi::AnyView value, int worker_id) = 0; struct FFI; friend struct SessionObj::FFI; @@ -338,7 +339,7 @@ template DRef SessionObj::CallPacked(const DRef& func, Args&&... args) { constexpr int offset = 3; constexpr int kNumArgs = offset + sizeof...(Args); - AnyView packed_args[kNumArgs]; + ffi::AnyView packed_args[kNumArgs]; ffi::PackedArgs::Fill(packed_args, /*.0=*/static_cast(DiscoAction::kCallPacked), // action /*.1=*/0, // reg_id, which will be updated by this->CallWithPacked diff --git a/include/tvm/runtime/module.h b/include/tvm/runtime/module.h index c02e312b71a0..705fb276d9e7 100644 --- a/include/tvm/runtime/module.h +++ b/include/tvm/runtime/module.h @@ -37,6 +37,7 @@ #include #include #include +#include #include namespace tvm { @@ -325,8 +326,80 @@ inline std::ostream& operator<<(std::ostream& out, const Module& module) { return out; } +namespace details { + +template +struct ModuleVTableEntryHelper {}; + +template +struct ModuleVTableEntryHelper { + using MemFnType = R (T::*)(Args...) const; + static TVM_ALWAYS_INLINE 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)...); }; + ffi::details::unpack_call(std::make_index_sequence{}, nullptr, wrapped, + args.data(), args.size(), rv); + } +}; + +template +struct ModuleVTableEntryHelper { + using MemFnType = R (T::*)(Args...); + static TVM_ALWAYS_INLINE 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)...); }; + ffi::details::unpack_call(std::make_index_sequence{}, nullptr, wrapped, + args.data(), args.size(), rv); + } +}; + +template +struct ModuleVTableEntryHelper { + using MemFnType = void (T::*)(Args...) const; + static TVM_ALWAYS_INLINE void Call(ffi::Any* rv, T* self, MemFnType f, ffi::PackedArgs args) { + auto wrapped = [self, f](Args... args) -> void { (self->*f)(std::forward(args)...); }; + ffi::details::unpack_call(std::make_index_sequence{}, nullptr, wrapped, + args.data(), args.size(), rv); + } +}; + +template +struct ModuleVTableEntryHelper { + using MemFnType = void (T::*)(Args...); + static TVM_ALWAYS_INLINE void Call(ffi::Any* rv, T* self, MemFnType f, ffi::PackedArgs args) { + auto wrapped = [self, f](Args... args) -> void { (self->*f)(std::forward(args)...); }; + ffi::details::unpack_call(std::make_index_sequence{}, nullptr, wrapped, + args.data(), args.size(), rv); + } +}; +} // namespace details } // namespace runtime } // namespace tvm -#include // NOLINT(*) -#endif // TVM_RUNTIME_MODULE_H_ +#define TVM_MODULE_VTABLE_BEGIN(TypeKey) \ + const char* type_key() const final { return TypeKey; } \ + ffi::Function GetFunction(const String& _name, const ObjectPtr& _self) override { \ + using SelfPtr = std::remove_cv_t; +#define TVM_MODULE_VTABLE_END() \ + return ffi::Function(nullptr); \ + } +#define TVM_MODULE_VTABLE_END_WITH_DEFAULT(MemFunc) \ + { \ + auto f = (MemFunc); \ + return (this->*f)(_name); \ + } \ + } // NOLINT(*) +#define TVM_MODULE_VTABLE_ENTRY(Name, MemFunc) \ + if (_name == Name) { \ + return ffi::Function::FromPacked([_self](ffi::PackedArgs args, ffi::Any* rv) -> void { \ + using Helper = ::tvm::runtime::details::ModuleVTableEntryHelper; \ + SelfPtr self = static_cast(_self.get()); \ + Helper::Call(rv, self, MemFunc, args); \ + }); \ + } +#define TVM_MODULE_VTABLE_ENTRY_PACKED(Name, MemFunc) \ + if (_name == Name) { \ + return ffi::Function([_self](ffi::PackedArgs args, ffi::Any* rv) -> void { \ + (static_cast(_self.get())->*(MemFunc))(args, rv); \ + }); \ + } + +#endif // TVM_RUNTIME_MODULE_H_ diff --git a/include/tvm/runtime/packed_func.h b/include/tvm/runtime/packed_func.h index 6da06c119171..3f8ec66bc1d3 100644 --- a/include/tvm/runtime/packed_func.h +++ b/include/tvm/runtime/packed_func.h @@ -26,145 +26,16 @@ #include #include -#include -#include -#include -#include - -#include -#include -#include namespace tvm { namespace runtime { -using ffi::Any; -using ffi::AnyView; - -namespace details { - -template -struct ModuleVTableEntryHelper {}; - -template -struct ModuleVTableEntryHelper { - using MemFnType = R (T::*)(Args...) const; - static TVM_ALWAYS_INLINE 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)...); }; - ffi::details::unpack_call(std::make_index_sequence{}, nullptr, wrapped, - args.data(), args.size(), rv); - } -}; +#define TVM_DLL_EXPORT_TYPED_FUNC TVM_FFI_DLL_EXPORT_TYPED_FUNC -template -struct ModuleVTableEntryHelper { - using MemFnType = R (T::*)(Args...); - static TVM_ALWAYS_INLINE 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)...); }; - ffi::details::unpack_call(std::make_index_sequence{}, nullptr, wrapped, - args.data(), args.size(), rv); - } -}; - -template -struct ModuleVTableEntryHelper { - using MemFnType = void (T::*)(Args...) const; - static TVM_ALWAYS_INLINE void Call(ffi::Any* rv, T* self, MemFnType f, ffi::PackedArgs args) { - auto wrapped = [self, f](Args... args) -> void { (self->*f)(std::forward(args)...); }; - ffi::details::unpack_call(std::make_index_sequence{}, nullptr, wrapped, - args.data(), args.size(), rv); - } -}; - -template -struct ModuleVTableEntryHelper { - using MemFnType = void (T::*)(Args...); - static TVM_ALWAYS_INLINE void Call(ffi::Any* rv, T* self, MemFnType f, ffi::PackedArgs args) { - auto wrapped = [self, f](Args... args) -> void { (self->*f)(std::forward(args)...); }; - ffi::details::unpack_call(std::make_index_sequence{}, nullptr, wrapped, - args.data(), args.size(), rv); - } -}; -} // namespace details - -#define TVM_MODULE_VTABLE_BEGIN(TypeKey) \ - const char* type_key() const final { return TypeKey; } \ - ffi::Function GetFunction(const String& _name, const ObjectPtr& _self) override { \ - using SelfPtr = std::remove_cv_t; -#define TVM_MODULE_VTABLE_END() \ - return ffi::Function(nullptr); \ - } -#define TVM_MODULE_VTABLE_END_WITH_DEFAULT(MemFunc) \ - { \ - auto f = (MemFunc); \ - return (this->*f)(_name); \ - } \ - } // NOLINT(*) -#define TVM_MODULE_VTABLE_ENTRY(Name, MemFunc) \ - if (_name == Name) { \ - return ffi::Function::FromPacked([_self](ffi::PackedArgs args, Any* rv) -> void { \ - using Helper = ::tvm::runtime::details::ModuleVTableEntryHelper; \ - SelfPtr self = static_cast(_self.get()); \ - Helper::Call(rv, self, MemFunc, args); \ - }); \ - } -#define TVM_MODULE_VTABLE_ENTRY_PACKED(Name, MemFunc) \ - if (_name == Name) { \ - return ffi::Function([_self](ffi::PackedArgs args, Any* rv) -> void { \ - (static_cast(_self.get())->*(MemFunc))(args, rv); \ - }); \ - } - -/*! - * \brief Export typed function as a ffi::Function - * that can be loaded by LibraryModule. - * - * \param ExportName The symbol name to be exported. - * \param Function The typed function. - * \note ExportName and Function must be different, - * see code examples below. - * - * \sa ffi::TypedFunction - * - * \code - * - * int AddOne_(int x) { - * return x + 1; - * } - * - * // Expose the function as "AddOne" - * TVM_DLL_EXPORT_TYPED_FUNC(AddOne, AddOne_); - * - * // Expose the function as "SubOne" - * TVM_DLL_EXPORT_TYPED_FUNC(SubOne, [](int x) { - * return x - 1; - * }); - * - * // The following code will cause compilation error. - * // Because the same Function and ExportName - * // TVM_DLL_EXPORT_TYPED_FUNC(AddOne_, AddOne_); - * - * // The following code is OK, assuming the macro - * // is in a different namespace from xyz - * // TVM_DLL_EXPORT_TYPED_FUNC(AddOne_, xyz::AddOne_); - * - * \endcode - */ -#define TVM_DLL_EXPORT_TYPED_FUNC(ExportName, Function) \ - extern "C" { \ - TVM_DLL int ExportName(void* self, TVMFFIAny* args, int32_t num_args, TVMFFIAny* result) { \ - TVM_FFI_SAFE_CALL_BEGIN(); \ - using FuncInfo = ::tvm::ffi::details::FunctionInfo; \ - static std::string name = #ExportName; \ - ::tvm::ffi::details::unpack_call( \ - std::make_index_sequence{}, &name, Function, \ - reinterpret_cast(args), num_args, \ - reinterpret_cast<::tvm::ffi::Any*>(result)); \ - TVM_FFI_SAFE_CALL_END(); \ - } \ - } -} // namespace runtime // NOLINT(*) using ffi::Any; using ffi::AnyView; + +} // namespace runtime } // namespace tvm + #endif // TVM_RUNTIME_PACKED_FUNC_H_ diff --git a/include/tvm/runtime/profiling.h b/include/tvm/runtime/profiling.h index 1e950f9f7a95..2a6ecc0e4d43 100644 --- a/include/tvm/runtime/profiling.h +++ b/include/tvm/runtime/profiling.h @@ -29,8 +29,9 @@ #include #include #include +#include +#include #include -#include #include #include diff --git a/include/tvm/runtime/relax_vm/executable.h b/include/tvm/runtime/relax_vm/executable.h index afaaea9e41e7..8a9fa024cab2 100644 --- a/include/tvm/runtime/relax_vm/executable.h +++ b/include/tvm/runtime/relax_vm/executable.h @@ -24,8 +24,8 @@ #define TVM_RUNTIME_RELAX_VM_EXECUTABLE_H_ #include +#include #include -#include #include #include diff --git a/include/tvm/runtime/relax_vm/vm.h b/include/tvm/runtime/relax_vm/vm.h index ce69548d7016..884a8d0f4375 100644 --- a/include/tvm/runtime/relax_vm/vm.h +++ b/include/tvm/runtime/relax_vm/vm.h @@ -155,7 +155,7 @@ class VirtualMachine : public runtime::ModuleNode { * \param rv The return value. */ virtual void InvokeClosurePacked(const ObjectRef& closure_or_packedfunc, ffi::PackedArgs args, - Any* rv) = 0; + ffi::Any* rv) = 0; /*! * \brief Set an instrumentation function. * diff --git a/include/tvm/script/printer/ir_docsifier_functor.h b/include/tvm/script/printer/ir_docsifier_functor.h index 40bb245e72f3..62133ef2c9da 100644 --- a/include/tvm/script/printer/ir_docsifier_functor.h +++ b/include/tvm/script/printer/ir_docsifier_functor.h @@ -19,9 +19,9 @@ #ifndef TVM_SCRIPT_PRINTER_IR_DOCSIFIER_FUNCTOR_H_ #define TVM_SCRIPT_PRINTER_IR_DOCSIFIER_FUNCTOR_H_ +#include #include #include -#include #include #include diff --git a/include/tvm/support/span.h b/include/tvm/support/span.h deleted file mode 100644 index 768252f77ce9..000000000000 --- a/include/tvm/support/span.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/*! - * - * \file tvm/support/span.h - * \brief Reimplementation of part of C++-20 style span. - */ -#ifndef TVM_SUPPORT_SPAN_H_ -#define TVM_SUPPORT_SPAN_H_ - -#include -#include -#include -#include - -namespace tvm { -namespace support { - -/*! - * \brief A partial implementation of the C++20 std::span. - * - * At the time of writing, TVM must compile against C++17. - */ -template -class Span { - public: - using value_type = W; - using const_W = typename std::add_const::type; - - template - class iterator_base { - public: - using iterator_category = std::input_iterator_tag; - using value_type = W; - using difference_type = std::ptrdiff_t; - using pointer = const W*; - using reference = const W&; - - inline iterator_base(T* ptr, T* end) : ptr_{ptr}, end_{end} { CHECK_GE(end, ptr); } - - inline W1 operator*() { return W1(*ptr_); } - - inline iterator_base& operator++() { - if (ptr_ != end_) ptr_++; - return *this; - } - - inline bool operator==(iterator_base other) { - return ptr_ == other.ptr_ && end_ == other.end_; - } - - inline bool operator!=(iterator_base other) { return !(*this == other); } - - template ::value>> - inline operator iterator_base() const { - return iterator_base(ptr_, end_); - } - - private: - T* ptr_; - T* end_; - }; - - using iterator = iterator_base; - using const_iterator = iterator_base; - - inline Span(T* begin, int num_elements) : begin_{begin}, end_{begin + num_elements} {} - inline Span(T* begin, T* end) : begin_{begin}, end_{end} {} - - inline iterator begin() const { return iterator(begin_, end_); } - - inline iterator end() const { return iterator(end_, end_); } - - size_t size() const { return end_ - begin_; } - - inline W operator[](int i) { - T* to_return = begin_ + i; - ICHECK_LT(to_return, end_) << "Span access out of bounds: " << i; - return W(*to_return); - } - - inline operator std::vector() { return std::vector(begin(), end()); } - - protected: - T* begin_; - T* end_; -}; - -} // namespace support -} // namespace tvm - -#endif // TVM_SUPPORT_SPAN_H_ diff --git a/include/tvm/target/codegen.h b/include/tvm/target/codegen.h index faa58f84870a..54f09a081b93 100644 --- a/include/tvm/target/codegen.h +++ b/include/tvm/target/codegen.h @@ -25,7 +25,7 @@ #define TVM_TARGET_CODEGEN_H_ #include -#include +#include #include #include diff --git a/include/tvm/tir/op_attr_types.h b/include/tvm/tir/op_attr_types.h index 29877b145802..883477dd645e 100644 --- a/include/tvm/tir/op_attr_types.h +++ b/include/tvm/tir/op_attr_types.h @@ -28,9 +28,9 @@ #ifndef TVM_TIR_OP_ATTR_TYPES_H_ #define TVM_TIR_OP_ATTR_TYPES_H_ +#include #include #include -#include #include diff --git a/include/tvm/topi/utils.h b/include/tvm/topi/utils.h index 23ac27d13426..b5f2d6c38d61 100644 --- a/include/tvm/topi/utils.h +++ b/include/tvm/topi/utils.h @@ -24,8 +24,8 @@ #ifndef TVM_TOPI_UTILS_H_ #define TVM_TOPI_UTILS_H_ +#include #include -#include namespace tvm { namespace topi { diff --git a/python/tvm/relax/frontend/nn/extern.py b/python/tvm/relax/frontend/nn/extern.py index d89369c718b2..e7248b0f4b27 100644 --- a/python/tvm/relax/frontend/nn/extern.py +++ b/python/tvm/relax/frontend/nn/extern.py @@ -135,14 +135,14 @@ def shape_dtype_inference(a, b): of in-memory representation of tensors. More details: https://github.com/dmlc/dlpack/blob/v0.8/include/dlpack/dlpack.h#L163-L206. - To expose the symbol, `TVM_DLL_EXPORT_TYPED_FUNC(symbol, function)` is guaranteed available: + To expose the symbol, `TVM_FFI_DLL_EXPORT_TYPED_FUNC(symbol, function)` is guaranteed available: .. code-block:: C++ // those headers are guaranteed to be available #include #include - #include + #include namespace { // anonymous namespace hides the symbol `_my_func_impl` from other translation units @@ -151,7 +151,7 @@ def shape_dtype_inference(a, b): } } // expose symbol `my_func` instead of `_my_func_impl` - TVM_DLL_EXPORT_TYPED_FUNC(my_func, _my_func_impl); + TVM_FFI_DLL_EXPORT_TYPED_FUNC(my_func, _my_func_impl); **A compiler pass `AttachExternModules`.** It is introduced to attach a list of `nn.ExternModule`s into an IRModule at any stage of the compilation pipeline, diff --git a/src/ir/op.cc b/src/ir/op.cc index 4917f8336b1d..b6d1f39526db 100644 --- a/src/ir/op.cc +++ b/src/ir/op.cc @@ -21,10 +21,10 @@ * \file src/ir/op.cc * \brief Primitive operators and intrinsics. */ +#include #include #include #include -#include #include #include diff --git a/src/node/attr_registry.h b/src/node/attr_registry.h index 9ec39e9f6aae..334c15b3be97 100644 --- a/src/node/attr_registry.h +++ b/src/node/attr_registry.h @@ -24,8 +24,8 @@ #ifndef TVM_NODE_ATTR_REGISTRY_H_ #define TVM_NODE_ATTR_REGISTRY_H_ +#include #include -#include #include #include diff --git a/src/node/serialization.cc b/src/node/serialization.cc index 631d70e2356c..986a2d044524 100644 --- a/src/node/serialization.cc +++ b/src/node/serialization.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include #include diff --git a/src/relax/backend/contrib/codegen_c/codegen_c.h b/src/relax/backend/contrib/codegen_c/codegen_c.h index ce26e94cb7f5..28ca0e3586e8 100644 --- a/src/relax/backend/contrib/codegen_c/codegen_c.h +++ b/src/relax/backend/contrib/codegen_c/codegen_c.h @@ -130,14 +130,14 @@ class CodegenCBase { * return 0; * } * - * TVM_DLL_EXPORT_TYPED_FUNC(foo, foo_wrapper_); + * TVM_FFI_DLL_EXPORT_TYPED_FUNC(foo, foo_wrapper_); * * int foo_init_wrapper_(Array arr) { * foo_consts = arr; * return 0; * } * - * TVM_DLL_EXPORT_TYPED_FUNC(__init_foo, foo_init_wrapper_); + * TVM_FFI_DLL_EXPORT_TYPED_FUNC(__init_foo, foo_init_wrapper_); * * \endcode */ @@ -230,7 +230,7 @@ class CodegenCBase { code_stream_ << "return 0;\n"; ExitScope(); code_stream_ << "}\n\n"; - code_stream_ << "TVM_DLL_EXPORT_TYPED_FUNC(__init_" << func_name << ", " << func_name + code_stream_ << "TVM_FFI_DLL_EXPORT_TYPED_FUNC(__init_" << func_name << ", " << func_name << "_init_wrapper_);\n\n"; code_stream_ << "#endif\n"; } diff --git a/src/relax/backend/contrib/cutlass/codegen.cc b/src/relax/backend/contrib/cutlass/codegen.cc index a05907a23127..8dee9b24f493 100644 --- a/src/relax/backend/contrib/cutlass/codegen.cc +++ b/src/relax/backend/contrib/cutlass/codegen.cc @@ -21,12 +21,12 @@ * \file src/relax/backend/contrib/cutlass/codegen.cc * \brief Implementation of the CUTLASS code generator for Relax. */ - #include #include #include #include #include +#include #include #include @@ -59,7 +59,7 @@ runtime::Module Finalize(const std::string& code, const Array& func_name << "Should only create CUTLASS CSourceModule if there is at least one CUTLASS partition"; std::ostringstream default_headers; - default_headers << "#include \n"; + default_headers << "#include \n"; default_headers << "#include \n"; default_headers << "#include \n"; default_headers << "#include \n"; diff --git a/src/relax/transform/fold_constant.cc b/src/relax/transform/fold_constant.cc index c2bac5daa7f2..7fec51086514 100644 --- a/src/relax/transform/fold_constant.cc +++ b/src/relax/transform/fold_constant.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include #include diff --git a/src/relax/transform/run_codegen.cc b/src/relax/transform/run_codegen.cc index 7556f2690307..d29bdaacb9b0 100644 --- a/src/relax/transform/run_codegen.cc +++ b/src/relax/transform/run_codegen.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include "../../support/ordered_set.h" #include "utils.h" diff --git a/src/runtime/const_loader_module.cc b/src/runtime/const_loader_module.cc index 50b504d17c46..84cd4943c552 100644 --- a/src/runtime/const_loader_module.cc +++ b/src/runtime/const_loader_module.cc @@ -31,8 +31,8 @@ #include #include #include +#include #include -#include #include diff --git a/src/runtime/contrib/amx/amx_config.cc b/src/runtime/contrib/amx/amx_config.cc index da5ae3f62cb3..1eb63a10fa4c 100644 --- a/src/runtime/contrib/amx/amx_config.cc +++ b/src/runtime/contrib/amx/amx_config.cc @@ -22,7 +22,6 @@ * \brief extraction of AMX configuration on x86 platforms */ #include -#include namespace tvm { namespace runtime { diff --git a/src/runtime/contrib/coreml/coreml_runtime.h b/src/runtime/contrib/coreml/coreml_runtime.h index b3f7e846e0ec..5f5eec1d03ca 100644 --- a/src/runtime/contrib/coreml/coreml_runtime.h +++ b/src/runtime/contrib/coreml/coreml_runtime.h @@ -29,8 +29,8 @@ #import #include +#include #include -#include #include #include diff --git a/src/runtime/contrib/cutlass/fp16_group_gemm.cu b/src/runtime/contrib/cutlass/fp16_group_gemm.cu index b1e152b1b064..dffe7dc4ffed 100644 --- a/src/runtime/contrib/cutlass/fp16_group_gemm.cu +++ b/src/runtime/contrib/cutlass/fp16_group_gemm.cu @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include "group_gemm_runner.cuh" diff --git a/src/runtime/contrib/cutlass/fp8_blockwise_scaled_gemm.cu b/src/runtime/contrib/cutlass/fp8_blockwise_scaled_gemm.cu index d9bd0a33ee25..b8732357c7bd 100644 --- a/src/runtime/contrib/cutlass/fp8_blockwise_scaled_gemm.cu +++ b/src/runtime/contrib/cutlass/fp8_blockwise_scaled_gemm.cu @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include "../cublas/cublas_utils.h" diff --git a/src/runtime/contrib/cutlass/fp8_gemm.cu b/src/runtime/contrib/cutlass/fp8_gemm.cu index 5146e62d8c5d..4ee31e73abca 100644 --- a/src/runtime/contrib/cutlass/fp8_gemm.cu +++ b/src/runtime/contrib/cutlass/fp8_gemm.cu @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include "../cublas/cublas_utils.h" diff --git a/src/runtime/contrib/cutlass/fp8_group_gemm.cu b/src/runtime/contrib/cutlass/fp8_group_gemm.cu index 104010f4c8ab..62a91dec1809 100644 --- a/src/runtime/contrib/cutlass/fp8_group_gemm.cu +++ b/src/runtime/contrib/cutlass/fp8_group_gemm.cu @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include "group_gemm_runner.cuh" diff --git a/src/runtime/contrib/cutlass/weight_preprocess.cc b/src/runtime/contrib/cutlass/weight_preprocess.cc index 7cc053712b86..5fece6166158 100644 --- a/src/runtime/contrib/cutlass/weight_preprocess.cc +++ b/src/runtime/contrib/cutlass/weight_preprocess.cc @@ -19,7 +19,6 @@ #include #include -#include #include "cutlass_kernels/cutlass_preprocessors.h" diff --git a/src/runtime/contrib/mrvl/mrvl_sw_runtime_lib.h b/src/runtime/contrib/mrvl/mrvl_sw_runtime_lib.h index c5242a4e7bde..10114802b4bf 100644 --- a/src/runtime/contrib/mrvl/mrvl_sw_runtime_lib.h +++ b/src/runtime/contrib/mrvl/mrvl_sw_runtime_lib.h @@ -25,7 +25,7 @@ #ifndef TVM_RUNTIME_CONTRIB_MRVL_MRVL_SW_RUNTIME_LIB_H_ #define TVM_RUNTIME_CONTRIB_MRVL_MRVL_SW_RUNTIME_LIB_H_ -#include +#include #include #include diff --git a/src/runtime/contrib/mscclpp/allreduce.cu b/src/runtime/contrib/mscclpp/allreduce.cu index a5bebbc56167..66a6a097f650 100644 --- a/src/runtime/contrib/mscclpp/allreduce.cu +++ b/src/runtime/contrib/mscclpp/allreduce.cu @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include "msccl.cuh" diff --git a/src/runtime/contrib/nvshmem/init.cc b/src/runtime/contrib/nvshmem/init.cc index 090457829e69..7b4a617a2501 100644 --- a/src/runtime/contrib/nvshmem/init.cc +++ b/src/runtime/contrib/nvshmem/init.cc @@ -21,7 +21,6 @@ #include #include #include -#include #include "../../cuda/cuda_common.h" diff --git a/src/runtime/contrib/nvshmem/memory_allocator.cc b/src/runtime/contrib/nvshmem/memory_allocator.cc index 86427eaa60dd..facfc9521741 100644 --- a/src/runtime/contrib/nvshmem/memory_allocator.cc +++ b/src/runtime/contrib/nvshmem/memory_allocator.cc @@ -20,7 +20,6 @@ #include #include #include -#include #include diff --git a/src/runtime/contrib/tflite/tflite_runtime.h b/src/runtime/contrib/tflite/tflite_runtime.h index 6557fa07975e..5e8751a01281 100644 --- a/src/runtime/contrib/tflite/tflite_runtime.h +++ b/src/runtime/contrib/tflite/tflite_runtime.h @@ -27,8 +27,9 @@ #include #include +#include +#include #include -#include #include #include diff --git a/src/runtime/contrib/vllm/attention_kernels.cu b/src/runtime/contrib/vllm/attention_kernels.cu index 15e57bd297d4..9221f4672511 100644 --- a/src/runtime/contrib/vllm/attention_kernels.cu +++ b/src/runtime/contrib/vllm/attention_kernels.cu @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include diff --git a/src/runtime/contrib/vllm/cache_kernels.cu b/src/runtime/contrib/vllm/cache_kernels.cu index d762010427d4..01320daac650 100644 --- a/src/runtime/contrib/vllm/cache_kernels.cu +++ b/src/runtime/contrib/vllm/cache_kernels.cu @@ -17,7 +17,7 @@ * under the License. */ #include -#include +#include #include #include diff --git a/src/runtime/cuda/cuda_common.h b/src/runtime/cuda/cuda_common.h index 037dd9426209..a378e53c54a5 100644 --- a/src/runtime/cuda/cuda_common.h +++ b/src/runtime/cuda/cuda_common.h @@ -25,7 +25,7 @@ #define TVM_RUNTIME_CUDA_CUDA_COMMON_H_ #include -#include +#include #include diff --git a/src/runtime/debug_compile.cc b/src/runtime/debug_compile.cc index 483b8cdb592b..4b22e2649462 100644 --- a/src/runtime/debug_compile.cc +++ b/src/runtime/debug_compile.cc @@ -25,11 +25,11 @@ #include #include #include +#include #include #include #include #include -#include // #include // #include @@ -37,7 +37,7 @@ // #include // #include -// #include +// #include // #include // #include diff --git a/src/runtime/device_api.cc b/src/runtime/device_api.cc index a80d6ebdbda6..3e3145c32f5c 100644 --- a/src/runtime/device_api.cc +++ b/src/runtime/device_api.cc @@ -18,9 +18,10 @@ */ /*! - * \file c_runtime_api.cc + * \file device_api.cc * \brief Device specific implementations */ +#include #include #include #include @@ -28,7 +29,7 @@ #include #include #include -#include +#include #include #include @@ -144,7 +145,7 @@ void DeviceAPI::CopyDataFromTo(DLTensor* from, DLTensor* to, TVMStreamHandle str size_t nbytes = GetDataSize(*from); ICHECK_EQ(nbytes, GetDataSize(*to)); - ICHECK(IsContiguous(*from) && IsContiguous(*to)) + ICHECK(ffi::IsContiguous(*from) && ffi::IsContiguous(*to)) << "CopyDataFromTo only support contiguous array for now"; CopyDataFromTo(from->data, from->byte_offset, to->data, to->byte_offset, nbytes, from->device, to->device, from->dtype, stream); diff --git a/src/runtime/disco/bcast_session.cc b/src/runtime/disco/bcast_session.cc index 034a1cf56524..46ecb49f50fc 100644 --- a/src/runtime/disco/bcast_session.cc +++ b/src/runtime/disco/bcast_session.cc @@ -20,7 +20,6 @@ #include #include -#include #include @@ -32,7 +31,7 @@ struct BcastSessionObj::Internal { static void TVM_ALWAYS_INLINE BroadcastUnpacked(BcastSessionObj* self, DiscoAction action, int64_t reg_id, Args&&... args) { constexpr int kNumArgs = 2 + sizeof...(Args); - AnyView packed_args[kNumArgs]; + ffi::AnyView packed_args[kNumArgs]; ffi::PackedArgs::Fill(packed_args, static_cast(action), reg_id, std::forward(args)...); self->BroadcastPacked(ffi::PackedArgs(packed_args, kNumArgs)); @@ -88,7 +87,7 @@ void BcastSessionObj::SyncWorker(int worker_id) { DRef BcastSessionObj::CallWithPacked(const ffi::PackedArgs& args) { // NOTE: this action is not safe unless we know args is not // used else where in this case it is oK - AnyView* args_vec = const_cast(args.data()); + ffi::AnyView* args_vec = const_cast(args.data()); // tranlsate args into remote calling convention int reg_id = AllocateReg(); { diff --git a/src/runtime/disco/bcast_session.h b/src/runtime/disco/bcast_session.h index bfb1ca24b565..f92369d85337 100644 --- a/src/runtime/disco/bcast_session.h +++ b/src/runtime/disco/bcast_session.h @@ -43,7 +43,7 @@ class BcastSessionObj : public SessionObj { void Shutdown() override; void InitCCL(String ccl, IntTuple device_ids) override; ffi::Any DebugGetFromRemote(int64_t reg_id, int worker_id) override = 0; - void DebugSetRegister(int64_t reg_id, AnyView value, int worker_id) override = 0; + void DebugSetRegister(int64_t reg_id, ffi::AnyView value, int worker_id) override = 0; protected: /*! \brief Deallocate a register id, kill it on all workers, and append it to `free_regs_`. */ diff --git a/src/runtime/disco/builtin.cc b/src/runtime/disco/builtin.cc index b3d04d1d5b6b..7c769b7dd081 100644 --- a/src/runtime/disco/builtin.cc +++ b/src/runtime/disco/builtin.cc @@ -22,7 +22,6 @@ #include #include #include -#include #include #include diff --git a/src/runtime/disco/disco_worker.cc b/src/runtime/disco/disco_worker.cc index b01d378c447f..8e63355283a8 100644 --- a/src/runtime/disco/disco_worker.cc +++ b/src/runtime/disco/disco_worker.cc @@ -20,7 +20,6 @@ #include #include #include -#include #include "../../support/process_id.h" #include "./protocol.h" @@ -34,7 +33,7 @@ TVM_DLL DiscoWorker* DiscoWorker::ThreadLocal() { return ret; } -void DiscoWorker::SetRegister(int reg_id, AnyView value) { +void DiscoWorker::SetRegister(int reg_id, ffi::AnyView value) { ICHECK(0 <= reg_id && reg_id < static_cast(register_file.size())); ffi::Any& rv = register_file.at(reg_id); if (rv.type_index() == ffi::TypeIndex::kTVMFFINDArray && @@ -95,7 +94,7 @@ struct DiscoWorker::Impl { } case DiscoAction::kDebugSetRegister: { int worker_id = args[2].cast(); - AnyView value = args[3]; + ffi::AnyView value = args[3]; DebugSetRegister(self, reg_id, worker_id, value); break; } @@ -139,7 +138,7 @@ struct DiscoWorker::Impl { static void SyncWorker(DiscoWorker* self, int worker_id) { if (worker_id == self->worker_id) { ::tvm::runtime::SyncWorker(); - AnyView packed_args[2]; + ffi::AnyView packed_args[2]; ffi::PackedArgs::Fill(packed_args, static_cast(DiscoAction::kSyncWorker), worker_id); self->channel->Reply(ffi::PackedArgs(packed_args, 2)); } @@ -151,17 +150,17 @@ struct DiscoWorker::Impl { if (rv.as()) { rv = DiscoDebugObject::Wrap(rv); } - AnyView packed_args[2]; + ffi::AnyView packed_args[2]; ffi::PackedArgs::Fill(packed_args, static_cast(DiscoAction::kDebugGetFromRemote), rv); self->channel->Reply(ffi::PackedArgs(packed_args, 2)); } } - static void DebugSetRegister(DiscoWorker* self, int reg_id, int worker_id, AnyView value) { + static void DebugSetRegister(DiscoWorker* self, int reg_id, int worker_id, ffi::AnyView value) { if (worker_id == self->worker_id) { ::tvm::runtime::SyncWorker(); self->SetRegister(reg_id, value); - AnyView packed_args[1]; + ffi::AnyView packed_args[1]; ffi::PackedArgs::Fill(packed_args, static_cast(DiscoAction::kDebugSetRegister)); self->channel->Reply(ffi::PackedArgs(packed_args, 1)); } @@ -171,7 +170,7 @@ struct DiscoWorker::Impl { const ffi::PackedArgs& args) { // NOTE: this action is not safe unless we know args is not // used else where in this case it is oK - AnyView* args_vec = const_cast(args.data()); + ffi::AnyView* args_vec = const_cast(args.data()); // translate args into remote calling convention for (int i = 0; i < args.size(); ++i) { if (auto opt_dref = args_vec[i].as()) { diff --git a/src/runtime/disco/disco_worker_thread.h b/src/runtime/disco/disco_worker_thread.h index 8d6b44396f4d..99960201b9e2 100644 --- a/src/runtime/disco/disco_worker_thread.h +++ b/src/runtime/disco/disco_worker_thread.h @@ -25,9 +25,9 @@ #ifndef TVM_RUNTIME_DISCO_DISCO_WORKER_THREAD_H_ #define TVM_RUNTIME_DISCO_DISCO_WORKER_THREAD_H_ +#include #include #include -#include #include #include diff --git a/src/runtime/disco/loader.cc b/src/runtime/disco/loader.cc index 59624ac0bfb1..f93170d02f07 100644 --- a/src/runtime/disco/loader.cc +++ b/src/runtime/disco/loader.cc @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -218,7 +217,7 @@ NDArray ShardLoaderObj::ApplyShardFunc(const ShardInfo::ShardFunc& shard_func, NDArray o = NDArray::Empty(shard_func.output_info.shape, shard_func.output_info.dtype, device); ffi::Function f = this->shard_funcs_.at(shard_func.name); int n = static_cast(shard_func.params.size()); - std::vector packed_args(n + 2); + std::vector packed_args(n + 2); const DLTensor* w_in = param.operator->(); const DLTensor* w_out = o.operator->(); packed_args[0] = const_cast(w_in); @@ -226,7 +225,7 @@ NDArray ShardLoaderObj::ApplyShardFunc(const ShardInfo::ShardFunc& shard_func, packed_args[i + 1] = shard_func.params[i]; } packed_args[n + 1] = const_cast(w_out); - Any rv; + ffi::Any rv; f.CallPacked(ffi::PackedArgs(packed_args.data(), packed_args.size()), &rv); return o; } diff --git a/src/runtime/disco/message_queue.h b/src/runtime/disco/message_queue.h index 0fa793c3ab21..e8286384ff50 100644 --- a/src/runtime/disco/message_queue.h +++ b/src/runtime/disco/message_queue.h @@ -45,12 +45,12 @@ class DiscoStreamMessageQueue : private dmlc::Stream, ffi::PackedArgs Recv() { bool is_implicit_shutdown = DequeueNextPacket(); - AnyView* packed_args = nullptr; + ffi::AnyView* packed_args = nullptr; int num_args = 0; if (is_implicit_shutdown) { num_args = 2; - packed_args = reinterpret_cast(ArenaAlloc(num_args)); + packed_args = reinterpret_cast(ArenaAlloc(num_args)); packed_args[0] = static_cast(DiscoAction::kShutDown); packed_args[1] = 0; } else { diff --git a/src/runtime/disco/process_session.cc b/src/runtime/disco/process_session.cc index eff03ea2536b..4563079c30b4 100644 --- a/src/runtime/disco/process_session.cc +++ b/src/runtime/disco/process_session.cc @@ -20,7 +20,6 @@ #include #include #include -#include #include #include @@ -100,7 +99,7 @@ class ProcessSessionObj final : public BcastSessionObj { return worker_0_->worker->register_file.at(reg_id); } { - AnyView packed_args[3]; + ffi::AnyView packed_args[3]; ffi::PackedArgs::Fill(packed_args, static_cast(DiscoAction::kDebugGetFromRemote), reg_id, worker_id); workers_[worker_id - 1]->Send(ffi::PackedArgs(packed_args, 3)); @@ -113,7 +112,7 @@ class ProcessSessionObj final : public BcastSessionObj { return result; } - void DebugSetRegister(int64_t reg_id, AnyView value, int worker_id) { + void DebugSetRegister(int64_t reg_id, ffi::AnyView value, int worker_id) { if (worker_id == 0) { this->SyncWorker(worker_id); worker_0_->worker->SetRegister(reg_id, value); @@ -125,7 +124,7 @@ class ProcessSessionObj final : public BcastSessionObj { value = wrapped; } { - AnyView packed_args[4]; + ffi::AnyView packed_args[4]; ffi::PackedArgs::Fill(packed_args, static_cast(DiscoAction::kDebugSetRegister), reg_id, worker_id, value); SendPacked(worker_id, ffi::PackedArgs(packed_args, 4)); diff --git a/src/runtime/disco/protocol.h b/src/runtime/disco/protocol.h index 9536c2911d1b..30a1e6ed6609 100644 --- a/src/runtime/disco/protocol.h +++ b/src/runtime/disco/protocol.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -212,7 +211,7 @@ inline void DiscoProtocol::ReadObject(TVMFFIAny* out) { LOG(FATAL) << "ValueError: Object type is not supported in Disco calling convention: " << Object::TypeIndex2Key(type_index) << " (type_index = " << type_index << ")"; } - *reinterpret_cast(out) = result; + *reinterpret_cast(out) = result; object_arena_.push_back(result); } diff --git a/src/runtime/disco/session.cc b/src/runtime/disco/session.cc index f2edfd59a27e..ed2d8575387f 100644 --- a/src/runtime/disco/session.cc +++ b/src/runtime/disco/session.cc @@ -19,7 +19,6 @@ #include #include #include -#include namespace tvm { namespace runtime { diff --git a/src/runtime/disco/threaded_session.cc b/src/runtime/disco/threaded_session.cc index c03a1bd9f4fd..f7e34e400c6a 100644 --- a/src/runtime/disco/threaded_session.cc +++ b/src/runtime/disco/threaded_session.cc @@ -48,7 +48,7 @@ class DiscoThreadedMessageQueue : private dmlc::Stream, ffi::PackedArgs Recv() { DequeueNextPacket(); - AnyView* packed_args = nullptr; + ffi::AnyView* packed_args = nullptr; int num_args = 0; RPCReference::RecvPackedSeq(reinterpret_cast(&packed_args), &num_args, this); return ffi::PackedArgs(packed_args, num_args); @@ -162,7 +162,7 @@ class ThreadedSessionObj final : public BcastSessionObj { return this->workers_.at(worker_id).worker->register_file.at(reg_id); } - void DebugSetRegister(int64_t reg_id, AnyView value, int worker_id) { + void DebugSetRegister(int64_t reg_id, ffi::AnyView value, int worker_id) { this->SyncWorker(worker_id); this->workers_.at(worker_id).worker->SetRegister(reg_id, value); } diff --git a/src/runtime/dso_library.cc b/src/runtime/dso_library.cc index d64d893ce12b..8a8666691300 100644 --- a/src/runtime/dso_library.cc +++ b/src/runtime/dso_library.cc @@ -24,7 +24,6 @@ #include #include #include -#include #include "library_module.h" diff --git a/src/runtime/hexagon/hexagon_buffer.h b/src/runtime/hexagon/hexagon_buffer.h index b426825fc21f..986d6b6e5ec6 100644 --- a/src/runtime/hexagon/hexagon_buffer.h +++ b/src/runtime/hexagon/hexagon_buffer.h @@ -20,11 +20,11 @@ #ifndef TVM_RUNTIME_HEXAGON_HEXAGON_BUFFER_H_ #define TVM_RUNTIME_HEXAGON_HEXAGON_BUFFER_H_ +#include #include #include #include #include -#include #include #include diff --git a/src/runtime/hexagon/hexagon_common.h b/src/runtime/hexagon/hexagon_common.h index 5834093a9e43..1e68a93a8b2e 100644 --- a/src/runtime/hexagon/hexagon_common.h +++ b/src/runtime/hexagon/hexagon_common.h @@ -24,9 +24,10 @@ #define TVM_RUNTIME_HEXAGON_HEXAGON_COMMON_H_ #include +#include #include +#include #include -#include #if defined(__hexagon__) #include diff --git a/src/runtime/hexagon/hexagon_thread_manager.h b/src/runtime/hexagon/hexagon_thread_manager.h index 31f3d0466972..7ec3ac61506d 100644 --- a/src/runtime/hexagon/hexagon_thread_manager.h +++ b/src/runtime/hexagon/hexagon_thread_manager.h @@ -20,9 +20,9 @@ #ifndef TVM_RUNTIME_HEXAGON_HEXAGON_THREAD_MANAGER_H_ #define TVM_RUNTIME_HEXAGON_HEXAGON_THREAD_MANAGER_H_ +#include #include #include -#include #include #include diff --git a/src/runtime/hexagon/hexagon_vtcm_pool.h b/src/runtime/hexagon/hexagon_vtcm_pool.h index 18c89722f4b0..ece8454b859a 100644 --- a/src/runtime/hexagon/hexagon_vtcm_pool.h +++ b/src/runtime/hexagon/hexagon_vtcm_pool.h @@ -20,11 +20,11 @@ #ifndef TVM_RUNTIME_HEXAGON_HEXAGON_VTCM_POOL_H_ #define TVM_RUNTIME_HEXAGON_HEXAGON_VTCM_POOL_H_ +#include #include #include #include #include -#include #include #include diff --git a/src/runtime/hexagon/rpc/hexagon/rpc_server.cc b/src/runtime/hexagon/rpc/hexagon/rpc_server.cc index d9a9d007b090..7880018ff8e8 100644 --- a/src/runtime/hexagon/rpc/hexagon/rpc_server.cc +++ b/src/runtime/hexagon/rpc/hexagon/rpc_server.cc @@ -29,7 +29,6 @@ extern "C" { #include #include #include -#include #include #include diff --git a/src/runtime/hexagon/rpc/simulator/session.cc b/src/runtime/hexagon/rpc/simulator/session.cc index 3211b8d0472f..5eb7beab0f57 100644 --- a/src/runtime/hexagon/rpc/simulator/session.cc +++ b/src/runtime/hexagon/rpc/simulator/session.cc @@ -19,7 +19,6 @@ #include #include -#include // POSIX includes #include #include diff --git a/src/runtime/meta_data.h b/src/runtime/meta_data.h index b93db5a19c6d..51120c1f9efb 100644 --- a/src/runtime/meta_data.h +++ b/src/runtime/meta_data.h @@ -26,9 +26,9 @@ #include #include +#include #include #include -#include #include #include diff --git a/src/runtime/metal/metal_common.h b/src/runtime/metal/metal_common.h index e57907e06ecc..138d312dd47c 100644 --- a/src/runtime/metal/metal_common.h +++ b/src/runtime/metal/metal_common.h @@ -30,10 +30,10 @@ #import #import #import +#include #include #include #include -#include #include #include diff --git a/src/runtime/metal/metal_module.h b/src/runtime/metal/metal_module.h index d01523b1faba..e2705a7a806b 100644 --- a/src/runtime/metal/metal_module.h +++ b/src/runtime/metal/metal_module.h @@ -24,7 +24,7 @@ #ifndef TVM_RUNTIME_METAL_METAL_MODULE_H_ #define TVM_RUNTIME_METAL_METAL_MODULE_H_ -#include +#include #include #include diff --git a/src/runtime/module.cc b/src/runtime/module.cc index d16239079c67..d2bc4b2c297a 100644 --- a/src/runtime/module.cc +++ b/src/runtime/module.cc @@ -23,7 +23,6 @@ */ #include #include -#include #include #include diff --git a/src/runtime/opencl/opencl_common.h b/src/runtime/opencl/opencl_common.h index 91dad2af82c4..dbef2f518f5a 100644 --- a/src/runtime/opencl/opencl_common.h +++ b/src/runtime/opencl/opencl_common.h @@ -24,12 +24,12 @@ #ifndef TVM_RUNTIME_OPENCL_OPENCL_COMMON_H_ #define TVM_RUNTIME_OPENCL_OPENCL_COMMON_H_ +#include #include #include #include #include #include -#include #include /* There are many OpenCL platforms that do not yet support OpenCL 2.0, diff --git a/src/runtime/opencl/opencl_module.h b/src/runtime/opencl/opencl_module.h index 22fc119e0318..198adc6cb216 100644 --- a/src/runtime/opencl/opencl_module.h +++ b/src/runtime/opencl/opencl_module.h @@ -24,7 +24,7 @@ #ifndef TVM_RUNTIME_OPENCL_OPENCL_MODULE_H_ #define TVM_RUNTIME_OPENCL_OPENCL_MODULE_H_ -#include +#include #include #include diff --git a/src/runtime/pack_args.h b/src/runtime/pack_args.h index 6fbbb05b7d58..b77adda4c9f4 100644 --- a/src/runtime/pack_args.h +++ b/src/runtime/pack_args.h @@ -31,8 +31,8 @@ #ifndef TVM_RUNTIME_PACK_ARGS_H_ #define TVM_RUNTIME_PACK_ARGS_H_ +#include #include -#include #include #include diff --git a/src/runtime/packed_func.cc b/src/runtime/packed_func.cc deleted file mode 100644 index 38146227f9dd..000000000000 --- a/src/runtime/packed_func.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * \file src/runtime/packed_func.cc - * \brief Implementation of non-inlinable ffi::Function pieces. - */ -#include -#include - -namespace tvm { -namespace runtime { - -TVM_REGISTER_OBJECT_TYPE(ffi::FunctionObj); - -} // namespace runtime -} // namespace tvm diff --git a/src/runtime/profiling.cc b/src/runtime/profiling.cc index 2a12fba0b02d..bab1d50db6a9 100644 --- a/src/runtime/profiling.cc +++ b/src/runtime/profiling.cc @@ -23,9 +23,9 @@ */ #include +#include #include #include -#include #include #include @@ -495,7 +495,7 @@ String ReportNode::AsTable(bool sort, bool aggregate, bool compute_col_sums) con } } for (const auto& p : aggregates) { - std::unordered_map aggregated; + std::unordered_map aggregated; std::unordered_set metrics; for (auto& call : calls) { for (auto& metric : call) { @@ -803,46 +803,47 @@ TVM_FFI_REGISTER_GLOBAL("runtime.profiling.DeviceWrapper").set_body_typed([](Dev ffi::Function ProfileFunction(Module mod, std::string func_name, int device_type, int device_id, int warmup_iters, Array collectors) { // Module::GetFunction is not const, so this lambda has to be mutable - return ffi::Function::FromPacked([=](const AnyView* args, int32_t num_args, Any* ret) mutable { - ffi::Function f = mod.GetFunction(func_name); - CHECK(f.defined()) << "There is no function called \"" << func_name << "\" in the module"; - Device dev{static_cast(device_type), device_id}; - - // warmup - for (int i = 0; i < warmup_iters; i++) { - f.CallPacked(args, num_args, ret); - } - - for (auto& collector : collectors) { - collector->Init({DeviceWrapper(dev)}); - } - std::vector> results; - results.reserve(collectors.size()); - std::vector> collector_data; - collector_data.reserve(collectors.size()); - for (auto& collector : collectors) { - ObjectRef o = collector->Start(dev); - // If not defined, then the collector cannot time this device. - if (o.defined()) { - collector_data.push_back({collector, o}); - } - } + return ffi::Function::FromPacked( + [=](const ffi::AnyView* args, int32_t num_args, ffi::Any* ret) mutable { + ffi::Function f = mod.GetFunction(func_name); + CHECK(f.defined()) << "There is no function called \"" << func_name << "\" in the module"; + Device dev{static_cast(device_type), device_id}; + + // warmup + for (int i = 0; i < warmup_iters; i++) { + f.CallPacked(args, num_args, ret); + } - // TODO(tkonolige): repeated calls if the runtime is small? - f.CallPacked(args, num_args, ret); + for (auto& collector : collectors) { + collector->Init({DeviceWrapper(dev)}); + } + std::vector> results; + results.reserve(collectors.size()); + std::vector> collector_data; + collector_data.reserve(collectors.size()); + for (auto& collector : collectors) { + ObjectRef o = collector->Start(dev); + // If not defined, then the collector cannot time this device. + if (o.defined()) { + collector_data.push_back({collector, o}); + } + } - for (auto& kv : collector_data) { - results.push_back(kv.first->Stop(kv.second)); - } - Map combined_results; - for (auto m : results) { - for (auto p : m) { - // assume that there is no shared metric name between collectors - combined_results.Set(p.first, p.second); - } - } - *ret = combined_results; - }); + // TODO(tkonolige): repeated calls if the runtime is small? + f.CallPacked(args, num_args, ret); + + for (auto& kv : collector_data) { + results.push_back(kv.first->Stop(kv.second)); + } + Map combined_results; + for (auto m : results) { + for (auto p : m) { + // assume that there is no shared metric name between collectors + combined_results.Set(p.first, p.second); + } + } + *ret = combined_results; + }); } TVM_FFI_REGISTER_GLOBAL("runtime.profiling.ProfileFunction") @@ -869,8 +870,8 @@ ffi::Function WrapTimeEvaluator(ffi::Function pf, Device dev, int number, int re auto ftimer = [pf, dev, number, repeat, min_repeat_ms, limit_zero_time_iterations, cooldown_interval_ms, repeats_to_cooldown, cache_flush_bytes, - f_preproc](const AnyView* args, int num_args, Any* rv) mutable { - Any temp; + f_preproc](const ffi::AnyView* args, int num_args, ffi::Any* rv) mutable { + ffi::Any temp; std::ostringstream os; // skip first time call, to activate lazy compilation components. pf.CallPacked(args, num_args, &temp); diff --git a/src/runtime/relax_vm/attn_backend.h b/src/runtime/relax_vm/attn_backend.h index dd8127525c9c..2eb9cf3d6677 100644 --- a/src/runtime/relax_vm/attn_backend.h +++ b/src/runtime/relax_vm/attn_backend.h @@ -26,9 +26,9 @@ #define TVM_RUNTIME_RELAX_VM_ATTN_BACKEND_H_ #include +#include #include #include -#include #include #include diff --git a/src/runtime/relax_vm/builtin.cc b/src/runtime/relax_vm/builtin.cc index f62bb14608fa..3d7904bd8f48 100644 --- a/src/runtime/relax_vm/builtin.cc +++ b/src/runtime/relax_vm/builtin.cc @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -113,7 +112,7 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.match_prim_value").set_body_typed(MatchPrimV * * \sa MatchShapeCode */ -void MatchShape(ffi::PackedArgs args, Any* rv) { +void MatchShape(ffi::PackedArgs args, ffi::Any* rv) { // input shape the first argument can take in tensor or shape. ffi::Shape input_shape; if (auto opt_nd = args[0].as()) { @@ -188,7 +187,7 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.make_prim_value").set_body_typed(MakePrimVal * * \sa MakeShapeCode */ -void MakeShape(ffi::PackedArgs args, Any* rv) { +void MakeShape(ffi::PackedArgs args, ffi::Any* rv) { // NOTE: heap can be nullptr auto heap = args[0].try_cast(); int64_t* heap_data = heap.has_value() ? static_cast((*heap)->data) : nullptr; @@ -219,8 +218,8 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.make_shape").set_body_packed(MakeShape); * \param dtype The expected content data type. * \param err_ctx Additional context if error occurs. */ -void CheckTensorInfo(ffi::PackedArgs args, Any* rv) { - AnyView arg = args[0]; +void CheckTensorInfo(ffi::PackedArgs args, ffi::Any* rv) { + ffi::AnyView arg = args[0]; int ndim = args[1].cast(); DataType dtype; Optional err_ctx; @@ -278,7 +277,7 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.check_shape_info").set_body_typed(CheckShape * \param dtype Expected dtype of the PrimValue. Can be DataType::Void() for unknown dtype. * \param err_ctx Additional context if error occurs. */ -void CheckPrimValueInfo(AnyView arg, DataType dtype, Optional err_ctx) { +void CheckPrimValueInfo(ffi::AnyView arg, DataType dtype, Optional err_ctx) { if (auto opt_obj = arg.as()) { LOG(FATAL) << "TypeError: " << err_ctx.value_or("") << ", expected dtype " << dtype << ", but received ObjectRef of type " << opt_obj.value()->GetTypeKey(); @@ -362,9 +361,9 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.alloc_tensor").set_body_method(&StorageObj:: // Closure function handling, calling convention //------------------------------------------------- TVM_FFI_REGISTER_GLOBAL("vm.builtin.make_closure") - .set_body_packed([](ffi::PackedArgs args, Any* rv) { + .set_body_packed([](ffi::PackedArgs args, ffi::Any* rv) { VMClosure clo = args[0].cast(); - std::vector saved_args; + std::vector saved_args; saved_args.resize(args.size() - 1); for (size_t i = 0; i < saved_args.size(); ++i) { saved_args[i] = args[i + 1]; @@ -374,7 +373,7 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.make_closure") }); TVM_FFI_REGISTER_GLOBAL("vm.builtin.invoke_closure") - .set_body_packed([](ffi::PackedArgs args, Any* rv) { + .set_body_packed([](ffi::PackedArgs args, ffi::Any* rv) { // args[0]: vm; args[1]: closure; args[2, 3, ...]: function arguments VirtualMachine* vm = VirtualMachine::GetContextPtr(args[0]); ObjectRef vm_closure = args[1].cast(); @@ -382,12 +381,12 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.invoke_closure") }); TVM_FFI_REGISTER_GLOBAL("vm.builtin.call_tir_dyn") - .set_body_packed([](ffi::PackedArgs args, Any* rv) { + .set_body_packed([](ffi::PackedArgs args, ffi::Any* rv) { ffi::Function func = args[0].cast(); ffi::Shape to_unpack = args[args.size() - 1].cast(); size_t num_tensor_args = args.size() - 2; - std::vector packed_args(num_tensor_args + to_unpack.size()); + std::vector packed_args(num_tensor_args + to_unpack.size()); std::copy(args.data() + 1, args.data() + args.size() - 1, packed_args.data()); for (size_t i = 0; i < to_unpack.size(); ++i) { @@ -401,7 +400,7 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.call_tir_dyn") //------------------------------------- TVM_FFI_REGISTER_GLOBAL("vm.builtin.shape_of").set_body_method(&NDArray::Shape); -TVM_FFI_REGISTER_GLOBAL("vm.builtin.copy").set_body_typed([](Any a) -> Any { return a; }); +TVM_FFI_REGISTER_GLOBAL("vm.builtin.copy").set_body_typed([](ffi::Any a) -> ffi::Any { return a; }); TVM_FFI_REGISTER_GLOBAL("vm.builtin.reshape") .set_body_typed([](NDArray data, ffi::Shape new_shape) { @@ -423,7 +422,7 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.to_device") * \param cond The condition * \return Bool */ -bool ReadIfCond(AnyView cond) { +bool ReadIfCond(ffi::AnyView cond) { if (auto opt_int = cond.try_cast()) { return opt_int.value(); } @@ -468,7 +467,7 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.read_if_cond").set_body_typed(ReadIfCond); //------------------------------------- TVM_FFI_REGISTER_GLOBAL("vm.builtin.invoke_debug_func") - .set_body_packed([](ffi::PackedArgs args, Any* rv) -> void { + .set_body_packed([](ffi::PackedArgs args, ffi::Any* rv) -> void { ICHECK_GE(args.size(), 3); int num_args = args.size() - 3; ObjectRef io_effect = args[0].cast(); @@ -479,7 +478,7 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.invoke_debug_func") << "Use the decorator `@tvm.register_func(\"" << debug_func_name << "\")` to register it."; String line_info = args[2].cast(); - std::vector call_args(num_args + 1); + std::vector call_args(num_args + 1); { call_args[0] = line_info; for (int i = 0; i < num_args; ++i) { @@ -494,20 +493,21 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.invoke_debug_func") // Data structure API //------------------------------------- TVM_FFI_REGISTER_GLOBAL("vm.builtin.tuple_getitem") - .set_body_typed([](Array arr, int64_t index) { return arr[index]; }); + .set_body_typed([](Array arr, int64_t index) { return arr[index]; }); TVM_FFI_REGISTER_GLOBAL("vm.builtin.tuple_reset_item") .set_body_typed([](const ffi::ArrayObj* arr, int64_t index) { const_cast(arr)->SetItem(index, nullptr); }); -TVM_FFI_REGISTER_GLOBAL("vm.builtin.make_tuple").set_body_packed([](ffi::PackedArgs args, Any* rv) { - Array arr; - for (int i = 0; i < args.size(); ++i) { - arr.push_back(args[i]); - } - *rv = arr; -}); +TVM_FFI_REGISTER_GLOBAL("vm.builtin.make_tuple") + .set_body_packed([](ffi::PackedArgs args, ffi::Any* rv) { + Array arr; + for (int i = 0; i < args.size(); ++i) { + arr.push_back(args[i]); + } + *rv = arr; + }); TVM_FFI_REGISTER_GLOBAL("vm.builtin.tensor_to_shape").set_body_typed([](NDArray data) { NDArray arr = data; @@ -613,7 +613,7 @@ int TVMBackendAnyListSetPackedArg(void* anylist, int index, TVMFFIAny* args, int int TVMBackendAnyListResetItem(void* anylist, int index) { using namespace tvm::runtime; TVM_FFI_SAFE_CALL_BEGIN(); - auto* list = static_cast(anylist); + auto* list = static_cast(anylist); list[index] = nullptr; TVM_FFI_SAFE_CALL_END(); } @@ -622,7 +622,7 @@ int TVMBackendAnyListMoveFromPackedReturn(void* anylist, int index, TVMFFIAny* a int ret_offset) { using namespace tvm::runtime; TVM_FFI_SAFE_CALL_BEGIN(); - auto* list = static_cast(anylist); + auto* list = static_cast(anylist); list[index] = tvm::ffi::details::AnyUnsafe::MoveTVMFFIAnyToAny(std::move(args[ret_offset])); TVM_FFI_SAFE_CALL_END(); } diff --git a/src/runtime/relax_vm/cuda/cuda_graph_builtin.cc b/src/runtime/relax_vm/cuda/cuda_graph_builtin.cc index 2fdf514b0e5d..d3484cbc7b3e 100644 --- a/src/runtime/relax_vm/cuda/cuda_graph_builtin.cc +++ b/src/runtime/relax_vm/cuda/cuda_graph_builtin.cc @@ -24,7 +24,6 @@ #include #include -#include #include #include "../../../support/utils.h" diff --git a/src/runtime/relax_vm/hexagon/builtin.cc b/src/runtime/relax_vm/hexagon/builtin.cc index d2d05a0e8256..89f1708b28ed 100644 --- a/src/runtime/relax_vm/hexagon/builtin.cc +++ b/src/runtime/relax_vm/hexagon/builtin.cc @@ -24,7 +24,6 @@ #include #include -#include #include #include "../../hexagon/hexagon_device_api.h" diff --git a/src/runtime/relax_vm/ndarray_cache_support.cc b/src/runtime/relax_vm/ndarray_cache_support.cc index c69b48ccd697..7341507e9a98 100644 --- a/src/runtime/relax_vm/ndarray_cache_support.cc +++ b/src/runtime/relax_vm/ndarray_cache_support.cc @@ -268,7 +268,7 @@ class NDArrayCache { TVM_FFI_REGISTER_GLOBAL("vm.builtin.ndarray_cache.get").set_body_typed(NDArrayCache::Get); TVM_FFI_REGISTER_GLOBAL("vm.builtin.ndarray_cache.update") - .set_body_packed([](ffi::PackedArgs args, Any* rv) { + .set_body_packed([](ffi::PackedArgs args, ffi::Any* rv) { CHECK(args.size() == 2 || args.size() == 3); String name = args[0].cast(); bool is_override = args.size() == 2 ? false : args[2].cast(); @@ -362,7 +362,7 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.param_array_from_cache") TVM_FFI_REGISTER_GLOBAL("vm.builtin.param_array_from_cache_by_name") .set_body_typed(ParamModuleNode::GetParamByName); TVM_FFI_REGISTER_GLOBAL("vm.builtin.param_array_from_cache_by_name_unpacked") - .set_body_packed([](ffi::PackedArgs args, Any* rv) { + .set_body_packed([](ffi::PackedArgs args, ffi::Any* rv) { Array names; names.reserve(args.size()); for (int i = 0; i < args.size(); ++i) { diff --git a/src/runtime/relax_vm/paged_kv_cache.cc b/src/runtime/relax_vm/paged_kv_cache.cc index be9cd5955767..2f21e6978a68 100644 --- a/src/runtime/relax_vm/paged_kv_cache.cc +++ b/src/runtime/relax_vm/paged_kv_cache.cc @@ -2285,7 +2285,7 @@ TVM_REGISTER_OBJECT_TYPE(PagedAttentionKVCacheObj); //------------------------------------------------- TVM_FFI_REGISTER_GLOBAL("vm.builtin.paged_attention_kv_cache_create") - .set_body_packed([](ffi::PackedArgs args, Any* rv) { + .set_body_packed([](ffi::PackedArgs args, ffi::Any* rv) { // Todo: cuda graph arg CHECK(args.size() == 28 || args.size() == 29) << "Invalid number of KV cache constructor args: " << args.size(); diff --git a/src/runtime/relax_vm/vm.cc b/src/runtime/relax_vm/vm.cc index 0fef2e4c6d07..8d0b928f8592 100644 --- a/src/runtime/relax_vm/vm.cc +++ b/src/runtime/relax_vm/vm.cc @@ -21,9 +21,9 @@ * \file src/runtime/relax_vm/vm.cc */ #include +#include #include #include -#include #include #include @@ -52,9 +52,9 @@ VMClosure::VMClosure(String func_name, ffi::Function impl) { * \param last_args The arguments to bound to in the end of the function. * \note The new function takes in arguments and append the last_args in the end. */ -ffi::Function VMClosure::BindLastArgs(ffi::Function func, std::vector last_args) { +ffi::Function VMClosure::BindLastArgs(ffi::Function func, std::vector last_args) { return ffi::Function([func, last_args](ffi::PackedArgs args, ffi::Any* rv) { - std::vector packed_args(args.size() + last_args.size()); + std::vector packed_args(args.size() + last_args.size()); std::copy(args.data(), args.data() + args.size(), packed_args.data()); for (size_t i = 0; i < last_args.size(); ++i) { packed_args[args.size() + i] = last_args[i]; @@ -68,14 +68,14 @@ ffi::Function VMClosure::BindLastArgs(ffi::Function func, std::vector last_ //----------------------------------------------------------- // Use the args after `starting_arg_idx` as a series of indices into `obj`, // indexing into nested Array and returning the final indexed object. -Any IndexIntoNestedObject(Any obj, ffi::PackedArgs args, int starting_arg_idx) { +ffi::Any IndexIntoNestedObject(ffi::Any obj, ffi::PackedArgs args, int starting_arg_idx) { for (int i = starting_arg_idx; i < args.size(); i++) { // the object must be an Array to be able to index into it if (!obj.as()) { LOG(FATAL) << "ValueError: Attempted to index into an object that is not an Array."; } int index = args[i].cast(); - auto arr = Downcast>(obj); + auto arr = Downcast>(obj); // make sure the index is in bounds if (index >= static_cast(arr.size())) { LOG(FATAL) << "IndexError: Invalid index (" << index << " >= " << arr.size() << ")."; @@ -110,12 +110,12 @@ Any ConvertObjectToDevice(Any src, const Device& dev, Allocator* alloc) { } } -ffi::Any ConvertArgToDevice(AnyView input, Device dev, Allocator* alloc) { +ffi::Any ConvertArgToDevice(ffi::AnyView input, Device dev, Allocator* alloc) { // in terms of memory-behavior. // To be extra careful, we copy DLTensor. // The developer can still explicitly allocate NDArray // in TVM Native API or NDArray::FromDLPack to regain zero copy behavior. - Any ret; + ffi::Any ret; if (auto opt_obj = input.as()) { ret = ConvertObjectToDevice(opt_obj.value(), dev, alloc); } else if (auto opt_dltensor = input.as()) { @@ -131,7 +131,7 @@ ffi::Any ConvertArgToDevice(AnyView input, Device dev, Allocator* alloc) { } ffi::Any ConvertRegToDevice(ffi::Any input, Device dev, Allocator* alloc) { - Any ret; + ffi::Any ret; if (auto opt_obj = input.as()) { ret = ConvertObjectToDevice(opt_obj.value(), dev, alloc); } else { @@ -163,7 +163,7 @@ struct VMFrame { /*! \brief Register in caller's frame to put return value */ RegName caller_return_register; /*! \brief Temporary argument tcode stack for packed func call. */ - std::vector call_args; + std::vector call_args; VMFrame(Index pc, Index register_file_size) : return_pc(pc), register_file(register_file_size), caller_return_register(0) {} @@ -534,7 +534,7 @@ void VirtualMachineImpl::InvokeClosurePacked(const ObjectRef& closure_or_packedf auto* clo = closure_or_packedfunc.as(); ICHECK(clo != nullptr) << "Function expects a closure or ffi::Function "; - std::vector packed_args(args.size() + 1); + std::vector packed_args(args.size() + 1); // per convention, ctx ptr must be VirtualMachine* casted to void. // this and VirtualMachine* may or maynot be the same // do first cast to VirtualMachine* then to void* @@ -554,7 +554,7 @@ RegType VirtualMachineImpl::InvokeClosureInternal(const ObjectRef& closure_or_pa auto* clo = closure_or_packed.as(); int clo_offset = clo != nullptr ? 1 : 0; - std::vector packed_args(args.size() + clo_offset); + std::vector packed_args(args.size() + clo_offset); if (clo != nullptr) { packed_args[0] = static_cast(static_cast(this)); @@ -726,7 +726,7 @@ void VirtualMachineImpl::RunInstrCall(VMFrame* curr_frame, Instruction instr) { // NOTE: no changes and resize to those vector ref(otherwise can leads to segfault) // in the remainder part of the function. - std::vector& call_args = curr_frame->call_args; + std::vector& call_args = curr_frame->call_args; for (Index i = 0; i < instr.num_args; ++i) { Instruction::Arg arg = instr.args[i]; @@ -768,7 +768,7 @@ void VirtualMachineImpl::RunInstrCall(VMFrame* curr_frame, Instruction instr) { call_args[2] = true; call_args[3] = nullptr; - Any rv; + ffi::Any rv; // store dtype to str since py callback cannot handle dtype atm. std::vector> temp_dtype; for (int i = 0; i < instr.num_args; ++i) { @@ -906,7 +906,7 @@ void VirtualMachineImpl::_SetInstrument(ffi::PackedArgs args, ffi::Any* rv) { void VirtualMachineImpl::_GetOutputArity(ffi::PackedArgs args, ffi::Any* rv) { std::string func_name = args[0].cast(); RegType out = LookupVMOutput(func_name); - Any obj = IndexIntoNestedObject(out, args, 1); + ffi::Any obj = IndexIntoNestedObject(out, args, 1); if (const auto* arr = obj.as()) { *rv = static_cast(arr->size()); } else { @@ -917,7 +917,7 @@ void VirtualMachineImpl::_GetOutputArity(ffi::PackedArgs args, ffi::Any* rv) { void VirtualMachineImpl::_GetOutput(ffi::PackedArgs args, ffi::Any* rv) { std::string func_name = args[0].cast(); RegType out = LookupVMOutput(func_name); - Any obj = IndexIntoNestedObject(out, args, 1); + ffi::Any obj = IndexIntoNestedObject(out, args, 1); if (obj.as()) { LOG(FATAL) << "ValueError: `get_output` cannot return a tuple for RPC compatibility. " "Please specify another index argument."; diff --git a/src/runtime/rocm/rocm_common.h b/src/runtime/rocm/rocm_common.h index b258e37508df..ec3e744d3034 100644 --- a/src/runtime/rocm/rocm_common.h +++ b/src/runtime/rocm/rocm_common.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include diff --git a/src/runtime/rpc/rpc_channel.cc b/src/runtime/rpc/rpc_channel.cc index d757eb718aed..50f7195a2224 100644 --- a/src/runtime/rpc/rpc_channel.cc +++ b/src/runtime/rpc/rpc_channel.cc @@ -22,6 +22,8 @@ */ #include "rpc_channel.h" +#include + #include namespace tvm { diff --git a/src/runtime/rpc/rpc_channel.h b/src/runtime/rpc/rpc_channel.h index 62af2d92a8ac..3c8f6b404cf4 100644 --- a/src/runtime/rpc/rpc_channel.h +++ b/src/runtime/rpc/rpc_channel.h @@ -24,7 +24,7 @@ #ifndef TVM_RUNTIME_RPC_RPC_CHANNEL_H_ #define TVM_RUNTIME_RPC_RPC_CHANNEL_H_ -#include +#include #include diff --git a/src/runtime/rpc/rpc_endpoint.cc b/src/runtime/rpc/rpc_endpoint.cc index 9e54223a09df..7ee721405619 100644 --- a/src/runtime/rpc/rpc_endpoint.cc +++ b/src/runtime/rpc/rpc_endpoint.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/src/runtime/rpc/rpc_endpoint.h b/src/runtime/rpc/rpc_endpoint.h index 5d94aed4704f..195adef053bd 100644 --- a/src/runtime/rpc/rpc_endpoint.h +++ b/src/runtime/rpc/rpc_endpoint.h @@ -24,7 +24,7 @@ #ifndef TVM_RUNTIME_RPC_RPC_ENDPOINT_H_ #define TVM_RUNTIME_RPC_RPC_ENDPOINT_H_ -#include +#include #include #include diff --git a/src/runtime/rpc/rpc_local_session.cc b/src/runtime/rpc/rpc_local_session.cc index 1769ed077f6a..a64bbb713250 100644 --- a/src/runtime/rpc/rpc_local_session.cc +++ b/src/runtime/rpc/rpc_local_session.cc @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -120,7 +121,7 @@ void LocalSession::CopyToRemote(void* from_bytes, DLTensor* to, uint64_t nbytes) } void LocalSession::CopyFromRemote(DLTensor* from, void* to_bytes, uint64_t nbytes) { - ICHECK_EQ(nbytes, GetDataSize(*from)); + ICHECK_EQ(nbytes, ffi::GetDataSize(*from)); DLTensor to; to.data = to_bytes; to.device = {kDLCPU, 0}; diff --git a/src/runtime/rpc/rpc_local_session.h b/src/runtime/rpc/rpc_local_session.h index 4019552ebcd1..9035b486c995 100644 --- a/src/runtime/rpc/rpc_local_session.h +++ b/src/runtime/rpc/rpc_local_session.h @@ -24,8 +24,8 @@ #ifndef TVM_RUNTIME_RPC_RPC_LOCAL_SESSION_H_ #define TVM_RUNTIME_RPC_RPC_LOCAL_SESSION_H_ +#include #include -#include #include #include diff --git a/src/runtime/rpc/rpc_session.cc b/src/runtime/rpc/rpc_session.cc index 76e07e00fb2b..ace9cf9b9485 100644 --- a/src/runtime/rpc/rpc_session.cc +++ b/src/runtime/rpc/rpc_session.cc @@ -23,8 +23,8 @@ */ #include "rpc_session.h" +#include #include -#include #include #include @@ -35,7 +35,7 @@ namespace runtime { bool RPCSession::IsAsync() const { return false; } void RPCSession::SendException(FAsyncCallback callback, const char* msg) { - AnyView packed_args[1] = {msg}; + ffi::AnyView packed_args[1] = {msg}; callback(RPCCode::kException, ffi::PackedArgs(packed_args, 1)); } @@ -51,7 +51,7 @@ void RPCSession::AsyncCallFunc(PackedFuncHandle func, ffi::PackedArgs packed_arg void RPCSession::AsyncCopyToRemote(void* local_from_bytes, DLTensor* remote_to, uint64_t nbytes, RPCSession::FAsyncCallback callback) { - AnyView packed_args[1] = {nullptr}; + ffi::AnyView packed_args[1] = {nullptr}; try { this->CopyToRemote(local_from_bytes, remote_to, nbytes); @@ -63,7 +63,7 @@ void RPCSession::AsyncCopyToRemote(void* local_from_bytes, DLTensor* remote_to, void RPCSession::AsyncCopyFromRemote(DLTensor* remote_from, void* local_to_bytes, uint64_t nbytes, RPCSession::FAsyncCallback callback) { - AnyView packed_args[1] = {nullptr}; + ffi::AnyView packed_args[1] = {nullptr}; try { this->CopyFromRemote(remote_from, local_to_bytes, nbytes); diff --git a/src/runtime/rpc/rpc_session.h b/src/runtime/rpc/rpc_session.h index 271e26dfd04e..c0ec2067eb5f 100644 --- a/src/runtime/rpc/rpc_session.h +++ b/src/runtime/rpc/rpc_session.h @@ -24,8 +24,10 @@ #ifndef TVM_RUNTIME_RPC_RPC_SESSION_H_ #define TVM_RUNTIME_RPC_RPC_SESSION_H_ +#include #include -#include +#include +#include #include #include diff --git a/src/runtime/spirv/spirv_shader.h b/src/runtime/spirv/spirv_shader.h index d194f70629e6..06b331d3334e 100644 --- a/src/runtime/spirv/spirv_shader.h +++ b/src/runtime/spirv/spirv_shader.h @@ -20,10 +20,11 @@ #ifndef TVM_RUNTIME_SPIRV_SPIRV_SHADER_H_ #define TVM_RUNTIME_SPIRV_SPIRV_SHADER_H_ +#include +#include #include #include #include -#include #include diff --git a/src/runtime/static_library.cc b/src/runtime/static_library.cc index 3eae0cb73940..08beb8cbc530 100644 --- a/src/runtime/static_library.cc +++ b/src/runtime/static_library.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include diff --git a/src/runtime/thread_pool.cc b/src/runtime/thread_pool.cc index e3a3a0a8fc63..d266fb7da8fa 100644 --- a/src/runtime/thread_pool.cc +++ b/src/runtime/thread_pool.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include #if TVM_THREADPOOL_USE_OPENMP #include diff --git a/src/runtime/thread_storage_scope.h b/src/runtime/thread_storage_scope.h index 049e6467d1fc..914fe67819de 100644 --- a/src/runtime/thread_storage_scope.h +++ b/src/runtime/thread_storage_scope.h @@ -24,7 +24,7 @@ #ifndef TVM_RUNTIME_THREAD_STORAGE_SCOPE_H_ #define TVM_RUNTIME_THREAD_STORAGE_SCOPE_H_ -#include +#include #include #include diff --git a/src/runtime/vulkan/vulkan_common.h b/src/runtime/vulkan/vulkan_common.h index c1961d8065ae..fb4776c98afc 100644 --- a/src/runtime/vulkan/vulkan_common.h +++ b/src/runtime/vulkan/vulkan_common.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include diff --git a/src/target/datatype/registry.cc b/src/target/datatype/registry.cc index 2c1fc84d4084..88f96b6a707b 100644 --- a/src/target/datatype/registry.cc +++ b/src/target/datatype/registry.cc @@ -19,6 +19,7 @@ #include "registry.h" #include +#include namespace tvm { namespace datatype { diff --git a/src/target/datatype/registry.h b/src/target/datatype/registry.h index eba7739a6b86..b1a1a4a7f50b 100644 --- a/src/target/datatype/registry.h +++ b/src/target/datatype/registry.h @@ -21,7 +21,6 @@ #define TVM_TARGET_DATATYPE_REGISTRY_H_ #include -#include #include #include diff --git a/src/target/llvm/llvm_module.cc b/src/target/llvm/llvm_module.cc index e5b2fc47ec8d..ed70d8692635 100644 --- a/src/target/llvm/llvm_module.cc +++ b/src/target/llvm/llvm_module.cc @@ -62,7 +62,6 @@ #include #include #include -#include #include #include #include diff --git a/src/target/source/source_module.cc b/src/target/source/source_module.cc index 054edd861adc..5e1f132fb5a5 100644 --- a/src/target/source/source_module.cc +++ b/src/target/source/source_module.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/src/target/spirv/ir_builder.h b/src/target/spirv/ir_builder.h index 057007be72ac..5df779c59547 100644 --- a/src/target/spirv/ir_builder.h +++ b/src/target/spirv/ir_builder.h @@ -24,7 +24,7 @@ #ifndef TVM_TARGET_SPIRV_IR_BUILDER_H_ #define TVM_TARGET_SPIRV_IR_BUILDER_H_ -#include +#include #include // clang-format off diff --git a/src/tir/transforms/make_packed_api.cc b/src/tir/transforms/make_packed_api.cc index 83ce75cead19..340e018a8db8 100644 --- a/src/tir/transforms/make_packed_api.cc +++ b/src/tir/transforms/make_packed_api.cc @@ -22,6 +22,7 @@ */ #include #include +#include #include #include #include diff --git a/src/topi/broadcast.cc b/src/topi/broadcast.cc index 2a868145c94e..1ee85e7b8c95 100644 --- a/src/topi/broadcast.cc +++ b/src/topi/broadcast.cc @@ -22,7 +22,6 @@ * \file broadcast.cc */ #include -#include #include #include diff --git a/src/topi/elemwise.cc b/src/topi/elemwise.cc index 05e59b971371..13947abcf604 100644 --- a/src/topi/elemwise.cc +++ b/src/topi/elemwise.cc @@ -22,7 +22,6 @@ * \file elemwise.cc */ #include -#include #include namespace tvm { diff --git a/src/topi/nn.cc b/src/topi/nn.cc index 68ba43090ac9..7fef93550d37 100644 --- a/src/topi/nn.cc +++ b/src/topi/nn.cc @@ -22,7 +22,6 @@ * \file nn.cc */ #include -#include #include #include #include diff --git a/src/topi/reduction.cc b/src/topi/reduction.cc index 1720ddd60230..f8920bdefd46 100644 --- a/src/topi/reduction.cc +++ b/src/topi/reduction.cc @@ -22,7 +22,6 @@ * \file reduction.cc */ #include -#include #include #include diff --git a/src/topi/transform.cc b/src/topi/transform.cc index 50aa50638266..5826fdac864f 100644 --- a/src/topi/transform.cc +++ b/src/topi/transform.cc @@ -22,7 +22,6 @@ * \file transform.cc */ #include -#include #include #include #include diff --git a/src/topi/utils.cc b/src/topi/utils.cc index 66da512a66e0..9a668ad2ac17 100644 --- a/src/topi/utils.cc +++ b/src/topi/utils.cc @@ -23,7 +23,6 @@ */ #include -#include #include namespace tvm { diff --git a/src/topi/vision.cc b/src/topi/vision.cc index 844f8f94592e..57d936268010 100644 --- a/src/topi/vision.cc +++ b/src/topi/vision.cc @@ -22,7 +22,6 @@ * \file vision.cc */ #include -#include #include namespace tvm { diff --git a/tests/cpp-runtime/hexagon/run_all_tests.cc b/tests/cpp-runtime/hexagon/run_all_tests.cc index 313b149e0987..cf8160971a51 100644 --- a/tests/cpp-runtime/hexagon/run_all_tests.cc +++ b/tests/cpp-runtime/hexagon/run_all_tests.cc @@ -19,7 +19,6 @@ #include #include -#include #include #include diff --git a/tests/cpp-runtime/hexagon/run_unit_tests.cc b/tests/cpp-runtime/hexagon/run_unit_tests.cc index 9b55151638e6..a4c613b41140 100644 --- a/tests/cpp-runtime/hexagon/run_unit_tests.cc +++ b/tests/cpp-runtime/hexagon/run_unit_tests.cc @@ -19,7 +19,6 @@ #include #include -#include #include #include diff --git a/tests/cpp/llvm_codegen_registry_test.cc b/tests/cpp/llvm_codegen_registry_test.cc index 49457fd0dac5..b5cea29c6b27 100644 --- a/tests/cpp/llvm_codegen_registry_test.cc +++ b/tests/cpp/llvm_codegen_registry_test.cc @@ -22,7 +22,6 @@ #include #include #include -#include #include diff --git a/tests/python/relax/frontend_nn_extern_module.cc b/tests/python/relax/frontend_nn_extern_module.cc index 09adbe9780d6..1bac39b35091 100644 --- a/tests/python/relax/frontend_nn_extern_module.cc +++ b/tests/python/relax/frontend_nn_extern_module.cc @@ -21,8 +21,8 @@ * \brief Testing code to be compiled by Relax nn.SourceModule */ #include +#include #include -#include namespace { @@ -65,5 +65,5 @@ int _test_sym(DLTensor* a, DLTensor* b, DLTensor* c) { return 0; } } // namespace -TVM_DLL_EXPORT_TYPED_FUNC(ext_scalar_add, _scalar_add); -TVM_DLL_EXPORT_TYPED_FUNC(ext_test_sym, _test_sym); +TVM_FFI_DLL_EXPORT_TYPED_FUNC(ext_scalar_add, _scalar_add); +TVM_FFI_DLL_EXPORT_TYPED_FUNC(ext_test_sym, _test_sym);