diff --git a/3rdparty/cutlass_fpA_intB_gemm b/3rdparty/cutlass_fpA_intB_gemm index 6ad91366619e..72b9883c986a 160000 --- a/3rdparty/cutlass_fpA_intB_gemm +++ b/3rdparty/cutlass_fpA_intB_gemm @@ -1 +1 @@ -Subproject commit 6ad91366619e20129c5f77d02c82098d13b287a5 +Subproject commit 72b9883c986a2ff427ca61ac0b14ad59be1dc862 diff --git a/apps/cpp_rpc/rpc_server.cc b/apps/cpp_rpc/rpc_server.cc index 797692d0f503..fd8fc476bbec 100644 --- a/apps/cpp_rpc/rpc_server.cc +++ b/apps/cpp_rpc/rpc_server.cc @@ -399,9 +399,9 @@ void RPCServerCreate(std::string host, int port, int port_end, std::string track rpc.Start(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("rpc.ServerCreate", RPCServerCreate); -}); +} } // namespace runtime } // namespace tvm diff --git a/apps/ios_rpc/tvmrpc/TVMRuntime.mm b/apps/ios_rpc/tvmrpc/TVMRuntime.mm index 47e82a7f96be..8831210242bd 100644 --- a/apps/ios_rpc/tvmrpc/TVMRuntime.mm +++ b/apps/ios_rpc/tvmrpc/TVMRuntime.mm @@ -52,7 +52,7 @@ void LogMessageImpl(const std::string& file, int lineno, int level, const std::s } // namespace detail -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.rpc.server.workpath", @@ -85,7 +85,7 @@ void LogMessageImpl(const std::string& file, int lineno, int level, const std::s *rv = Module::LoadFromFile(name, fmt); LOG(INFO) << "Load module from " << name << " ..."; }); -}); +} #if defined(USE_CUSTOM_DSO_LOADER) && USE_CUSTOM_DSO_LOADER == 1 @@ -112,7 +112,7 @@ void Init(const std::string& name) { }; // Add UnsignedDSOLoader plugin in global registry -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("ffi.Module.load_from_file.dylib_custom", [](ffi::PackedArgs args, ffi::Any* rv) { @@ -120,7 +120,7 @@ void Init(const std::string& name) { n->Init(args[0]); *rv = tvm::ffi::CreateLibraryModule(n); }); -}); +} #endif diff --git a/docs/arch/device_target_interactions.rst b/docs/arch/device_target_interactions.rst index 6a80418be798..aa7f5e67854c 100644 --- a/docs/arch/device_target_interactions.rst +++ b/docs/arch/device_target_interactions.rst @@ -153,10 +153,10 @@ then be registered with the following steps. #. Register the function to the tvm registry:: - TVM_FFI_STATIC_INIT_BLOCK({ + TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("device_api.foo", FooDeviceAPI::Global); - }); + } .. _base.h: https://github.com/apache/tvm/blob/main/include/tvm/runtime/base.h @@ -228,10 +228,10 @@ the same name as was used in the ``TVM_REGISTER_TARGET_KIND`` definition above. :: tvm::runtime::Module GeneratorFooCode(IRModule mod, Target target); - TVM_FFI_STATIC_INIT_BLOCK({ + TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("target.build.foo", GeneratorFooCode); - }); + } The code generator takes two arguments. The first is the ``IRModule`` to compile, and the second is the ``Target`` that describes the device diff --git a/docs/arch/pass_infra.rst b/docs/arch/pass_infra.rst index 2b878e52a21c..ef3672058c61 100644 --- a/docs/arch/pass_infra.rst +++ b/docs/arch/pass_infra.rst @@ -376,10 +376,10 @@ Python when needed. return CreateFunctionPass(pass_func, 0, "FoldConstant", {}); } - TVM_FFI_STATIC_INIT_BLOCK({ + TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.FoldConstant", FoldConstant); - }); + } } // namespace transform diff --git a/docs/arch/runtime.rst b/docs/arch/runtime.rst index d8dca0690a16..99c83de8376a 100644 --- a/docs/arch/runtime.rst +++ b/docs/arch/runtime.rst @@ -80,10 +80,10 @@ The following example registers PackedFunc in C++ and calls from python. .. code:: c // register a global packed function in c++ - TVM_FFI_STATIC_INIT_BLOCK({ + TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("myadd", MyAdd); - }); + } .. code:: python @@ -112,13 +112,13 @@ we can pass functions from python (as PackedFunc) to C++. .. code:: c - TVM_FFI_STATIC_INIT_BLOCK({ + TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("callhello", [](ffi::PackedArgs args, ffi::Any* rv) { ffi::Function f = args[0].cast(); f("hello world"); }); - }); + } .. code:: python @@ -230,7 +230,7 @@ Each ``Object`` subclass will override this to register its members. Here is an TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.IntImm", IntImmNode, PrimExprNode); }; // in cc file - TVM_FFI_STATIC_INIT_BLOCK({ IntImmNode::RegisterReflection(); }); + TVM_FFI_STATIC_INIT_BLOCK() { IntImmNode::RegisterReflection(); } The RegisterReflection gives us a reflection API to register each member of the object. We can use this function to visit the node and serialize any language object recursively. diff --git a/ffi/docs/guides/packaging.md b/ffi/docs/guides/packaging.md index 1ae9bc673010..c12fe4e30719 100644 --- a/ffi/docs/guides/packaging.md +++ b/ffi/docs/guides/packaging.md @@ -161,11 +161,11 @@ void RaiseError(ffi::String msg) { TVM_FFI_THROW(RuntimeError) << msg; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("my_ffi_extension.raise_error", RaiseError); -}); +} ``` Make sure to have a unique name across all registered functions when registering a global function. diff --git a/ffi/docs/guides/python_guide.md b/ffi/docs/guides/python_guide.md index b7cff501c191..0ab56eb9c461 100644 --- a/ffi/docs/guides/python_guide.md +++ b/ffi/docs/guides/python_guide.md @@ -203,7 +203,7 @@ public: TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(TestIntPair, tvm::ffi::ObjectRef, TestIntPairObj); }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; // register the object into the system // register field accessors and a global static function `__create__` as ffi::Function @@ -213,7 +213,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_static("__create__", [](int64_t a, int64_t b) -> TestIntPair { return TestIntPair(a, b); }); -}); +} ``` You can then create wrapper classes for objects that are in the library as follows: diff --git a/ffi/examples/packaging/src/extension.cc b/ffi/examples/packaging/src/extension.cc index 7a2eb1514851..6a7324f4108e 100644 --- a/ffi/examples/packaging/src/extension.cc +++ b/ffi/examples/packaging/src/extension.cc @@ -62,7 +62,7 @@ TVM_FFI_DLL_EXPORT_TYPED_FUNC(add_one, my_ffi_extension::AddOne); // The static initialization block is // called once when the library is loaded. -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; // In this particular example, we use the reflection mechanisms to // register the functions directly into the global function table. @@ -85,5 +85,5 @@ TVM_FFI_STATIC_INIT_BLOCK({ // tvm::ffi::Module::LoadFromFile, instead, just load the dll or simply bundle into the // final project refl::GlobalDef().def("my_ffi_extension.raise_error", RaiseError); -}); +} } // namespace my_ffi_extension diff --git a/ffi/include/tvm/ffi/base_details.h b/ffi/include/tvm/ffi/base_details.h index 80cd889ddb30..c20f0e5c05cf 100644 --- a/ffi/include/tvm/ffi/base_details.h +++ b/ffi/include/tvm/ffi/base_details.h @@ -72,9 +72,6 @@ #define TVM_FFI_UNREACHABLE() __builtin_unreachable() #endif -/*! \brief helper macro to suppress unused warning */ -#define TVM_FFI_ATTRIBUTE_UNUSED [[maybe_unused]] - #define TVM_FFI_STR_CONCAT_(__x, __y) __x##__y #define TVM_FFI_STR_CONCAT(__x, __y) TVM_FFI_STR_CONCAT_(__x, __y) @@ -86,12 +83,39 @@ #define TVM_FFI_FUNC_SIG __func__ #endif -#define TVM_FFI_STATIC_INIT_BLOCK_VAR_DEF \ - TVM_FFI_ATTRIBUTE_UNUSED static inline int __##TVMFFIStaticInitReg +#if defined(__GNUC__) +// gcc and clang and attribute constructor +/// \cond Doxygen_Suppress +#define TVM_FFI_STATIC_INIT_BLOCK_DEF_(FnName) __attribute__((constructor)) static void FnName() +/// \endcond +/* + * \brief Macro that defines a block that will be called during static initialization. + * + * \code + * TVM_FFI_STATIC_INIT_BLOCK() { + * RegisterFunctions(); + * } + * \endcode + */ +#define TVM_FFI_STATIC_INIT_BLOCK() \ + TVM_FFI_STATIC_INIT_BLOCK_DEF_(TVM_FFI_STR_CONCAT(__TVMFFIStaticInitFunc, __COUNTER__)) -/*! \brief helper macro to run code once during initialization */ -#define TVM_FFI_STATIC_INIT_BLOCK(Body) \ - TVM_FFI_STR_CONCAT(TVM_FFI_STATIC_INIT_BLOCK_VAR_DEF, __COUNTER__) = []() { Body return 0; }() +#else +/// \cond Doxygen_Suppress +// for other compilers, use the variable trick +#define TVM_FFI_STATIC_INIT_BLOCK_DEF_(FnName, RegVar) \ + static void FnName(); \ + [[maybe_unused]] static inline int RegVar = []() { \ + FnName(); \ + return 0; \ + }(); \ + static void FnName() + +#define TVM_FFI_STATIC_INIT_BLOCK() \ + TVM_FFI_STATIC_INIT_BLOCK_DEF_(TVM_FFI_STR_CONCAT(__TVMFFIStaticInitFunc, __COUNTER__), \ + TVM_FFI_STR_CONCAT(__TVMFFIStaticInitReg, __COUNTER__)) +/// \endcond +#endif /* * \brief Define the default copy/move constructor and assign operator diff --git a/ffi/src/ffi/container.cc b/ffi/src/ffi/container.cc index 858cbd47c771..5cf692ac2a18 100644 --- a/ffi/src/ffi/container.cc +++ b/ffi/src/ffi/container.cc @@ -56,7 +56,7 @@ class MapForwardIterFunctor { ffi::MapObj::iterator end_; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("ffi.Array", @@ -83,6 +83,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("ffi.MapForwardIterFunctor", [](const ffi::MapObj* n) -> ffi::Function { return ffi::Function::FromTyped(MapForwardIterFunctor(n->begin(), n->end())); }); -}); +} } // namespace ffi } // namespace tvm diff --git a/ffi/src/ffi/extra/json_parser.cc b/ffi/src/ffi/extra/json_parser.cc index c346e0d4a158..dddb782d448e 100644 --- a/ffi/src/ffi/extra/json_parser.cc +++ b/ffi/src/ffi/extra/json_parser.cc @@ -720,11 +720,11 @@ json::Value Parse(const String& json_str, String* error_msg) { return JSONParser::Parse(json_str, error_msg); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ffi.json.Parse", [](const String& json_str) { return json::Parse(json_str); }); -}); +} } // namespace json } // namespace ffi diff --git a/ffi/src/ffi/extra/json_writer.cc b/ffi/src/ffi/extra/json_writer.cc index c2cd3f2f36d3..1a4636d2ecd3 100644 --- a/ffi/src/ffi/extra/json_writer.cc +++ b/ffi/src/ffi/extra/json_writer.cc @@ -295,10 +295,10 @@ String Stringify(const json::Value& value, Optional indent) { return JSONWriter::Stringify(value, indent); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ffi.json.Stringify", Stringify); -}); +} } // namespace json } // namespace ffi diff --git a/ffi/src/ffi/extra/library_module_dynamic_lib.cc b/ffi/src/ffi/extra/library_module_dynamic_lib.cc index e85b05180baf..34072aad5a8e 100644 --- a/ffi/src/ffi/extra/library_module_dynamic_lib.cc +++ b/ffi/src/ffi/extra/library_module_dynamic_lib.cc @@ -108,11 +108,11 @@ void DSOLibrary::Unload() { } #endif -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ffi.Module.load_from_file.so", [](String library_path, String) { return CreateLibraryModule(make_object(library_path)); }); -}); +} } // namespace ffi } // namespace tvm diff --git a/ffi/src/ffi/extra/library_module_system_lib.cc b/ffi/src/ffi/extra/library_module_system_lib.cc index 9d077fec33ed..3a614738a04f 100644 --- a/ffi/src/ffi/extra/library_module_system_lib.cc +++ b/ffi/src/ffi/extra/library_module_system_lib.cc @@ -124,7 +124,7 @@ class SystemLibModuleRegistry { Map lib_map_; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("ffi.SystemLib", [](ffi::PackedArgs args, ffi::Any* rv) { String symbol_prefix = ""; @@ -133,7 +133,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } *rv = SystemLibModuleRegistry::Global()->GetOrCreateModule(symbol_prefix); }); -}); +} } // namespace ffi } // namespace tvm diff --git a/ffi/src/ffi/extra/module.cc b/ffi/src/ffi/extra/module.cc index 9450917bc5f2..d2ebcd121dfc 100644 --- a/ffi/src/ffi/extra/module.cc +++ b/ffi/src/ffi/extra/module.cc @@ -119,7 +119,7 @@ Module Module::LoadFromFile(const String& file_name) { return (*floader)(file_name, format).cast(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; ModuleObj::InternalUnsafe::RegisterReflection(); @@ -144,7 +144,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_method("ffi.ModuleWriteToFile", &ModuleObj::WriteToFile) .def_method("ffi.ModuleImportModule", &ModuleObj::ImportModule) .def_method("ffi.ModuleClearImports", &ModuleObj::ClearImports); -}); +} } // namespace ffi } // namespace tvm diff --git a/ffi/src/ffi/extra/reflection_extra.cc b/ffi/src/ffi/extra/reflection_extra.cc index 698be6337698..f92364370f17 100644 --- a/ffi/src/ffi/extra/reflection_extra.cc +++ b/ffi/src/ffi/extra/reflection_extra.cc @@ -132,12 +132,12 @@ inline void AccessPathRegisterReflection() { [](const AccessPath& self, const AccessPath& other) { return self->PathEqual(other); }); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; AccessStepRegisterReflection(); AccessPathRegisterReflection(); refl::GlobalDef().def_packed("ffi.MakeObjectFromPackedArgs", MakeObjectFromPackedArgs); -}); +} } // namespace reflection } // namespace ffi diff --git a/ffi/src/ffi/extra/serialization.cc b/ffi/src/ffi/extra/serialization.cc index ea9a96b696ec..14c784428ed5 100644 --- a/ffi/src/ffi/extra/serialization.cc +++ b/ffi/src/ffi/extra/serialization.cc @@ -415,7 +415,7 @@ String ToJSONGraphString(const Any& value, const Any& metadata) { return json::Stringify(ToJSONGraph(value, metadata)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ffi.ToJSONGraph", ToJSONGraph) @@ -424,7 +424,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("ffi.FromJSONGraphString", FromJSONGraphString); refl::EnsureTypeAttrColumn("__data_to_json__"); refl::EnsureTypeAttrColumn("__data_from_json__"); -}); +} } // namespace ffi } // namespace tvm diff --git a/ffi/src/ffi/extra/structural_equal.cc b/ffi/src/ffi/extra/structural_equal.cc index 976ba4ecf4d8..ccedfcb7a8b1 100644 --- a/ffi/src/ffi/extra/structural_equal.cc +++ b/ffi/src/ffi/extra/structural_equal.cc @@ -428,12 +428,12 @@ Optional StructuralEqual::GetFirstMismatch(const Any return reflection::AccessPathPair(lhs_path, rhs_path); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ffi.GetFirstStructuralMismatch", StructuralEqual::GetFirstMismatch); // ensure the type attribute column is presented in the system even if it is empty. refl::EnsureTypeAttrColumn("__s_equal__"); -}); +} } // namespace ffi } // namespace tvm diff --git a/ffi/src/ffi/extra/structural_hash.cc b/ffi/src/ffi/extra/structural_hash.cc index 2eb9843fed4f..f6463afa9cff 100644 --- a/ffi/src/ffi/extra/structural_hash.cc +++ b/ffi/src/ffi/extra/structural_hash.cc @@ -307,11 +307,11 @@ uint64_t StructuralHash::Hash(const Any& value, bool map_free_vars, bool skip_te return handler.HashAny(value); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ffi.StructuralHash", StructuralHash::Hash); refl::EnsureTypeAttrColumn("__s_hash__"); -}); +} } // namespace ffi } // namespace tvm diff --git a/ffi/src/ffi/extra/testing.cc b/ffi/src/ffi/extra/testing.cc index 54bf7ba35234..3d9501d8c460 100644 --- a/ffi/src/ffi/extra/testing.cc +++ b/ffi/src/ffi/extra/testing.cc @@ -55,14 +55,14 @@ class TestIntPair : public tvm::ffi::ObjectRef { TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(TestIntPair, tvm::ffi::ObjectRef, TestIntPairObj); }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::ObjectDef() .def_ro("a", &TestIntPairObj::a) .def_ro("b", &TestIntPairObj::b) .def_static("__create__", [](int64_t a, int64_t b) -> TestIntPair { return TestIntPair(a, b); }); -}); +} class TestObjectBase : public Object { public: @@ -98,7 +98,7 @@ TVM_FFI_NO_INLINE void TestApply(PackedArgs args, Any* ret) { f.CallPacked(args.Slice(1), ret); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::ObjectDef() @@ -127,7 +127,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ std::cout << "Function finished without catching signal" << std::endl; }) .def("testing.object_use_count", [](const Object* obj) { return obj->use_count(); }); -}); +} } // namespace ffi } // namespace tvm diff --git a/ffi/src/ffi/function.cc b/ffi/src/ffi/function.cc index ca587c6f9e5f..b1bee7ee506c 100644 --- a/ffi/src/ffi/function.cc +++ b/ffi/src/ffi/function.cc @@ -200,7 +200,7 @@ int TVMFFIFunctionCall(TVMFFIObjectHandle func, TVMFFIAny* args, int32_t num_arg #endif } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ffi.FunctionRemoveGlobal", @@ -226,4 +226,4 @@ TVM_FFI_STATIC_INIT_BLOCK({ }) .def("ffi.String", [](tvm::ffi::String val) -> tvm::ffi::String { return val; }) .def("ffi.Bytes", [](tvm::ffi::Bytes val) -> tvm::ffi::Bytes { return val; }); -}); +} diff --git a/ffi/src/ffi/tensor.cc b/ffi/src/ffi/tensor.cc index c166c296c8a4..d40828012fb1 100644 --- a/ffi/src/ffi/tensor.cc +++ b/ffi/src/ffi/tensor.cc @@ -28,7 +28,7 @@ namespace tvm { namespace ffi { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("ffi.Shape", [](ffi::PackedArgs args, Any* ret) { int64_t* mutable_data; @@ -42,7 +42,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } *ret = details::ObjectUnsafe::ObjectRefFromObjectPtr(shape); }); -}); +} } // namespace ffi } // namespace tvm diff --git a/ffi/tests/cpp/test_reflection.cc b/ffi/tests/cpp/test_reflection.cc index 8de408de2647..c9aa500aeb41 100644 --- a/ffi/tests/cpp/test_reflection.cc +++ b/ffi/tests/cpp/test_reflection.cc @@ -46,7 +46,7 @@ struct TestObjADerived : public TestObjA { TVM_FFI_DECLARE_OBJECT_INFO_FINAL("test.TestObjADerived", TestObjADerived, TestObjA); }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; TIntObj::RegisterReflection(); @@ -58,7 +58,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ refl::ObjectDef().def_ro("x", &TestObjA::x).def_rw("y", &TestObjA::y); refl::ObjectDef().def_ro("z", &TestObjADerived::z); -}); +} TEST(Reflection, GetFieldByteOffset) { EXPECT_EQ(reflection::GetFieldByteOffsetToObject(&TestObjA::x), sizeof(TVMFFIObject)); @@ -147,10 +147,10 @@ TEST(Reflection, TypeAttrColumn) { EXPECT_EQ(size_attr[TIntObj::_type_index].cast(), sizeof(TIntObj)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_method("testing.Int_GetValue", &TIntObj::GetValue); -}); +} TEST(Reflection, FuncRegister) { Function fget_value = Function::GetGlobalRequired("testing.Int_GetValue"); diff --git a/include/tvm/runtime/profiling.h b/include/tvm/runtime/profiling.h index 32035e63f960..c04310d9db20 100644 --- a/include/tvm/runtime/profiling.h +++ b/include/tvm/runtime/profiling.h @@ -134,12 +134,12 @@ class Timer : public ObjectRef { * }; * * - * TVM_FFI_STATIC_INIT_BLOCK({ + * TVM_FFI_STATIC_INIT_BLOCK() { * namespace refl = tvm::ffi::reflection; * refl::GlobalDef().def("profiling.timer.cpu", [](Device dev) { * return Timer(ffi::make_object()); * }); - * }); + * } * \endcode */ static TVM_DLL Timer Start(Device dev); diff --git a/python/tvm/contrib/msc/plugin/codegen/sources.py b/python/tvm/contrib/msc/plugin/codegen/sources.py index a4e89ad7ecd2..a0923cd3210e 100644 --- a/python/tvm/contrib/msc/plugin/codegen/sources.py +++ b/python/tvm/contrib/msc/plugin/codegen/sources.py @@ -686,14 +686,14 @@ class TVMUtils { }; #define TVM_MSC_PLUGIN_REGISTER_GLOBAL_DEF(FuncName, Body) \ - TVM_FFI_STATIC_INIT_BLOCK({ \ + TVM_FFI_STATIC_INIT_BLOCK() { \ tvm::ffi::reflection::GlobalDef().def(FuncName, Body); \ - }) + } #define TVM_MSC_PLUGIN_REGISTER_GLOBAL_DEF_PACKED(FuncName, Body) \ - TVM_FFI_STATIC_INIT_BLOCK({ \ + TVM_FFI_STATIC_INIT_BLOCK() { \ tvm::ffi::reflection::GlobalDef().def_packed(FuncName, Body); \ - }) + } #endif // PLUGIN_SUPPORT_TVM """ @@ -1162,4 +1162,7 @@ def get_plugin_sources() -> Dict[str, str]: The base utils sources. """ - return {"plugin_base.h": get_plugin_base_h_code(), "plugin_utils.h": get_plugin_utils_h_code()} + return { + "plugin_base.h": get_plugin_base_h_code(), + "plugin_utils.h": get_plugin_utils_h_code(), + } diff --git a/src/arith/analyzer.cc b/src/arith/analyzer.cc index a96f3cdf223b..f6f0b9f4d8df 100644 --- a/src/arith/analyzer.cc +++ b/src/arith/analyzer.cc @@ -270,7 +270,7 @@ PrimExpr Analyzer::Simplify(const PrimExpr& expr, int steps) { return res; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("arith.CreateAnalyzer", [](ffi::PackedArgs args, ffi::Any* ret) { using ffi::Function; @@ -365,7 +365,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ }; *ret = ffi::TypedFunction(f); }); -}); +} } // namespace arith } // namespace tvm diff --git a/src/arith/bound_deducer.cc b/src/arith/bound_deducer.cc index ed941c7dbdad..eb9edca36341 100644 --- a/src/arith/bound_deducer.cc +++ b/src/arith/bound_deducer.cc @@ -403,14 +403,14 @@ IntSet DeduceBound(PrimExpr v, PrimExpr e, const ffi::Map& hint_map return DeduceBound(v, e, hmap, rmap); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.DeduceBound", [](PrimExpr v, PrimExpr cond, const ffi::Map hint_map, const ffi::Map relax_map) { return DeduceBound(v, cond, hint_map, relax_map); }); -}); +} } // namespace arith } // namespace tvm diff --git a/src/arith/const_int_bound.cc b/src/arith/const_int_bound.cc index 9f5a0ab00084..b8e5db483f4f 100644 --- a/src/arith/const_int_bound.cc +++ b/src/arith/const_int_bound.cc @@ -39,7 +39,7 @@ namespace arith { using namespace tir; -TVM_FFI_STATIC_INIT_BLOCK({ ConstIntBoundNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ConstIntBoundNode::RegisterReflection(); } ConstIntBound::ConstIntBound(int64_t min_value, int64_t max_value) { auto node = ffi::make_object(); @@ -52,10 +52,10 @@ ConstIntBound MakeConstIntBound(int64_t min_value, int64_t max_value) { return ConstIntBound(min_value, max_value); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.ConstIntBound", MakeConstIntBound); -}); +} inline void PrintBoundValue(std::ostream& os, int64_t val) { if (val == ConstIntBound::kPosInf) { diff --git a/src/arith/detect_common_subexpr.cc b/src/arith/detect_common_subexpr.cc index a10105f7c3c8..70768128e535 100644 --- a/src/arith/detect_common_subexpr.cc +++ b/src/arith/detect_common_subexpr.cc @@ -70,9 +70,9 @@ ffi::Map DetectCommonSubExpr(const PrimExpr& e, int thresh) { return results; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.DetectCommonSubExpr", DetectCommonSubExpr); -}); +} } // namespace arith } // namespace tvm diff --git a/src/arith/detect_linear_equation.cc b/src/arith/detect_linear_equation.cc index d86dace8725d..4a0b5f9cf0c3 100644 --- a/src/arith/detect_linear_equation.cc +++ b/src/arith/detect_linear_equation.cc @@ -291,12 +291,12 @@ ffi::Array DetectClipBound(const PrimExpr& e, const ffi::Array& v return ret; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("arith.DetectLinearEquation", DetectLinearEquation) .def("arith.DetectClipBound", [](const PrimExpr& e, const ffi::Array& vars) { return DetectClipBound(e, vars); }); -}); +} } // namespace arith } // namespace tvm diff --git a/src/arith/domain_touched.cc b/src/arith/domain_touched.cc index 319f786f6a37..3fc6d34b7071 100644 --- a/src/arith/domain_touched.cc +++ b/src/arith/domain_touched.cc @@ -163,12 +163,12 @@ ffi::Map> DomainTouchedAccessMap(const PrimFunc& f return ret; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("arith.DomainTouched", DomainTouched) .def("arith.DomainTouchedAccessMap", DomainTouchedAccessMap); -}); +} } // namespace arith } // namespace tvm diff --git a/src/arith/int_constraints.cc b/src/arith/int_constraints.cc index eec0fd2ef1b7..e116ba9e3b7a 100644 --- a/src/arith/int_constraints.cc +++ b/src/arith/int_constraints.cc @@ -39,11 +39,11 @@ namespace tvm { namespace arith { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { IntGroupBoundsNode::RegisterReflection(); IntConstraintsNode::RegisterReflection(); IntConstraintsTransformNode::RegisterReflection(); -}); +} ffi::Array AsConditions(const ffi::Array& variables, const ffi::Map& bounds, @@ -201,7 +201,7 @@ Range IntGroupBounds::FindBestRange(const ffi::Map& vranges_addl) co return Range::FromMinExtent(best_lower, analyzer.Simplify(best_diff_over + 1)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("arith.IntGroupBounds", @@ -217,7 +217,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ *ret = bounds.FindBestRange(args[1].cast>()); } }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { @@ -246,14 +246,14 @@ IntConstraints::IntConstraints(ffi::Array variables, ffi::Map r data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "arith.IntConstraints", [](ffi::Array variables, ffi::Map ranges, ffi::Array relations) { return IntConstraints(variables, ranges, relations); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { @@ -293,14 +293,14 @@ IntConstraintsTransform IntConstraintsTransform::operator+( return IntConstraintsTransform(operator->()->src, other->dst, src_to_dst, dst_to_src); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.IntConstraintsTransform", [](IntConstraints src, IntConstraints dst, ffi::Map src_to_dst, ffi::Map dst_to_src) { return IntConstraintsTransform(src, dst, src_to_dst, dst_to_src); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { diff --git a/src/arith/int_set.cc b/src/arith/int_set.cc index b37680376a35..aa15284b3e03 100644 --- a/src/arith/int_set.cc +++ b/src/arith/int_set.cc @@ -44,7 +44,7 @@ using tir::is_zero; using tir::make_const; using tir::make_zero; -TVM_FFI_STATIC_INIT_BLOCK({ IntervalSetNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { IntervalSetNode::RegisterReflection(); } PrimExpr SymbolicLimits::pos_inf_ = Var("pos_inf", DataType::Handle()); PrimExpr SymbolicLimits::neg_inf_ = Var("neg_inf", DataType::Handle()); @@ -60,10 +60,10 @@ IntervalSet MakeIntervalSet(PrimExpr min_value, PrimExpr max_value) { return IntervalSet(min_value, max_value); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.IntervalSet", MakeIntervalSet); -}); +} IntervalSet Intersect(Analyzer* analyzer, IntervalSet a, IntervalSet b) { PrimExpr max_value = min(a->max_value, b->max_value); @@ -1198,7 +1198,7 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) << "[" << op->min_value << ", " << op->max_value << ']'; }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("arith.intset_single_point", IntSet::SinglePoint) @@ -1229,7 +1229,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("arith.PosInf", []() { return SymbolicLimits::pos_inf_; }) .def("arith.NegInf", []() { return SymbolicLimits::neg_inf_; }) .def("arith.UnionLowerBound", UnionLowerBound); -}); +} } // namespace arith } // namespace tvm diff --git a/src/arith/iter_affine_map.cc b/src/arith/iter_affine_map.cc index e8c96c908a7b..3de431fb9574 100644 --- a/src/arith/iter_affine_map.cc +++ b/src/arith/iter_affine_map.cc @@ -41,12 +41,12 @@ namespace arith { using namespace tir; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { IterMarkNode::RegisterReflection(); IterSplitExprNode::RegisterReflection(); IterSumExprNode::RegisterReflection(); IterMapResultNode::RegisterReflection(); -}); +} IterMark::IterMark(PrimExpr source, PrimExpr extent) { auto n = ffi::make_object(); @@ -55,11 +55,11 @@ IterMark::IterMark(PrimExpr source, PrimExpr extent) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.IterMark", [](PrimExpr source, PrimExpr extent) { return IterMark(source, extent); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { @@ -100,13 +100,13 @@ IterSplitExpr::IterSplitExpr(IterMark source, PrimExpr lower_factor, PrimExpr ex data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.IterSplitExpr", [](IterMark source, PrimExpr lower_factor, PrimExpr extent, PrimExpr scale) { return IterSplitExpr(source, lower_factor, extent, scale); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { @@ -123,12 +123,12 @@ IterSumExpr::IterSumExpr(ffi::Array args, PrimExpr base) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.IterSumExpr", [](ffi::Array args, PrimExpr base) { return IterSumExpr(args, base); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { @@ -1524,7 +1524,7 @@ IterMapResult DetectIterMap(const ffi::Array& indices, return result; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "arith.DetectIterMap", @@ -1534,7 +1534,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return DetectIterMap(indices, input_iters, input_pred, IterMapLevel(check_level), &ana, simplify_trivial_iterators); }); -}); +} IterSumExpr NormalizeToIterSum(PrimExpr index, const ffi::Map& input_iters, arith::Analyzer* analyzer) { @@ -1552,14 +1552,14 @@ IterSumExpr NormalizeToIterSum(PrimExpr index, const ffi::Map& input return rewriter.RewriteToNormalizedIterSum(index); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.NormalizeToIterSum", [](PrimExpr index, const ffi::Map& input_iters) { arith::Analyzer ana; return NormalizeToIterSum(index, input_iters, &ana); }); -}); +} PrimExpr IterMapRewriter::VisitExpr_(const VarNode* op) { auto var = ffi::GetRef(op); @@ -2154,10 +2154,10 @@ PrimExpr NormalizeIterMapToExpr(const PrimExpr& expr) { return normalizer.Convert(expr); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.NormalizeIterMapToExpr", NormalizeIterMapToExpr); -}); +} ffi::Array IterMapSimplify(const ffi::Array& indices, const ffi::Map& input_iters, @@ -2187,7 +2187,7 @@ ffi::Array IterMapSimplify(const ffi::Array& indices, return simplified; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "arith.IterMapSimplify", @@ -2197,7 +2197,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return IterMapSimplify(indices, input_iters, input_pred, IterMapLevel(check_level), &ana, simplify_trivial_iterators); }); -}); +} /*! * \brief Divider to divide the bindings into two sets of bindings(outer and inner) @@ -2524,7 +2524,7 @@ ffi::Array> SubspaceDivide(const ffi::Array& bind return results; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "arith.SubspaceDivide", @@ -2535,7 +2535,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return SubspaceDivide(bindings, root_iters, sub_iters, predicate, IterMapLevel(check_level), &ana, simplify_trivial_iterators); }); -}); +} class InverseAffineIterMapTransformer { public: @@ -2668,10 +2668,10 @@ ffi::Map InverseAffineIterMap(const ffi::Array& iter return InverseAffineIterMapTransformer(&analyzer)(iter_map, outputs); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.InverseAffineIterMap", InverseAffineIterMap); -}); +} } // namespace arith } // namespace tvm diff --git a/src/arith/modular_set.cc b/src/arith/modular_set.cc index 1c8d1ba8b4d8..e69b8ad20e85 100644 --- a/src/arith/modular_set.cc +++ b/src/arith/modular_set.cc @@ -39,7 +39,7 @@ namespace arith { using namespace tir; -TVM_FFI_STATIC_INIT_BLOCK({ ModularSetNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ModularSetNode::RegisterReflection(); } ModularSet::ModularSet(int64_t coeff, int64_t base) { auto node = ffi::make_object(); @@ -58,10 +58,10 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) ModularSet MakeModularSet(int64_t coeff, int64_t base) { return ModularSet(coeff, base); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.ModularSet", MakeModularSet); -}); +} // internal entry for const int bound struct ModularSetAnalyzer::Entry { diff --git a/src/arith/narrow_predicate_expression.cc b/src/arith/narrow_predicate_expression.cc index c608de6b2c45..d73364cf45ca 100644 --- a/src/arith/narrow_predicate_expression.cc +++ b/src/arith/narrow_predicate_expression.cc @@ -214,10 +214,10 @@ PrimExpr NarrowPredicateExpression(PrimExpr expr, ffi::Map free_para return ExpressionNarrower::Apply(std::move(expr), std::move(free_parameters)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.NarrowPredicateExpression", NarrowPredicateExpression); -}); +} } // namespace arith } // namespace tvm diff --git a/src/arith/presburger_set.cc b/src/arith/presburger_set.cc index 8f2edb0c1360..3722837830d6 100644 --- a/src/arith/presburger_set.cc +++ b/src/arith/presburger_set.cc @@ -46,7 +46,7 @@ namespace arith { #ifdef TVM_MLIR_VERSION #if TVM_MLIR_VERSION >= 150 -TVM_FFI_STATIC_INIT_BLOCK({ PresburgerSetNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { PresburgerSetNode::RegisterReflection(); } using namespace tir; static void Update(const PrimExpr& constraint, PresburgerSetNode* intset) { @@ -275,10 +275,10 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) PresburgerSet MakePresburgerSet(const PrimExpr& constraint) { return PresburgerSet(constraint); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("arith.PresburgerSet", MakePresburgerSet); -}); +} } // namespace arith } // namespace tvm diff --git a/src/arith/rewrite_simplify.cc b/src/arith/rewrite_simplify.cc index 9ed30a9de0cd..e333f85a3279 100644 --- a/src/arith/rewrite_simplify.cc +++ b/src/arith/rewrite_simplify.cc @@ -44,7 +44,7 @@ namespace arith { using namespace tir; -TVM_FFI_STATIC_INIT_BLOCK({ RewriteSimplifierStatsNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { RewriteSimplifierStatsNode::RegisterReflection(); } // Note: When using matches_one_of or PMatchesOneOf alongside these // macros, be careful which patterns are used in the ResExpr. While diff --git a/src/arith/solve_linear_equation.cc b/src/arith/solve_linear_equation.cc index 2e1b725f83c5..8143892d9abd 100644 --- a/src/arith/solve_linear_equation.cc +++ b/src/arith/solve_linear_equation.cc @@ -456,7 +456,7 @@ IntConstraintsTransform SolveLinearEquations(const IntConstraints& system_to_sol return transform; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "arith.SolveLinearEquations", [](ffi::PackedArgs args, ffi::Any* ret) { @@ -473,7 +473,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ LOG(FATAL) << "arith.SolveLinearEquations expects 1 or 3 arguments, gets " << args.size(); } }); -}); +} } // namespace arith } // namespace tvm diff --git a/src/arith/solve_linear_inequality.cc b/src/arith/solve_linear_inequality.cc index bbca4ccbd97e..a46f9e520176 100644 --- a/src/arith/solve_linear_inequality.cc +++ b/src/arith/solve_linear_inequality.cc @@ -536,7 +536,7 @@ IntConstraintsTransform SolveInequalitiesDeskewRange(const IntConstraints& inequ return transform; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed( @@ -585,7 +585,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ << args.size(); } }); -}); +} } // namespace arith } // namespace tvm diff --git a/src/contrib/msc/core/ir/graph.cc b/src/contrib/msc/core/ir/graph.cc index 2d062d033bba..6e69e66bca01 100644 --- a/src/contrib/msc/core/ir/graph.cc +++ b/src/contrib/msc/core/ir/graph.cc @@ -1436,7 +1436,7 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) } }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { MSCTensorNode::RegisterReflection(); BaseJointNode::RegisterReflection(); MSCJointNode::RegisterReflection(); @@ -1445,9 +1445,9 @@ TVM_FFI_STATIC_INIT_BLOCK({ BaseGraphNode::RegisterReflection(); MSCGraphNode::RegisterReflection(); WeightGraphNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("msc.core.MSCTensor", @@ -1521,10 +1521,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ const ffi::Map& relation_wtypes) -> WeightGraph { return WeightGraph(graph, main_wtypes, relation_wtypes); }); -}); +} // MSC Graph APIS -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("msc.core.MSCGraphHasNode", @@ -1580,10 +1580,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ [](const ffi::String& graph_json) -> MSCGraph { return MSCGraph(graph_json); }) .def("msc.core.MSCGraphToPrototxt", [](const MSCGraph& graph) -> ffi::String { return graph->ToPrototxt(); }); -}); +} // Weight Graph APIS -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("msc.core.WeightGraphHasNode", @@ -1646,7 +1646,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("msc.core.PruneWeights", [](const MSCGraph& graph, const ffi::Map& pruned_tensors) -> MSCGraph { return PruneWeights(graph, pruned_tensors); }); -}); +} } // namespace msc } // namespace contrib diff --git a/src/contrib/msc/core/ir/graph_builder.cc b/src/contrib/msc/core/ir/graph_builder.cc index 67770a21f27a..df7a1520ebfa 100644 --- a/src/contrib/msc/core/ir/graph_builder.cc +++ b/src/contrib/msc/core/ir/graph_builder.cc @@ -839,7 +839,7 @@ void WeightsExtractor::VisitExpr_(const CallNode* op) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("msc.core.BuildFromRelax", @@ -858,7 +858,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ const auto& func = Downcast(module->Lookup(entry_name)); return WeightsExtractor(module).GetWeights(func); }); -}); +} } // namespace msc } // namespace contrib diff --git a/src/contrib/msc/core/ir/plugin.cc b/src/contrib/msc/core/ir/plugin.cc index 3c143b03ea18..1ff3a8dc8dcd 100644 --- a/src/contrib/msc/core/ir/plugin.cc +++ b/src/contrib/msc/core/ir/plugin.cc @@ -308,14 +308,14 @@ const Plugin GetPlugin(const ffi::String& name) { return PluginRegistry::Global( bool IsPlugin(const ffi::String& name) { return PluginRegistry::Global()->Registered(name); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { PluginAttrNode::RegisterReflection(); PluginTensorNode::RegisterReflection(); PluginExternNode::RegisterReflection(); PluginNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("msc.core.RegisterPlugin", @@ -327,7 +327,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("msc.core.GetPlugin", [](const ffi::String& name) -> Plugin { return GetPlugin(name); }) .def("msc.core.IsPlugin", [](const ffi::String& name) -> Bool { return Bool(IsPlugin(name)); }); -}); +} } // namespace msc } // namespace contrib diff --git a/src/contrib/msc/core/printer/msc_doc.cc b/src/contrib/msc/core/printer/msc_doc.cc index 40d1ada3b4d7..e1cae35be132 100644 --- a/src/contrib/msc/core/printer/msc_doc.cc +++ b/src/contrib/msc/core/printer/msc_doc.cc @@ -87,7 +87,7 @@ LambdaDoc::LambdaDoc(IdDoc name, ffi::Array args, ffi::Array this->data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { DeclareDocNode::RegisterReflection(); StrictListDocNode::RegisterReflection(); PointerDocNode::RegisterReflection(); @@ -95,7 +95,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ConstructorDocNode::RegisterReflection(); SwitchDocNode::RegisterReflection(); LambdaDocNode::RegisterReflection(); -}); +} } // namespace msc } // namespace contrib diff --git a/src/contrib/msc/core/transform/bind_named_params.cc b/src/contrib/msc/core/transform/bind_named_params.cc index 630f5d473ba8..992c514ad7ef 100644 --- a/src/contrib/msc/core/transform/bind_named_params.cc +++ b/src/contrib/msc/core/transform/bind_named_params.cc @@ -159,10 +159,10 @@ Pass BindNamedParams(ffi::String func_name, ffi::Map param return CreateModulePass(pass_func, 0, "BindNamedParams", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.BindNamedParams", BindNamedParams); -}); +} } // namespace transform diff --git a/src/contrib/msc/core/transform/bind_shape.cc b/src/contrib/msc/core/transform/bind_shape.cc index c85c821c145a..c9963ba94e84 100644 --- a/src/contrib/msc/core/transform/bind_shape.cc +++ b/src/contrib/msc/core/transform/bind_shape.cc @@ -134,10 +134,10 @@ Pass BindShape(const ffi::String& entry_name) { return CreateModulePass(pass_func, 0, "BindShape", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.BindShape", BindShape); -}); +} } // namespace transform } // namespace relax diff --git a/src/contrib/msc/core/transform/fuse_tuple.cc b/src/contrib/msc/core/transform/fuse_tuple.cc index 692ff826e150..6f2913ac9599 100644 --- a/src/contrib/msc/core/transform/fuse_tuple.cc +++ b/src/contrib/msc/core/transform/fuse_tuple.cc @@ -232,10 +232,10 @@ Pass FuseTuple(const ffi::String& target, const ffi::String& entry_name) { return CreateModulePass(pass_func, 0, "FuseTuple", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.FuseTuple", FuseTuple); -}); +} } // namespace transform } // namespace relax diff --git a/src/contrib/msc/core/transform/inline_params.cc b/src/contrib/msc/core/transform/inline_params.cc index eb59713e7111..9c5eb7536564 100644 --- a/src/contrib/msc/core/transform/inline_params.cc +++ b/src/contrib/msc/core/transform/inline_params.cc @@ -186,10 +186,10 @@ Pass InlineParams(const ffi::String& entry_name) { return CreateModulePass(pass_func, 0, "InlineParams", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.InlineParams", InlineParams); -}); +} } // namespace transform } // namespace relax diff --git a/src/contrib/msc/core/transform/set_byoc_attrs.cc b/src/contrib/msc/core/transform/set_byoc_attrs.cc index c6b35129a8df..16ce44cede16 100644 --- a/src/contrib/msc/core/transform/set_byoc_attrs.cc +++ b/src/contrib/msc/core/transform/set_byoc_attrs.cc @@ -103,10 +103,10 @@ Pass SetBYOCAttrs(const ffi::String& target, const ffi::String& entry_name) { return CreateModulePass(pass_func, 0, "SetBYOCAttrs", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.SetBYOCAttrs", SetBYOCAttrs); -}); +} } // namespace transform } // namespace relax diff --git a/src/contrib/msc/core/transform/set_expr_layout.cc b/src/contrib/msc/core/transform/set_expr_layout.cc index 1e38ecd147b0..90dd47cb2d36 100644 --- a/src/contrib/msc/core/transform/set_expr_layout.cc +++ b/src/contrib/msc/core/transform/set_expr_layout.cc @@ -1364,10 +1364,10 @@ Pass SetExprLayout(bool allow_missing, const ffi::String& entry_name) { return CreateModulePass(pass_func, 0, "SetExprLayout", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.SetExprLayout", SetExprLayout); -}); +} } // namespace transform } // namespace relax diff --git a/src/contrib/msc/core/transform/set_expr_name.cc b/src/contrib/msc/core/transform/set_expr_name.cc index ecf1afd9940f..d0231afedba5 100644 --- a/src/contrib/msc/core/transform/set_expr_name.cc +++ b/src/contrib/msc/core/transform/set_expr_name.cc @@ -326,10 +326,10 @@ Pass SetRelaxExprName(const ffi::String& entry_name, const ffi::String& target, return CreateModulePass(pass_func, 0, "SetRelaxExprName", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.SetRelaxExprName", SetRelaxExprName); -}); +} } // namespace transform } // namespace relax diff --git a/src/contrib/msc/core/utils.cc b/src/contrib/msc/core/utils.cc index 720574cfa9a9..bc70c809af7c 100644 --- a/src/contrib/msc/core/utils.cc +++ b/src/contrib/msc/core/utils.cc @@ -532,7 +532,7 @@ const DataType ExprUtils::GetDataType(const Expr& expr) { return Downcast(GetStructInfo(expr))->dtype; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("msc.core.SpanGetAttr", SpanUtils::GetAttr) @@ -552,7 +552,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ }) .def("msc.core.ToAttrKey", [](const ffi::String& key) -> ffi::String { return CommonUtils::ToAttrKey(key); }); -}); +} } // namespace msc } // namespace contrib diff --git a/src/contrib/msc/framework/tensorflow/codegen.cc b/src/contrib/msc/framework/tensorflow/codegen.cc index 954341114df7..30488fcc9af0 100644 --- a/src/contrib/msc/framework/tensorflow/codegen.cc +++ b/src/contrib/msc/framework/tensorflow/codegen.cc @@ -152,7 +152,7 @@ const ffi::Array TensorflowCodeGen::GetOpCodes(const MSCJoint& node) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("msc.framework.tensorflow.GetTensorflowSources", [](const MSCGraph& graph, const ffi::String& codegen_config, @@ -161,7 +161,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ codegen.Init(); return codegen.GetSources(print_config); }); -}); +} } // namespace msc } // namespace contrib diff --git a/src/contrib/msc/framework/tensorrt/codegen.cc b/src/contrib/msc/framework/tensorrt/codegen.cc index b0d290328d62..1be8cf0836c9 100644 --- a/src/contrib/msc/framework/tensorrt/codegen.cc +++ b/src/contrib/msc/framework/tensorrt/codegen.cc @@ -576,7 +576,7 @@ const ffi::Map TensorRTCodeGen::GetStepCtx() { return step_ctx; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("msc.framework.tensorrt.GetTensorRTSources", @@ -593,7 +593,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return ""; #endif }); -}); +} /*! * \brief Create runtime modules for MSC TensorRT. @@ -623,10 +623,10 @@ ffi::Array MSCTensorRTCompiler(ffi::Array functions, return compiled_functions; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ext.msc_tensorrt", MSCTensorRTCompiler); -}); +} } // namespace msc } // namespace contrib diff --git a/src/contrib/msc/framework/tensorrt/transform_tensorrt.cc b/src/contrib/msc/framework/tensorrt/transform_tensorrt.cc index 06f694d463d7..e3579ec7ef77 100644 --- a/src/contrib/msc/framework/tensorrt/transform_tensorrt.cc +++ b/src/contrib/msc/framework/tensorrt/transform_tensorrt.cc @@ -918,10 +918,10 @@ Pass TransformTensorRT(const ffi::String& config) { return CreateFunctionPass(pass_func, 0, "TransformTensorRT", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.TransformTensorRT", TransformTensorRT); -}); +} } // namespace transform } // namespace relax diff --git a/src/contrib/msc/framework/torch/codegen.cc b/src/contrib/msc/framework/torch/codegen.cc index b1ab14b9fd06..c81646f8b267 100644 --- a/src/contrib/msc/framework/torch/codegen.cc +++ b/src/contrib/msc/framework/torch/codegen.cc @@ -153,7 +153,7 @@ const ffi::Array TorchCodeGen::GetOpCodes(const MSCJoint& node) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("msc.framework.torch.GetTorchSources", [](const MSCGraph& graph, const ffi::String& codegen_config, @@ -162,7 +162,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ codegen.Init(); return codegen.GetSources(print_config); }); -}); +} } // namespace msc } // namespace contrib diff --git a/src/contrib/msc/framework/tvm/codegen.cc b/src/contrib/msc/framework/tvm/codegen.cc index 2a9ed4c8f703..29445ed7ccc3 100644 --- a/src/contrib/msc/framework/tvm/codegen.cc +++ b/src/contrib/msc/framework/tvm/codegen.cc @@ -212,7 +212,7 @@ const ffi::Array RelaxCodeGen::GetOpCodes(const MSCJoint& node) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("msc.framework.tvm.GetRelaxSources", [](const MSCGraph& graph, const ffi::String& codegen_config, @@ -221,7 +221,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ codegen.Init(); return codegen.GetSources(print_config); }); -}); +} } // namespace msc } // namespace contrib diff --git a/src/contrib/msc/plugin/tensorrt_codegen.cc b/src/contrib/msc/plugin/tensorrt_codegen.cc index b9ca02bcb9d5..890b9a6df7b3 100644 --- a/src/contrib/msc/plugin/tensorrt_codegen.cc +++ b/src/contrib/msc/plugin/tensorrt_codegen.cc @@ -885,7 +885,7 @@ void TensorRTPluginCodeGen::CodegenEnqueue(const Plugin& plugin, bool dynamic) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("msc.plugin.GetTensorRTPluginSources", [](const ffi::String& codegen_config, const ffi::String& print_config, @@ -899,7 +899,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } return ffi::Map(); }); -}); +} } // namespace msc } // namespace contrib diff --git a/src/contrib/msc/plugin/torch_codegen.cc b/src/contrib/msc/plugin/torch_codegen.cc index 79c61d13e965..d5a2b5353de4 100644 --- a/src/contrib/msc/plugin/torch_codegen.cc +++ b/src/contrib/msc/plugin/torch_codegen.cc @@ -496,7 +496,7 @@ void TorchPluginCodeGen::CodeGenCompute(const Plugin& plugin, const ffi::String& } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("msc.plugin.GetTorchPluginSources", [](const ffi::String& codegen_config, const ffi::String& print_config, @@ -510,7 +510,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } return ffi::Map(); }); -}); +} } // namespace msc } // namespace contrib diff --git a/src/contrib/msc/plugin/tvm_codegen.cc b/src/contrib/msc/plugin/tvm_codegen.cc index ae107c06773f..7a109a147280 100644 --- a/src/contrib/msc/plugin/tvm_codegen.cc +++ b/src/contrib/msc/plugin/tvm_codegen.cc @@ -396,7 +396,7 @@ void TVMPluginCodeGen::CodeGenCompute(const Plugin& plugin, const ffi::String& d } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("msc.plugin.GetTVMPluginSources", [](const ffi::String& codegen_config, const ffi::String& print_config, @@ -410,7 +410,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } return ffi::Map(); }); -}); +} } // namespace msc } // namespace contrib diff --git a/src/ir/analysis.cc b/src/ir/analysis.cc index 72fc1803715d..81d6bb7e5891 100644 --- a/src/ir/analysis.cc +++ b/src/ir/analysis.cc @@ -44,10 +44,10 @@ ffi::Map> CollectCallMap(const IRModule& mod) { return call_map; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ir.analysis.CollectCallMap", CollectCallMap); -}); +} } // namespace ir } // namespace tvm diff --git a/src/ir/apply_pass_to_function.cc b/src/ir/apply_pass_to_function.cc index bf5138924b7f..3dd7c6a5ff8f 100644 --- a/src/ir/apply_pass_to_function.cc +++ b/src/ir/apply_pass_to_function.cc @@ -130,10 +130,10 @@ Pass ApplyPassToFunction(Pass pass, ffi::String func_name_regex, return CreateModulePass(pass_func, 0, pass_name, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("transform.ApplyPassToFunction", ApplyPassToFunction); -}); +} } // namespace transform } // namespace tvm diff --git a/src/ir/attrs.cc b/src/ir/attrs.cc index 911e829ea9c9..748f4bf5c93f 100644 --- a/src/ir/attrs.cc +++ b/src/ir/attrs.cc @@ -28,10 +28,10 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { AttrFieldInfoNode::RegisterReflection(); DictAttrsNode::RegisterReflection(); -}); +} DictAttrs WithAttrs(DictAttrs attrs, ffi::Map new_attrs) { if (new_attrs.empty()) { @@ -69,11 +69,11 @@ DictAttrs::DictAttrs(ffi::Map dict) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ tvm::ffi::reflection::ObjectDef(); }); +TVM_FFI_STATIC_INIT_BLOCK() { tvm::ffi::reflection::ObjectDef(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ir.DictAttrsGetDict", [](DictAttrs attrs) { return attrs->dict; }); -}); +} } // namespace tvm diff --git a/src/ir/diagnostic.cc b/src/ir/diagnostic.cc index ac8b11575239..e20c6b8e1715 100644 --- a/src/ir/diagnostic.cc +++ b/src/ir/diagnostic.cc @@ -29,22 +29,22 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { DiagnosticNode::RegisterReflection(); DiagnosticRendererNode::RegisterReflection(); DiagnosticContextNode::RegisterReflection(); -}); +} // failed to check to argument arg0.dims[0] != 0 /* Diagnostic */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("diagnostics.Diagnostic", [](int level, Span span, ffi::String message) { return Diagnostic(static_cast(level), span, message); }); -}); +} Diagnostic::Diagnostic(DiagnosticLevel level, Span span, const std::string& message) { auto n = ffi::make_object(); @@ -115,13 +115,13 @@ TVM_DLL DiagnosticRenderer::DiagnosticRenderer( data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("diagnostics.DiagnosticRenderer", [](ffi::TypedFunction renderer) { return DiagnosticRenderer(renderer); }); -}); +} /* Diagnostic Context */ @@ -145,12 +145,12 @@ void DiagnosticContext::Render() { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "diagnostics.DiagnosticRendererRender", [](DiagnosticRenderer renderer, DiagnosticContext ctx) { renderer.Render(ctx); }); -}); +} DiagnosticContext::DiagnosticContext(const IRModule& module, const DiagnosticRenderer& renderer) { CHECK(renderer.defined()) << "can not initialize a diagnostic renderer with a null function"; @@ -160,27 +160,27 @@ DiagnosticContext::DiagnosticContext(const IRModule& module, const DiagnosticRen data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("diagnostics.DiagnosticContext", [](const IRModule& module, const DiagnosticRenderer& renderer) { return DiagnosticContext(module, renderer); }); -}); +} /*! \brief Emit a diagnostic. */ void DiagnosticContext::Emit(const Diagnostic& diagnostic) { (*this)->diagnostics.push_back(diagnostic); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("diagnostics.Emit", [](DiagnosticContext ctx, const Diagnostic& diagnostic) { return ctx.Emit(diagnostic); }) .def("diagnostics.DiagnosticContextRender", [](DiagnosticContext context) { return context.Render(); }); -}); +} /*! \brief Emit a diagnostic. */ void DiagnosticContext::EmitFatal(const Diagnostic& diagnostic) { @@ -212,11 +212,11 @@ DiagnosticContext DiagnosticContext::Default(const IRModule& module) { return DiagnosticContext(module, renderer); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("diagnostics.Default", [](const IRModule& module) { return DiagnosticContext::Default(module); }); -}); +} std::ostream& EmitDiagnosticHeader(std::ostream& out, const Span& span, DiagnosticLevel level, std::string msg) { @@ -330,13 +330,13 @@ DiagnosticRenderer TerminalRenderer(std::ostream& out) { }); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def(DEFAULT_RENDERER, []() { return TerminalRenderer(std::cerr); }) .def("diagnostics.GetRenderer", []() { return GetRenderer(); }) .def("diagnostics.ClearRenderer", []() { tvm::ffi::Function::RemoveGlobal(OVERRIDE_RENDERER); }); -}); +} } // namespace tvm diff --git a/src/ir/env_func.cc b/src/ir/env_func.cc index 77c346eabcce..5a6e2c662b61 100644 --- a/src/ir/env_func.cc +++ b/src/ir/env_func.cc @@ -27,7 +27,7 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ EnvFuncNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { EnvFuncNode::RegisterReflection(); } using ffi::Any; using ffi::Function; @@ -50,7 +50,7 @@ ObjectPtr CreateEnvNode(const std::string& name) { EnvFunc EnvFunc::Get(const ffi::String& name) { return EnvFunc(CreateEnvNode(name)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ir.EnvFuncGet", EnvFunc::Get) @@ -69,5 +69,5 @@ TVM_FFI_STATIC_INIT_BLOCK({ return node->name; }) .def("__data_from_json__", EnvFunc::Get); -}); +} } // namespace tvm diff --git a/src/ir/expr.cc b/src/ir/expr.cc index 101a00cf5a5d..6c0065c29c94 100644 --- a/src/ir/expr.cc +++ b/src/ir/expr.cc @@ -33,7 +33,7 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { BaseExprNode::RegisterReflection(); PrimExprNode::RegisterReflection(); RelaxExprNode::RegisterReflection(); @@ -42,7 +42,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ IntImmNode::RegisterReflection(); FloatImmNode::RegisterReflection(); RangeNode::RegisterReflection(); -}); +} PrimExpr::PrimExpr(int32_t value) : PrimExpr(IntImm(DataType::Int(32), value)) {} @@ -78,12 +78,12 @@ IntImm::IntImm(DataType dtype, int64_t value, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ir.IntImm", [](DataType dtype, int64_t value, Span span) { return IntImm(dtype, value, span); }); -}); +} FloatImm::FloatImm(DataType dtype, double value, Span span) { ICHECK_EQ(dtype.lanes(), 1) << "ValueError: FloatImm can only take scalar."; @@ -181,12 +181,12 @@ FloatImm::FloatImm(DataType dtype, double value, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ir.FloatImm", [](DataType dtype, double value, Span span) { return FloatImm(dtype, value, span); }); -}); +} Range::Range(PrimExpr begin, PrimExpr end, Span span) : Range(ffi::make_object(begin, tir::is_zero(begin) ? end : (end - begin), span)) {} @@ -195,7 +195,7 @@ Range Range::FromMinExtent(PrimExpr min, PrimExpr extent, Span span) { return Range(ffi::make_object(min, extent, span)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ir.Range_from_min_extent", Range::FromMinExtent) @@ -206,7 +206,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return Range(IntImm(begin->dtype, 0), begin, span); } }); -}); +} GlobalVar::GlobalVar(ffi::String name_hint, Span span) { ObjectPtr n = ffi::make_object(); @@ -215,7 +215,7 @@ GlobalVar::GlobalVar(ffi::String name_hint, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ir.GlobalVar", [](ffi::String name) { return GlobalVar(name); }) @@ -224,6 +224,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ ss << ref; return ss.str(); }); -}); +} } // namespace tvm diff --git a/src/ir/function.cc b/src/ir/function.cc index 21fdb7975b89..de14d57b3ef8 100644 --- a/src/ir/function.cc +++ b/src/ir/function.cc @@ -30,7 +30,7 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ir.BaseFunc_Attrs", [](BaseFunc func) { return func->attrs; }) @@ -78,6 +78,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ TVM_FFI_UNREACHABLE(); } }); -}); +} } // namespace tvm diff --git a/src/ir/global_info.cc b/src/ir/global_info.cc index b318c86b0f00..151387d3c25a 100644 --- a/src/ir/global_info.cc +++ b/src/ir/global_info.cc @@ -26,18 +26,18 @@ #include namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { VDeviceNode::RegisterReflection(); DummyGlobalInfoNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ir.DummyGlobalInfo", []() { auto n = DummyGlobalInfo(ffi::make_object()); return n; }); -}); +} VDevice::VDevice(Target tgt, int dev_id, MemoryScope mem_scope) { ObjectPtr n = ffi::make_object(); @@ -47,10 +47,10 @@ VDevice::VDevice(Target tgt, int dev_id, MemoryScope mem_scope) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ir.VDevice", [](Target tgt, int dev_id, MemoryScope mem_scope) { return VDevice(tgt, dev_id, mem_scope); }); -}); +} } // namespace tvm diff --git a/src/ir/global_var_supply.cc b/src/ir/global_var_supply.cc index 71505430c5cc..115eba152948 100644 --- a/src/ir/global_var_supply.cc +++ b/src/ir/global_var_supply.cc @@ -32,7 +32,7 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ GlobalVarSupplyNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { GlobalVarSupplyNode::RegisterReflection(); } GlobalVarSupply::GlobalVarSupply(const NameSupply& name_supply, std::unordered_map name_to_var_map) { @@ -94,7 +94,7 @@ GlobalVar GlobalVarSupplyNode::FreshGlobal(ffi::String name, bool add_prefix) { return var; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ir.GlobalVarSupply_NameSupply", @@ -106,6 +106,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_method("ir.GlobalVarSupply_FreshGlobal", &GlobalVarSupplyNode::FreshGlobal) .def_method("ir.GlobalVarSupply_UniqueGlobalFor", &GlobalVarSupplyNode::UniqueGlobalFor) .def_method("ir.GlobalVarSupply_ReserveGlobalVar", &GlobalVarSupplyNode::ReserveGlobalVar); -}); +} } // namespace tvm diff --git a/src/ir/instrument.cc b/src/ir/instrument.cc index 950936983205..011968d105c5 100644 --- a/src/ir/instrument.cc +++ b/src/ir/instrument.cc @@ -33,7 +33,7 @@ namespace tvm { namespace instrument { -TVM_FFI_STATIC_INIT_BLOCK({ PassInstrumentNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { PassInstrumentNode::RegisterReflection(); } /*! * \brief Base PassInstrument implementation @@ -176,7 +176,7 @@ void BasePassInstrumentNode::RunAfterPass(const IRModule& ir_module, } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "instrument.PassInstrument", @@ -188,7 +188,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return BasePassInstrument(name, enter_pass_ctx, exit_pass_ctx, should_run, run_before_pass, run_after_pass); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { @@ -312,7 +312,7 @@ ffi::String RenderPassProfiles() { return os.str(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("instrument.RenderTimePassProfiles", RenderPassProfiles) @@ -332,7 +332,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ /* enter_pass_ctx */ nullptr, exit_pass_ctx, /* should_run */ nullptr, run_before_pass, run_after_pass); }); -}); +} } // namespace instrument } // namespace tvm diff --git a/src/ir/module.cc b/src/ir/module.cc index 05eaca3a4764..b0104ba14d17 100644 --- a/src/ir/module.cc +++ b/src/ir/module.cc @@ -36,7 +36,7 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ IRModuleNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { IRModuleNode::RegisterReflection(); } IRModule::IRModule(tvm::ffi::Map functions, SourceMap source_map, DictAttrs attrs, ffi::Map> global_infos) { @@ -225,7 +225,7 @@ IRModule IRModule::FromExpr(const RelaxExpr& expr, return mod; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ir.IRModule", @@ -312,6 +312,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ }) .def("ir.Module_GetAttr", [](IRModule mod, ffi::String key) -> ObjectRef { return mod->GetAttr(key); }); -}); +} } // namespace tvm diff --git a/src/ir/name_supply.cc b/src/ir/name_supply.cc index 253812470313..cc6db0c21fff 100644 --- a/src/ir/name_supply.cc +++ b/src/ir/name_supply.cc @@ -91,13 +91,13 @@ std::string NameSupplyNode::GetUniqueName(std::string name, bool add_underscore) return name; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ir.NameSupply", [](ffi::String prefix) { return NameSupply(prefix); }) .def_method("ir.NameSupply_FreshName", &NameSupplyNode::FreshName) .def_method("ir.NameSupply_ReserveName", &NameSupplyNode::ReserveName) .def_method("ir.NameSupply_ContainsName", &NameSupplyNode::ContainsName); -}); +} } // namespace tvm diff --git a/src/ir/op.cc b/src/ir/op.cc index a57fcea8e0a2..514b45c65ad0 100644 --- a/src/ir/op.cc +++ b/src/ir/op.cc @@ -34,7 +34,7 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ OpNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { OpNode::RegisterReflection(); } using ffi::Any; using ffi::Function; @@ -80,7 +80,7 @@ void OpRegEntry::UpdateAttr(const ffi::String& key, ffi::Any value, int plevel) } // Frontend APIs -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ir.ListOpNames", []() { return OpRegistry::Global()->ListAllNames(); }) @@ -159,7 +159,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return node->name; }) .def("__data_from_json__", [](const ffi::String& name) -> Op { return Op::Get(name); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { diff --git a/src/ir/replace_global_vars.cc b/src/ir/replace_global_vars.cc index 13337dca36a6..98b5b74c42cd 100644 --- a/src/ir/replace_global_vars.cc +++ b/src/ir/replace_global_vars.cc @@ -63,10 +63,10 @@ IRModule ReplaceGlobalVars(IRModule mod, ffi::Map replacem return mod; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("transform.ReplaceGlobalVars", ReplaceGlobalVars); -}); +} IRModule ModuleReplaceGlobalVars( IRModule mod, @@ -101,10 +101,10 @@ IRModule ModuleReplaceGlobalVars( return ReplaceGlobalVars(mod, gvar_replacements); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ir.Module_ReplaceGlobalVars", ModuleReplaceGlobalVars); -}); +} } // namespace transform } // namespace tvm diff --git a/src/ir/source_map.cc b/src/ir/source_map.cc index 47727d5297a0..521b02db44b5 100644 --- a/src/ir/source_map.cc +++ b/src/ir/source_map.cc @@ -29,7 +29,7 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; SourceNameNode::RegisterReflection(); SpanNode::RegisterReflection(); @@ -44,7 +44,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return node->name; }) .def("__data_from_json__", SourceName::Get); -}); +} ObjectPtr GetSourceNameNode(const ffi::String& name) { // always return pointer as the reference can change as map re-allocate. @@ -68,10 +68,10 @@ ObjectPtr GetSourceNameNodeByStr(const std::string& name) { SourceName SourceName::Get(const ffi::String& name) { return SourceName(GetSourceNameNode(name)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ir.SourceName", SourceName::Get); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { @@ -140,7 +140,7 @@ SequentialSpan::SequentialSpan(std::initializer_list init) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ir.Span", @@ -148,7 +148,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return Span(source_name, line, end_line, column, end_column); }) .def("ir.SequentialSpan", [](tvm::ffi::Array spans) { return SequentialSpan(spans); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { @@ -226,7 +226,7 @@ SourceMap::SourceMap(ffi::Map source_map) { void SourceMap::Add(const Source& source) { (*this)->source_map.Set(source->source_name, source); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("SourceMapAdd", [](SourceMap map, ffi::String name, ffi::String content) { auto src_name = SourceName::Get(name); @@ -234,6 +234,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ map.Add(source); return src_name; }); -}); +} } // namespace tvm diff --git a/src/ir/transform.cc b/src/ir/transform.cc index f0afa863e521..35f1e49e595d 100644 --- a/src/ir/transform.cc +++ b/src/ir/transform.cc @@ -498,7 +498,7 @@ Pass CreateModulePass(std::function pass_func, return ModulePass(std::move(pass_func), pass_info); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("transform.PassInfo", @@ -508,7 +508,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ Pass pass = args[0].cast(); *ret = pass->Info(); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& ref, tvm::ReprPrinter* p) { @@ -528,14 +528,14 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) } }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { PassContextNode::RegisterReflection(); PassInfoNode::RegisterReflection(); SequentialNode::RegisterReflection(); ModulePassNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("transform.MakeModulePass", @@ -548,7 +548,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ }) .def("transform.RunPass", [](Pass pass, ffi::RValueRef mod) { return pass(*std::move(mod)); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { @@ -558,7 +558,7 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) << info->opt_level; }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("transform.Sequential", [](ffi::PackedArgs args, ffi::Any* ret) { auto passes = args[0].cast>(); @@ -569,7 +569,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ PassInfo pass_info = PassInfo(opt_level, name, required, /* traceable */ traceable); *ret = Sequential(passes, pass_info); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { @@ -585,7 +585,7 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) p->stream << "]"; }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "transform.PassContext", @@ -605,7 +605,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ PassConfigManager::Global()->Legalize(&(pctx->config)); return pctx; }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { @@ -628,7 +628,7 @@ class PassContext::Internal { static void ExitScope(PassContext pass_ctx) { pass_ctx.ExitWithScope(); } }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("transform.GetCurrentPassContext", PassContext::Current) @@ -640,7 +640,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ pass_ctx->instruments = instruments; pass_ctx.InstrumentEnterPassContext(); }); -}); +} Pass PrintIR(ffi::String header, bool show_meta_data) { auto pass_func = [header, show_meta_data](IRModule mod, const PassContext& ctx) { @@ -650,12 +650,12 @@ Pass PrintIR(ffi::String header, bool show_meta_data) { return CreateModulePass(pass_func, 0, "PrintIR", {}, /* traceable */ false); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("transform.PrintIR", PrintIR) .def("transform.ListConfigs", PassContext::ListConfigs); -}); +} } // namespace transform } // namespace tvm diff --git a/src/ir/type.cc b/src/ir/type.cc index dc2bfb984b22..b28e20a78f89 100644 --- a/src/ir/type.cc +++ b/src/ir/type.cc @@ -26,14 +26,14 @@ #include namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { TypeNode::RegisterReflection(); PrimTypeNode::RegisterReflection(); PointerTypeNode::RegisterReflection(); TupleTypeNode::RegisterReflection(); FuncTypeNode::RegisterReflection(); TensorMapTypeNode::RegisterReflection(); -}); +} PrimType::PrimType(runtime::DataType dtype, Span span) { ObjectPtr n = ffi::make_object(); @@ -42,10 +42,10 @@ PrimType::PrimType(runtime::DataType dtype, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ir.PrimType", [](runtime::DataType dtype) { return PrimType(dtype); }); -}); +} PointerType::PointerType(Type element_type, ffi::String storage_scope) { ObjectPtr n = ffi::make_object(); @@ -58,12 +58,12 @@ PointerType::PointerType(Type element_type, ffi::String storage_scope) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ir.PointerType", [](Type element_type, ffi::String storage_scope = "") { return PointerType(element_type, storage_scope); }); -}); +} FuncType::FuncType(tvm::ffi::Array arg_types, Type ret_type, Span span) { ObjectPtr n = ffi::make_object(); @@ -73,12 +73,12 @@ FuncType::FuncType(tvm::ffi::Array arg_types, Type ret_type, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ir.FuncType", [](tvm::ffi::Array arg_types, Type ret_type) { return FuncType(arg_types, ret_type); }); -}); +} TupleType::TupleType(ffi::Array fields, Span span) { ObjectPtr n = ffi::make_object(); @@ -89,12 +89,12 @@ TupleType::TupleType(ffi::Array fields, Span span) { TupleType TupleType::Empty() { return TupleType(ffi::Array()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ir.TupleType", [](ffi::Array fields) { return TupleType(fields); }) .def("ir.TensorMapType", [](Span span) { return TensorMapType(span); }); -}); +} TensorMapType::TensorMapType(Span span) { ObjectPtr n = ffi::make_object(); diff --git a/src/meta_schedule/arg_info.cc b/src/meta_schedule/arg_info.cc index 44fa338fefa1..5c00a9bdbc4e 100644 --- a/src/meta_schedule/arg_info.cc +++ b/src/meta_schedule/arg_info.cc @@ -160,9 +160,9 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) }); /******** FFI ********/ -TVM_FFI_STATIC_INIT_BLOCK({ TensorInfoNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { TensorInfoNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("meta_schedule.ArgInfoAsJSON", &ArgInfoNode::AsJSON) @@ -172,7 +172,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("meta_schedule.TensorInfo", [](runtime::DataType dtype, ffi::Shape shape) -> TensorInfo { return TensorInfo(dtype, shape); }); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/builder/builder.cc b/src/meta_schedule/builder/builder.cc index c4822f41971c..195547bee764 100644 --- a/src/meta_schedule/builder/builder.cc +++ b/src/meta_schedule/builder/builder.cc @@ -50,13 +50,13 @@ Builder Builder::PyBuilder(BuilderNode::FBuild f_build) { /******** FFI ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { BuilderInputNode::RegisterReflection(); BuilderResultNode::RegisterReflection(); PyBuilderNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("meta_schedule.BuilderInput", @@ -69,7 +69,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ -> BuilderResult { return BuilderResult(artifact_path, error_msg); }) .def_method("meta_schedule.BuilderBuild", &BuilderNode::Build) .def("meta_schedule.BuilderPyBuilder", Builder::PyBuilder); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/cost_model/cost_model.cc b/src/meta_schedule/cost_model/cost_model.cc index dddb798af2fe..4cc13787ae96 100644 --- a/src/meta_schedule/cost_model/cost_model.cc +++ b/src/meta_schedule/cost_model/cost_model.cc @@ -71,7 +71,7 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) p->stream << f_as_string(); }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("meta_schedule.CostModelLoad", &CostModelNode::Load) @@ -86,7 +86,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ std::copy(result.begin(), result.end(), static_cast(p_addr)); }) .def("meta_schedule.CostModelPyCostModel", CostModel::PyCostModel); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/database/database.cc b/src/meta_schedule/database/database.cc index 8094449bfb97..a7548c95b6cb 100644 --- a/src/meta_schedule/database/database.cc +++ b/src/meta_schedule/database/database.cc @@ -286,13 +286,13 @@ Database Database::PyDatabase(PyDatabaseNode::FHasWorkload f_has_workload, /******** FFI ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { WorkloadNode::RegisterReflection(); TuningRecordNode::RegisterReflection(); PyDatabaseNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("meta_schedule.Workload", [](IRModule mod) { return Workload(mod); }) @@ -321,7 +321,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_method("meta_schedule.DatabaseQueryIRModule", &DatabaseNode::QueryIRModule) .def_method("meta_schedule.DatabaseDumpPruned", &DatabaseNode::DumpPruned) .def("meta_schedule.DatabasePyDatabase", Database::PyDatabase); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/database/json_database.cc b/src/meta_schedule/database/json_database.cc index ccde9f555e03..862d0fd05a10 100644 --- a/src/meta_schedule/database/json_database.cc +++ b/src/meta_schedule/database/json_database.cc @@ -213,12 +213,12 @@ Database Database::JSONDatabase(ffi::String path_workload, ffi::String path_tuni return Database(n); } -TVM_FFI_STATIC_INIT_BLOCK({ JSONDatabaseNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { JSONDatabaseNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.DatabaseJSONDatabase", Database::JSONDatabase); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/database/memory_database.cc b/src/meta_schedule/database/memory_database.cc index 72be245e14eb..ef144e47631c 100644 --- a/src/meta_schedule/database/memory_database.cc +++ b/src/meta_schedule/database/memory_database.cc @@ -99,12 +99,12 @@ Database Database::MemoryDatabase(ffi::String mod_eq_name) { return Database(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.DatabaseMemoryDatabase", Database::MemoryDatabase); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ MemoryDatabaseNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { MemoryDatabaseNode::RegisterReflection(); } } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/database/ordered_union_database.cc b/src/meta_schedule/database/ordered_union_database.cc index 08a492f646ab..ddb38af9d581 100644 --- a/src/meta_schedule/database/ordered_union_database.cc +++ b/src/meta_schedule/database/ordered_union_database.cc @@ -83,13 +83,13 @@ Database Database::OrderedUnionDatabase(ffi::Array databases) { return Database(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.DatabaseOrderedUnionDatabase", Database::OrderedUnionDatabase); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ OrderedUnionDatabaseNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { OrderedUnionDatabaseNode::RegisterReflection(); } } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/database/schedule_fn_database.cc b/src/meta_schedule/database/schedule_fn_database.cc index 5070039bcd37..5825b6834b8f 100644 --- a/src/meta_schedule/database/schedule_fn_database.cc +++ b/src/meta_schedule/database/schedule_fn_database.cc @@ -102,12 +102,12 @@ Database Database::ScheduleFnDatabase(ffi::TypedFunction sc return Database(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.DatabaseScheduleFnDatabase", Database::ScheduleFnDatabase); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ ScheduleFnDatabaseNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ScheduleFnDatabaseNode::RegisterReflection(); } } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/database/union_database.cc b/src/meta_schedule/database/union_database.cc index 9d789010e4b5..125bcb7ac45f 100644 --- a/src/meta_schedule/database/union_database.cc +++ b/src/meta_schedule/database/union_database.cc @@ -84,12 +84,12 @@ Database Database::UnionDatabase(ffi::Array databases) { return Database(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.DatabaseUnionDatabase", Database::UnionDatabase); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ UnionDatabaseNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { UnionDatabaseNode::RegisterReflection(); } } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/extracted_task.cc b/src/meta_schedule/extracted_task.cc index ad93f1d5e8ab..6410a50c133e 100644 --- a/src/meta_schedule/extracted_task.cc +++ b/src/meta_schedule/extracted_task.cc @@ -39,16 +39,16 @@ ExtractedTask::ExtractedTask(ffi::String task_name, IRModule mod, Target target, data_ = n; } -TVM_FFI_STATIC_INIT_BLOCK({ ExtractedTaskNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ExtractedTaskNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ExtractedTask", [](ffi::String task_name, IRModule mod, Target target, ffi::Array dispatched, int weight) -> ExtractedTask { return ExtractedTask(task_name, mod, target, dispatched, weight); }); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/feature_extractor/feature_extractor.cc b/src/meta_schedule/feature_extractor/feature_extractor.cc index 983d24ed25c6..978ba658020c 100644 --- a/src/meta_schedule/feature_extractor/feature_extractor.cc +++ b/src/meta_schedule/feature_extractor/feature_extractor.cc @@ -47,18 +47,18 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) p->stream << f_as_string(); }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { FeatureExtractorNode::RegisterReflection(); PyFeatureExtractorNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("meta_schedule.FeatureExtractorExtractFrom", &FeatureExtractorNode::ExtractFrom) .def("meta_schedule.FeatureExtractorPyFeatureExtractor", FeatureExtractor::PyFeatureExtractor); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/feature_extractor/per_store_feature.cc b/src/meta_schedule/feature_extractor/per_store_feature.cc index f78749873eae..9072ccf62a94 100644 --- a/src/meta_schedule/feature_extractor/per_store_feature.cc +++ b/src/meta_schedule/feature_extractor/per_store_feature.cc @@ -1446,13 +1446,13 @@ FeatureExtractor FeatureExtractor::PerStoreFeature(int buffers_per_store, return FeatureExtractor(n); } -TVM_FFI_STATIC_INIT_BLOCK({ PerStoreFeatureNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { PerStoreFeatureNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.FeatureExtractorPerStoreFeature", FeatureExtractor::PerStoreFeature); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/measure_callback/add_to_database.cc b/src/meta_schedule/measure_callback/add_to_database.cc index c6892daa98a6..76d5b1c7cead 100644 --- a/src/meta_schedule/measure_callback/add_to_database.cc +++ b/src/meta_schedule/measure_callback/add_to_database.cc @@ -65,11 +65,11 @@ MeasureCallback MeasureCallback::AddToDatabase() { return MeasureCallback(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.MeasureCallbackAddToDatabase", MeasureCallback::AddToDatabase); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/measure_callback/measure_callback.cc b/src/meta_schedule/measure_callback/measure_callback.cc index dbc6b634665d..bf5172349b13 100644 --- a/src/meta_schedule/measure_callback/measure_callback.cc +++ b/src/meta_schedule/measure_callback/measure_callback.cc @@ -58,18 +58,18 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) p->stream << f_as_string(); }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { MeasureCallbackNode::RegisterReflection(); PyMeasureCallbackNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("meta_schedule.MeasureCallbackApply", &MeasureCallbackNode::Apply) .def("meta_schedule.MeasureCallbackPyMeasureCallback", MeasureCallback::PyMeasureCallback) .def("meta_schedule.MeasureCallbackDefault", MeasureCallback::Default); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/measure_callback/remove_build_artifact.cc b/src/meta_schedule/measure_callback/remove_build_artifact.cc index e76a75ad0e50..bee5b0b03ecd 100644 --- a/src/meta_schedule/measure_callback/remove_build_artifact.cc +++ b/src/meta_schedule/measure_callback/remove_build_artifact.cc @@ -46,11 +46,11 @@ MeasureCallback MeasureCallback::RemoveBuildArtifact() { return MeasureCallback(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.MeasureCallbackRemoveBuildArtifact", MeasureCallback::RemoveBuildArtifact); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/measure_callback/update_cost_model.cc b/src/meta_schedule/measure_callback/update_cost_model.cc index 6675fb5cd09d..38f714b03a83 100644 --- a/src/meta_schedule/measure_callback/update_cost_model.cc +++ b/src/meta_schedule/measure_callback/update_cost_model.cc @@ -63,11 +63,11 @@ MeasureCallback MeasureCallback::UpdateCostModel() { return MeasureCallback(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.MeasureCallbackUpdateCostModel", MeasureCallback::UpdateCostModel); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/mutator/mutate_compute_location.cc b/src/meta_schedule/mutator/mutate_compute_location.cc index 438656d41f9d..4ad979648aca 100644 --- a/src/meta_schedule/mutator/mutate_compute_location.cc +++ b/src/meta_schedule/mutator/mutate_compute_location.cc @@ -131,13 +131,13 @@ Mutator Mutator::MutateComputeLocation() { return Mutator(ffi::make_object()); } -TVM_FFI_STATIC_INIT_BLOCK({ MutateComputeLocationNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { MutateComputeLocationNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.MutatorMutateComputeLocation", Mutator::MutateComputeLocation); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/mutator/mutate_parallel.cc b/src/meta_schedule/mutator/mutate_parallel.cc index 9e998f724177..66266dd2a539 100644 --- a/src/meta_schedule/mutator/mutate_parallel.cc +++ b/src/meta_schedule/mutator/mutate_parallel.cc @@ -312,12 +312,12 @@ Mutator Mutator::MutateParallel(int64_t max_jobs_per_core) { return Mutator(n); } -TVM_FFI_STATIC_INIT_BLOCK({ MutateParallelNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { MutateParallelNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.MutatorMutateParallel", Mutator::MutateParallel); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/mutator/mutate_thread_binding.cc b/src/meta_schedule/mutator/mutate_thread_binding.cc index 7ffbc4739a83..ef9c30729485 100644 --- a/src/meta_schedule/mutator/mutate_thread_binding.cc +++ b/src/meta_schedule/mutator/mutate_thread_binding.cc @@ -171,12 +171,12 @@ Mutator Mutator::MutateThreadBinding() { return Mutator(ffi::make_object()); } -TVM_FFI_STATIC_INIT_BLOCK({ MutateThreadBindingNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { MutateThreadBindingNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.MutateThreadBinding", Mutator::MutateThreadBinding); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/mutator/mutate_tile_size.cc b/src/meta_schedule/mutator/mutate_tile_size.cc index b8762db843d0..e2f3689d2854 100644 --- a/src/meta_schedule/mutator/mutate_tile_size.cc +++ b/src/meta_schedule/mutator/mutate_tile_size.cc @@ -272,12 +272,12 @@ ffi::Optional MutateTileSizeNode::Apply(const Trace& trace, TRandState* r Mutator Mutator::MutateTileSize() { return Mutator(ffi::make_object()); } -TVM_FFI_STATIC_INIT_BLOCK({ MutateTileSizeNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { MutateTileSizeNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.MutatorMutateTileSize", Mutator::MutateTileSize); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/mutator/mutate_unroll.cc b/src/meta_schedule/mutator/mutate_unroll.cc index ae89d1bdc02d..dab987708238 100644 --- a/src/meta_schedule/mutator/mutate_unroll.cc +++ b/src/meta_schedule/mutator/mutate_unroll.cc @@ -142,12 +142,12 @@ ffi::Optional MutateUnrollNode::Apply(const Trace& trace, TRandState* ran Mutator Mutator::MutateUnroll() { return Mutator(ffi::make_object()); } -TVM_FFI_STATIC_INIT_BLOCK({ MutateUnrollNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { MutateUnrollNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.MutatorMutateUnroll", Mutator::MutateUnroll); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/mutator/mutator.cc b/src/meta_schedule/mutator/mutator.cc index 6862a9b202cc..fd8fe45bf185 100644 --- a/src/meta_schedule/mutator/mutator.cc +++ b/src/meta_schedule/mutator/mutator.cc @@ -87,12 +87,12 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) p->stream << f_as_string(); }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { MutatorNode::RegisterReflection(); PyMutatorNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("meta_schedule.MutatorInitializeWithTuneContext", @@ -109,7 +109,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("meta_schedule.MutatorDefaultCUDA", Mutator::DefaultCUDA) .def("meta_schedule.MutatorDefaultCUDATensorCore", Mutator::DefaultCUDATensorCore) .def("meta_schedule.MutatorDefaultHexagon", Mutator::DefaultHexagon); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/postproc/disallow_async_strided_mem_copy.cc b/src/meta_schedule/postproc/disallow_async_strided_mem_copy.cc index 37a8121e9665..94789ee40257 100644 --- a/src/meta_schedule/postproc/disallow_async_strided_mem_copy.cc +++ b/src/meta_schedule/postproc/disallow_async_strided_mem_copy.cc @@ -186,11 +186,11 @@ Postproc Postproc::DisallowAsyncStridedMemCopy() { return Postproc(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.PostprocDisallowAsyncStridedMemCopy", Postproc::DisallowAsyncStridedMemCopy); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/postproc/disallow_dynamic_loop.cc b/src/meta_schedule/postproc/disallow_dynamic_loop.cc index bd6184728533..bd69b3a21ab1 100644 --- a/src/meta_schedule/postproc/disallow_dynamic_loop.cc +++ b/src/meta_schedule/postproc/disallow_dynamic_loop.cc @@ -83,10 +83,10 @@ Postproc Postproc::DisallowDynamicLoop() { return Postproc(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.PostprocDisallowDynamicLoop", Postproc::DisallowDynamicLoop); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/postproc/postproc.cc b/src/meta_schedule/postproc/postproc.cc index b93f47c69fa6..41557830afb6 100644 --- a/src/meta_schedule/postproc/postproc.cc +++ b/src/meta_schedule/postproc/postproc.cc @@ -119,12 +119,12 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) p->stream << f_as_string(); }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { PostprocNode::RegisterReflection(); PyPostprocNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("meta_schedule.PostprocInitializeWithTuneContext", @@ -136,7 +136,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("meta_schedule.PostprocDefaultCUDA", Postproc::DefaultCUDA) .def("meta_schedule.PostprocDefaultCUDATensorCore", Postproc::DefaultCUDATensorCore) .def("meta_schedule.PostprocDefaultHexagon", Postproc::DefaultHexagon); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/postproc/rewrite_cooperative_fetch.cc b/src/meta_schedule/postproc/rewrite_cooperative_fetch.cc index 82d64a277fe3..e0c4b5c8f1d8 100644 --- a/src/meta_schedule/postproc/rewrite_cooperative_fetch.cc +++ b/src/meta_schedule/postproc/rewrite_cooperative_fetch.cc @@ -234,13 +234,13 @@ Postproc Postproc::RewriteCooperativeFetch() { return Postproc(n); } -TVM_FFI_STATIC_INIT_BLOCK({ RewriteCooperativeFetchNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { RewriteCooperativeFetchNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.PostprocRewriteCooperativeFetch", Postproc::RewriteCooperativeFetch); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/postproc/rewrite_layout.cc b/src/meta_schedule/postproc/rewrite_layout.cc index f954f36a84e6..3712c777913d 100644 --- a/src/meta_schedule/postproc/rewrite_layout.cc +++ b/src/meta_schedule/postproc/rewrite_layout.cc @@ -272,10 +272,10 @@ Postproc Postproc::RewriteLayout() { return Postproc(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.PostprocRewriteLayout", Postproc::RewriteLayout); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/postproc/rewrite_parallel_vectorize_unroll.cc b/src/meta_schedule/postproc/rewrite_parallel_vectorize_unroll.cc index c0f2b5153008..340211663b19 100644 --- a/src/meta_schedule/postproc/rewrite_parallel_vectorize_unroll.cc +++ b/src/meta_schedule/postproc/rewrite_parallel_vectorize_unroll.cc @@ -465,11 +465,11 @@ Postproc Postproc::RewriteParallelVectorizeUnroll() { return Postproc(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.PostprocRewriteParallelVectorizeUnroll", Postproc::RewriteParallelVectorizeUnroll); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/postproc/rewrite_reduction_block.cc b/src/meta_schedule/postproc/rewrite_reduction_block.cc index e184b9c12a9b..74a80cf80bc0 100644 --- a/src/meta_schedule/postproc/rewrite_reduction_block.cc +++ b/src/meta_schedule/postproc/rewrite_reduction_block.cc @@ -176,13 +176,13 @@ Postproc Postproc::RewriteReductionBlock() { return Postproc(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.PostprocRewriteReductionBlock", Postproc::RewriteReductionBlock); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ RewriteReductionBlockNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { RewriteReductionBlockNode::RegisterReflection(); } } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/postproc/rewrite_tensorize.cc b/src/meta_schedule/postproc/rewrite_tensorize.cc index 43203a5cbe78..3a1024e41022 100644 --- a/src/meta_schedule/postproc/rewrite_tensorize.cc +++ b/src/meta_schedule/postproc/rewrite_tensorize.cc @@ -109,12 +109,12 @@ Postproc Postproc::RewriteTensorize(bool vectorize_init_loop) { return Postproc(n); } -TVM_FFI_STATIC_INIT_BLOCK({ RewriteTensorizeNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { RewriteTensorizeNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.PostprocRewriteTensorize", Postproc::RewriteTensorize); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/postproc/rewrite_unbound_block.cc b/src/meta_schedule/postproc/rewrite_unbound_block.cc index 7da5dadf4d38..98e3db2522f1 100644 --- a/src/meta_schedule/postproc/rewrite_unbound_block.cc +++ b/src/meta_schedule/postproc/rewrite_unbound_block.cc @@ -145,12 +145,12 @@ Postproc Postproc::RewriteUnboundBlock(int max_threadblocks) { return Postproc(n); } -TVM_FFI_STATIC_INIT_BLOCK({ RewriteUnboundBlockNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { RewriteUnboundBlockNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.PostprocRewriteUnboundBlock", Postproc::RewriteUnboundBlock); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/postproc/verify_gpu_code.cc b/src/meta_schedule/postproc/verify_gpu_code.cc index 00ca99ff8faa..f02790cb497a 100644 --- a/src/meta_schedule/postproc/verify_gpu_code.cc +++ b/src/meta_schedule/postproc/verify_gpu_code.cc @@ -214,10 +214,10 @@ Postproc Postproc::VerifyGPUCode() { return Postproc(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.PostprocVerifyGPUCode", Postproc::VerifyGPUCode); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/postproc/verify_vtcm_limit.cc b/src/meta_schedule/postproc/verify_vtcm_limit.cc index 3acc6c31a508..38234ef01102 100644 --- a/src/meta_schedule/postproc/verify_vtcm_limit.cc +++ b/src/meta_schedule/postproc/verify_vtcm_limit.cc @@ -68,10 +68,10 @@ Postproc Postproc::VerifyVTCMLimit() { return Postproc(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.PostprocVerifyVTCMLimit", Postproc::VerifyVTCMLimit); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/profiler.cc b/src/meta_schedule/profiler.cc index 2a71aeed69ca..e0bbc904c2c1 100644 --- a/src/meta_schedule/profiler.cc +++ b/src/meta_schedule/profiler.cc @@ -122,9 +122,9 @@ ffi::Optional Profiler::Current() { } } -TVM_FFI_STATIC_INIT_BLOCK({ ProfilerNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ProfilerNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("meta_schedule.Profiler", []() -> Profiler { return Profiler(); }) @@ -134,7 +134,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_method("meta_schedule.ProfilerGet", &ProfilerNode::Get) .def_method("meta_schedule.ProfilerTable", &ProfilerNode::Table) .def("meta_schedule.ProfilerTimedScope", ProfilerTimedScope); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/runner/runner.cc b/src/meta_schedule/runner/runner.cc index d59d57ec64d4..0d620fb3b337 100644 --- a/src/meta_schedule/runner/runner.cc +++ b/src/meta_schedule/runner/runner.cc @@ -55,14 +55,14 @@ Runner Runner::PyRunner(Runner::FRun f_run) { /******** FFI ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { RunnerInputNode::RegisterReflection(); RunnerResultNode::RegisterReflection(); RunnerFutureNode::RegisterReflection(); PyRunnerNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("meta_schedule.RunnerInput", @@ -79,7 +79,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_method("meta_schedule.RunnerFutureResult", &RunnerFutureNode::Result) .def_method("meta_schedule.RunnerRun", &RunnerNode::Run) .def("meta_schedule.RunnerPyRunner", Runner::PyRunner); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule/cpu/winograd.cc b/src/meta_schedule/schedule/cpu/winograd.cc index 6a2b82aa426c..c3fd12e282b3 100644 --- a/src/meta_schedule/schedule/cpu/winograd.cc +++ b/src/meta_schedule/schedule/cpu/winograd.cc @@ -60,7 +60,7 @@ static ffi::Array ScheduleDataPack(tir::Schedule sch, tir::BlockRV return {t0[0], t1[0], t0[1], t1[1]}; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("meta_schedule.cpu.conv2d_nhwc_winograd_data_pack", @@ -97,7 +97,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ScheduleDataPack(sch, block, {0, 1}, {2, 3, 4, 5}); return {sch}; }); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule/cuda/winograd.cc b/src/meta_schedule/schedule/cuda/winograd.cc index 2b9f4f78df0e..74a70da58b36 100644 --- a/src/meta_schedule/schedule/cuda/winograd.cc +++ b/src/meta_schedule/schedule/cuda/winograd.cc @@ -64,7 +64,7 @@ static ffi::Array ScheduleDataPack(tir::Schedule sch, tir::BlockRV return {t0[0], t1[0], t0[1], t1[1]}; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("meta_schedule.cuda.conv2d_nhwc_winograd_data_pack", @@ -161,7 +161,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } return {sch}; }); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule_rule/add_rfactor.cc b/src/meta_schedule/schedule_rule/add_rfactor.cc index 7c4fc5a53baa..fad3279eb792 100644 --- a/src/meta_schedule/schedule_rule/add_rfactor.cc +++ b/src/meta_schedule/schedule_rule/add_rfactor.cc @@ -122,12 +122,12 @@ ffi::Array AddRFactorNode::Apply(const tir::Schedule& sch, return res; } -TVM_FFI_STATIC_INIT_BLOCK({ AddRFactorNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { AddRFactorNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ScheduleRuleAddRFactor", ScheduleRule::AddRFactor); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule_rule/apply_custom_rule.cc b/src/meta_schedule/schedule_rule/apply_custom_rule.cc index 89a52d101294..927ce3656c2f 100644 --- a/src/meta_schedule/schedule_rule/apply_custom_rule.cc +++ b/src/meta_schedule/schedule_rule/apply_custom_rule.cc @@ -91,12 +91,12 @@ bool ScheduleRule::IsApplyCustomRule(const ScheduleRule& rule) { return rule->IsInstance(); } -TVM_FFI_STATIC_INIT_BLOCK({ ApplyCustomRuleNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ApplyCustomRuleNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ScheduleRuleApplyCustomRule", ScheduleRule::ApplyCustomRule); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule_rule/auto_bind.cc b/src/meta_schedule/schedule_rule/auto_bind.cc index 6890413a8875..1ab276c5bec7 100644 --- a/src/meta_schedule/schedule_rule/auto_bind.cc +++ b/src/meta_schedule/schedule_rule/auto_bind.cc @@ -80,12 +80,12 @@ ScheduleRule ScheduleRule::AutoBind(int max_threadblocks, ffi::Array th return ScheduleRule(n); } -TVM_FFI_STATIC_INIT_BLOCK({ AutoBindNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { AutoBindNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ScheduleRuleAutoBind", ScheduleRule::AutoBind); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule_rule/auto_inline.cc b/src/meta_schedule/schedule_rule/auto_inline.cc index fba61e2f5e55..3d5fc8798c13 100644 --- a/src/meta_schedule/schedule_rule/auto_inline.cc +++ b/src/meta_schedule/schedule_rule/auto_inline.cc @@ -193,12 +193,12 @@ ScheduleRule ScheduleRule::AutoInline(bool into_producer, // return ScheduleRule(n); } -TVM_FFI_STATIC_INIT_BLOCK({ AutoInlineNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { AutoInlineNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ScheduleRuleAutoInline", ScheduleRule::AutoInline); -}); +} /*! \brief Inline blocks that produce a constant scalar. */ class InlineConstantScalarsNode : public ScheduleRuleNode { @@ -241,12 +241,12 @@ ScheduleRule ScheduleRule::InlineConstantScalars() { return ScheduleRule(n); } -TVM_FFI_STATIC_INIT_BLOCK({ InlineConstantScalarsNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { InlineConstantScalarsNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ScheduleRuleInlineConstantScalars", ScheduleRule::InlineConstantScalars); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule_rule/cross_thread_reduction.cc b/src/meta_schedule/schedule_rule/cross_thread_reduction.cc index 504de3c353b8..17e9552dcb60 100644 --- a/src/meta_schedule/schedule_rule/cross_thread_reduction.cc +++ b/src/meta_schedule/schedule_rule/cross_thread_reduction.cc @@ -295,13 +295,13 @@ ScheduleRule ScheduleRule::CrossThreadReduction(ffi::Array thread_exten return ScheduleRule(n); } -TVM_FFI_STATIC_INIT_BLOCK({ CrossThreadReductionNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { CrossThreadReductionNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ScheduleRuleCrossThreadReduction", ScheduleRule::CrossThreadReduction); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule_rule/multi_level_tiling.cc b/src/meta_schedule/schedule_rule/multi_level_tiling.cc index 2f796fa6b1da..ea78c4f6e3d3 100644 --- a/src/meta_schedule/schedule_rule/multi_level_tiling.cc +++ b/src/meta_schedule/schedule_rule/multi_level_tiling.cc @@ -55,7 +55,7 @@ using tir::IterVarType; using tir::LoopRV; using tir::Schedule; -TVM_FFI_STATIC_INIT_BLOCK({ MultiLevelTilingNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { MultiLevelTilingNode::RegisterReflection(); } State::State(tir::Schedule sch, tir::BlockRV block_rv, ffi::Array> tiles) { ObjectPtr node = ffi::make_object(); @@ -407,11 +407,11 @@ ScheduleRule ScheduleRule::MultiLevelTiling( return ScheduleRule(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ScheduleRuleMultiLevelTiling", ScheduleRule::MultiLevelTiling); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule_rule/multi_level_tiling_tensor_core.cc b/src/meta_schedule/schedule_rule/multi_level_tiling_tensor_core.cc index 42cc7b35caac..cdf69d8f1148 100644 --- a/src/meta_schedule/schedule_rule/multi_level_tiling_tensor_core.cc +++ b/src/meta_schedule/schedule_rule/multi_level_tiling_tensor_core.cc @@ -925,11 +925,11 @@ ScheduleRule ScheduleRule::MultiLevelTilingTensorCore( return ScheduleRule(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ScheduleRuleMultiLevelTilingTensorCore", ScheduleRule::MultiLevelTilingTensorCore); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule_rule/multi_level_tiling_wide_vector.cc b/src/meta_schedule/schedule_rule/multi_level_tiling_wide_vector.cc index 61e830a2284f..a09a38230d68 100644 --- a/src/meta_schedule/schedule_rule/multi_level_tiling_wide_vector.cc +++ b/src/meta_schedule/schedule_rule/multi_level_tiling_wide_vector.cc @@ -127,11 +127,11 @@ ScheduleRule ScheduleRule::MultiLevelTilingWideVector( return ScheduleRule(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ScheduleRuleMultiLevelTilingWideVector", ScheduleRule::MultiLevelTilingWideVector); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule_rule/multi_level_tiling_with_intrin.cc b/src/meta_schedule/schedule_rule/multi_level_tiling_with_intrin.cc index 2b038ba37b1f..7b67823ad76a 100644 --- a/src/meta_schedule/schedule_rule/multi_level_tiling_with_intrin.cc +++ b/src/meta_schedule/schedule_rule/multi_level_tiling_with_intrin.cc @@ -106,11 +106,11 @@ ScheduleRule ScheduleRule::MultiLevelTilingWithIntrin( return ScheduleRule(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ScheduleRuleMultiLevelTilingWithIntrin", ScheduleRule::MultiLevelTilingWithIntrin); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule_rule/parallel_vectorize_unroll.cc b/src/meta_schedule/schedule_rule/parallel_vectorize_unroll.cc index f0dd4e0a4123..9216c70e3328 100644 --- a/src/meta_schedule/schedule_rule/parallel_vectorize_unroll.cc +++ b/src/meta_schedule/schedule_rule/parallel_vectorize_unroll.cc @@ -135,13 +135,13 @@ ScheduleRule ScheduleRule::ParallelizeVectorizeUnroll(int max_jobs_per_core, return ScheduleRule(n); } -TVM_FFI_STATIC_INIT_BLOCK({ ParallelizeVectorizeUnrollNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ParallelizeVectorizeUnrollNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ScheduleRuleParallelizeVectorizeUnroll", ScheduleRule::ParallelizeVectorizeUnroll); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule_rule/random_compute_location.cc b/src/meta_schedule/schedule_rule/random_compute_location.cc index 4f7246fb3b8e..2c9975fcf916 100644 --- a/src/meta_schedule/schedule_rule/random_compute_location.cc +++ b/src/meta_schedule/schedule_rule/random_compute_location.cc @@ -125,12 +125,12 @@ ScheduleRule ScheduleRule::RandomComputeLocation() { return ScheduleRule(ffi::make_object()); } -TVM_FFI_STATIC_INIT_BLOCK({ RandomComputeLocationNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { RandomComputeLocationNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.ScheduleRuleRandomComputeLocation", ScheduleRule::RandomComputeLocation); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/schedule_rule/schedule_rule.cc b/src/meta_schedule/schedule_rule/schedule_rule.cc index 2aad6a8df548..9eac4ad57b20 100644 --- a/src/meta_schedule/schedule_rule/schedule_rule.cc +++ b/src/meta_schedule/schedule_rule/schedule_rule.cc @@ -459,12 +459,12 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) p->stream << f_as_string(); }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { ScheduleRuleNode::RegisterReflection(); PyScheduleRuleNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("meta_schedule.ScheduleRuleInitializeWithTuneContext", @@ -477,7 +477,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("meta_schedule.ScheduleRuleDefaultCUDATensorCore", ScheduleRule::DefaultCUDATensorCore) .def("meta_schedule.ScheduleRuleDefaultHexagon", ScheduleRule::DefaultHexagon) .def("meta_schedule.ScheduleRuleDefaultARM", ScheduleRule::DefaultARM); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/search_strategy/evolutionary_search.cc b/src/meta_schedule/search_strategy/evolutionary_search.cc index 3c0ea55592c7..8aa5aca45059 100644 --- a/src/meta_schedule/search_strategy/evolutionary_search.cc +++ b/src/meta_schedule/search_strategy/evolutionary_search.cc @@ -802,9 +802,9 @@ ffi::Array EvolutionarySearchEvolveWithCostModel(EvolutionarySearch se return result; } -TVM_FFI_STATIC_INIT_BLOCK({ EvolutionarySearchNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { EvolutionarySearchNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("meta_schedule.SearchStrategyEvolutionarySearch", SearchStrategy::EvolutionarySearch) @@ -812,7 +812,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ EvolutionarySearchSampleInitPopulation) .def("meta_schedule.SearchStrategyEvolutionarySearchEvolveWithCostModel", EvolutionarySearchEvolveWithCostModel); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/search_strategy/replay_func.cc b/src/meta_schedule/search_strategy/replay_func.cc index 8e9b0032395f..498857ad96cd 100644 --- a/src/meta_schedule/search_strategy/replay_func.cc +++ b/src/meta_schedule/search_strategy/replay_func.cc @@ -161,12 +161,12 @@ SearchStrategy SearchStrategy::ReplayFunc() { return SearchStrategy(n); } -TVM_FFI_STATIC_INIT_BLOCK({ ReplayFuncNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ReplayFuncNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.SearchStrategyReplayFunc", SearchStrategy::ReplayFunc); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/search_strategy/replay_trace.cc b/src/meta_schedule/search_strategy/replay_trace.cc index 90c57a0b23e4..7898b171d357 100644 --- a/src/meta_schedule/search_strategy/replay_trace.cc +++ b/src/meta_schedule/search_strategy/replay_trace.cc @@ -190,12 +190,12 @@ SearchStrategy SearchStrategy::ReplayTrace(int max_fail_count) { return SearchStrategy(n); } -TVM_FFI_STATIC_INIT_BLOCK({ ReplayTraceNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ReplayTraceNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.SearchStrategyReplayTrace", SearchStrategy::ReplayTrace); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/search_strategy/search_strategy.cc b/src/meta_schedule/search_strategy/search_strategy.cc index 3d0941c3632f..3273e70ac1b8 100644 --- a/src/meta_schedule/search_strategy/search_strategy.cc +++ b/src/meta_schedule/search_strategy/search_strategy.cc @@ -85,12 +85,12 @@ SearchStrategy SearchStrategy::PySearchStrategy( return SearchStrategy(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { MeasureCandidateNode::RegisterReflection(); PySearchStrategyNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("meta_schedule.MeasureCandidate", @@ -107,7 +107,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_method("meta_schedule.SearchStrategyNotifyRunnerResults", &SearchStrategyNode::NotifyRunnerResults) .def_method("meta_schedule.SearchStrategyClone", &SearchStrategyNode::Clone); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/space_generator/post_order_apply.cc b/src/meta_schedule/space_generator/post_order_apply.cc index aeb7d2b68d4d..26829356e56a 100644 --- a/src/meta_schedule/space_generator/post_order_apply.cc +++ b/src/meta_schedule/space_generator/post_order_apply.cc @@ -115,13 +115,13 @@ SpaceGenerator SpaceGenerator::PostOrderApply( return SpaceGenerator(n); } -TVM_FFI_STATIC_INIT_BLOCK({ PostOrderApplyNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { PostOrderApplyNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.SpaceGeneratorPostOrderApply", SpaceGenerator::PostOrderApply); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/space_generator/schedule_fn.cc b/src/meta_schedule/space_generator/schedule_fn.cc index 9cd99f8a5365..687abef75fe6 100644 --- a/src/meta_schedule/space_generator/schedule_fn.cc +++ b/src/meta_schedule/space_generator/schedule_fn.cc @@ -95,12 +95,12 @@ SpaceGenerator SpaceGenerator::ScheduleFn( return SpaceGenerator(n); } -TVM_FFI_STATIC_INIT_BLOCK({ ScheduleFnNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ScheduleFnNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.SpaceGeneratorScheduleFn", SpaceGenerator::ScheduleFn); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/space_generator/space_generator.cc b/src/meta_schedule/space_generator/space_generator.cc index e6f01fa51760..9e458a3ad7cf 100644 --- a/src/meta_schedule/space_generator/space_generator.cc +++ b/src/meta_schedule/space_generator/space_generator.cc @@ -201,12 +201,12 @@ SpaceGenerator SpaceGenerator::PySpaceGenerator( return SpaceGenerator(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { SpaceGeneratorNode::RegisterReflection(); PySpaceGeneratorNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("meta_schedule.SpaceGeneratorInitializeWithTuneContext", @@ -215,7 +215,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ &SpaceGeneratorNode::GenerateDesignSpace) .def("meta_schedule.SpaceGeneratorPySpaceGenerator", SpaceGenerator::PySpaceGenerator) .def_method("meta_schedule.SpaceGeneratorClone", &SpaceGeneratorNode::Clone); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/space_generator/space_generator_union.cc b/src/meta_schedule/space_generator/space_generator_union.cc index 922fe4e670d1..026daa68a762 100644 --- a/src/meta_schedule/space_generator/space_generator_union.cc +++ b/src/meta_schedule/space_generator/space_generator_union.cc @@ -83,13 +83,13 @@ SpaceGenerator SpaceGenerator::SpaceGeneratorUnion( return SpaceGenerator(n); } -TVM_FFI_STATIC_INIT_BLOCK({ SpaceGeneratorUnionNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { SpaceGeneratorUnionNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.SpaceGeneratorSpaceGeneratorUnion", SpaceGenerator::SpaceGeneratorUnion); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/task_scheduler/gradient_based.cc b/src/meta_schedule/task_scheduler/gradient_based.cc index c37fd4b51898..babf521c280c 100644 --- a/src/meta_schedule/task_scheduler/gradient_based.cc +++ b/src/meta_schedule/task_scheduler/gradient_based.cc @@ -143,12 +143,12 @@ TaskScheduler TaskScheduler::GradientBased(ffi::Function logger, double alpha, i return TaskScheduler(n); } -TVM_FFI_STATIC_INIT_BLOCK({ GradientBasedNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { GradientBasedNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.TaskSchedulerGradientBased", TaskScheduler::GradientBased); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/task_scheduler/round_robin.cc b/src/meta_schedule/task_scheduler/round_robin.cc index efae9928ef9a..c3b95a7cc4c6 100644 --- a/src/meta_schedule/task_scheduler/round_robin.cc +++ b/src/meta_schedule/task_scheduler/round_robin.cc @@ -62,12 +62,12 @@ TaskScheduler TaskScheduler::RoundRobin(ffi::Function logger) { return TaskScheduler(n); } -TVM_FFI_STATIC_INIT_BLOCK({ RoundRobinNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { RoundRobinNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("meta_schedule.TaskSchedulerRoundRobin", TaskScheduler::RoundRobin); -}); +} } // namespace meta_schedule } // namespace tvm diff --git a/src/meta_schedule/task_scheduler/task_scheduler.cc b/src/meta_schedule/task_scheduler/task_scheduler.cc index cc337d99a3a4..85c6d71b4307 100644 --- a/src/meta_schedule/task_scheduler/task_scheduler.cc +++ b/src/meta_schedule/task_scheduler/task_scheduler.cc @@ -23,11 +23,11 @@ namespace tvm { namespace meta_schedule { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { TaskRecordNode::RegisterReflection(); TaskSchedulerNode::RegisterReflection(); PyTaskSchedulerNode::RegisterReflection(); -}); +} TaskRecord::TaskRecord(TuneContext ctx, double task_weight) { ObjectPtr n = ffi::make_object(); @@ -371,7 +371,7 @@ void PyTaskSchedulerNode::Tune(ffi::Array tasks, ffi::Arraystream << Downcast(node); }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("node.AsRepr", [](ffi::Any obj) { std::ostringstream os; os << obj; return os.str(); }); -}); +} } // namespace tvm diff --git a/src/node/script_printer.cc b/src/node/script_printer.cc index 68b2b392105b..36c61d78b345 100644 --- a/src/node/script_printer.cc +++ b/src/node/script_printer.cc @@ -28,7 +28,7 @@ namespace tvm { using AccessPath = ffi::reflection::AccessPath; -TVM_FFI_STATIC_INIT_BLOCK({ PrinterConfigNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { PrinterConfigNode::RegisterReflection(); } TVMScriptPrinter::FType& TVMScriptPrinter::vtable() { static FType inst; @@ -145,12 +145,12 @@ ffi::Array PrinterConfigNode::GetBuiltinKeywords() { return result; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("node.PrinterConfig", [](ffi::Map config_dict) { return PrinterConfig(config_dict); }) .def("node.TVMScriptPrinterScript", TVMScriptPrinter::Script); -}); +} } // namespace tvm diff --git a/src/node/serialization.cc b/src/node/serialization.cc index 09e364bb8ee4..2faf8d170bd8 100644 --- a/src/node/serialization.cc +++ b/src/node/serialization.cc @@ -40,8 +40,8 @@ Any LoadJSON(std::string json_str) { return ffi::FromJSONGraph(jgraph); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("node.SaveJSON", SaveJSON).def("node.LoadJSON", LoadJSON); -}); +} } // namespace tvm diff --git a/src/node/structural_equal.cc b/src/node/structural_equal.cc index be009a77c305..e33d7c774687 100644 --- a/src/node/structural_equal.cc +++ b/src/node/structural_equal.cc @@ -73,12 +73,12 @@ bool NodeStructuralEqualAdapter(const Any& lhs, const Any& rhs, bool assert_mode } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("node.StructuralEqual", NodeStructuralEqualAdapter) .def("node.GetFirstStructuralMismatch", ffi::StructuralEqual::GetFirstMismatch); -}); +} bool StructuralEqual::operator()(const ffi::Any& lhs, const ffi::Any& rhs, bool map_free_params) const { diff --git a/src/node/structural_hash.cc b/src/node/structural_hash.cc index 24916fb18803..aa02d097e966 100644 --- a/src/node/structural_hash.cc +++ b/src/node/structural_hash.cc @@ -41,7 +41,7 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("node.StructuralHash", [](const Any& object, bool map_free_vars) -> int64_t { @@ -78,7 +78,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ICHECK(temp.Load(&b64strm)); return temp; }); -}); +} uint64_t StructuralHash::operator()(const ffi::Any& object) const { return ffi::StructuralHash::Hash(object, false); @@ -100,7 +100,7 @@ struct ReportNodeTrait { } }; -TVM_FFI_STATIC_INIT_BLOCK({ ReportNodeTrait::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ReportNodeTrait::RegisterReflection(); } TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { @@ -116,7 +116,7 @@ struct CountNodeTrait { } }; -TVM_FFI_STATIC_INIT_BLOCK({ CountNodeTrait::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { CountNodeTrait::RegisterReflection(); } TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { @@ -132,7 +132,7 @@ struct DurationNodeTrait { } }; -TVM_FFI_STATIC_INIT_BLOCK({ DurationNodeTrait::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { DurationNodeTrait::RegisterReflection(); } TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { @@ -148,7 +148,7 @@ struct PercentNodeTrait { } }; -TVM_FFI_STATIC_INIT_BLOCK({ PercentNodeTrait::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { PercentNodeTrait::RegisterReflection(); } TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { @@ -164,7 +164,7 @@ struct RatioNodeTrait { } }; -TVM_FFI_STATIC_INIT_BLOCK({ RatioNodeTrait::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { RatioNodeTrait::RegisterReflection(); } TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { diff --git a/src/relax/analysis/analysis.cc b/src/relax/analysis/analysis.cc index c2d29f9837bd..a61d548443a3 100644 --- a/src/relax/analysis/analysis.cc +++ b/src/relax/analysis/analysis.cc @@ -202,7 +202,7 @@ bool ContainsImpureCall(const Expr& expr, const ffi::Optional& own_name) { return FindImpureCall(expr, own_name).defined(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.analysis.free_vars", FreeVars) @@ -210,7 +210,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("relax.analysis.all_vars", AllVars) .def("relax.analysis.all_global_vars", AllGlobalVars) .def("relax.analysis.contains_impure_call", ContainsImpureCall); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/analysis/computable_at_compile_time.cc b/src/relax/analysis/computable_at_compile_time.cc index 5ce64fcef220..954240c19189 100644 --- a/src/relax/analysis/computable_at_compile_time.cc +++ b/src/relax/analysis/computable_at_compile_time.cc @@ -93,10 +93,10 @@ ffi::Array ComputableAtCompileTime(const Function& func) { return CompileTimeCollector::Collect(func); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.computable_at_compile_time", ComputableAtCompileTime); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/analysis/detect_recursion.cc b/src/relax/analysis/detect_recursion.cc index 05260d18d89e..7b2a5f516e92 100644 --- a/src/relax/analysis/detect_recursion.cc +++ b/src/relax/analysis/detect_recursion.cc @@ -393,10 +393,10 @@ tvm::ffi::Array> DetectRecursion(const IRModule& m) { return ret; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.detect_recursion", DetectRecursion); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/analysis/layout_transformation.cc b/src/relax/analysis/layout_transformation.cc index aa5ceea01560..5bd5568a93a3 100644 --- a/src/relax/analysis/layout_transformation.cc +++ b/src/relax/analysis/layout_transformation.cc @@ -615,13 +615,13 @@ ffi::Map> SuggestLayoutTransforms return analyzer.GetSuggestedTransforms(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.suggest_layout_transforms", [](PrimFunc fn, ffi::Array write_buffer_transformations) { return SuggestLayoutTransforms(fn, write_buffer_transformations); }); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/analysis/struct_info_analysis.cc b/src/relax/analysis/struct_info_analysis.cc index 53f76cadcbba..3952b1ce4a6e 100644 --- a/src/relax/analysis/struct_info_analysis.cc +++ b/src/relax/analysis/struct_info_analysis.cc @@ -73,11 +73,11 @@ class StaticTypeDeriver : public StructInfoFunctor { Type GetStaticType(const StructInfo& info) { return StaticTypeDeriver()(info); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.GetStaticType", [](const StructInfo& info) { return GetStaticType(info); }); -}); +} //-------------------------- // StructInfoFromType @@ -290,13 +290,13 @@ StructInfo EraseToWellDefined(const StructInfo& info, ffi::Map shape_var_map, ffi::Map var_map) { return EraseToWellDefined(info, shape_var_map, var_map); }); -}); +} //-------------------------- // IsBaseOf @@ -603,24 +603,24 @@ BaseCheckResult StructInfoBaseCheck(const StructInfo& base, const StructInfo& de } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.StructInfoBaseCheck", [](const StructInfo& base, const StructInfo& derived) -> int { return static_cast(StructInfoBaseCheck(base, derived)); }); -}); +} bool IsBaseOf(const StructInfo& base, const StructInfo& derived, arith::Analyzer* ana) { return StructInfoBaseCheck(base, derived, ana) == BaseCheckResult::kPass; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.StructInfoIsBaseOf", [](const StructInfo& base, const StructInfo& derived) { return IsBaseOf(base, derived); }); -}); +} class StructInfoBasePreconditionCollector : public StructInfoFunctor { @@ -968,13 +968,13 @@ StructInfo DeriveCallRetStructInfo(const FuncStructInfo& finfo, const Call& call } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.DeriveCallRetStructInfo", [](const FuncStructInfo& finfo, const Call& call, const BlockBuilder& ctx) { return DeriveCallRetStructInfo(finfo, call, ctx); }); -}); +} //-------------------------- // UnifyToLCA @@ -1174,12 +1174,12 @@ StructInfo StructInfoLCA(const StructInfo& lhs, const StructInfo& rhs, arith::An } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.analysis.StructInfoLCA", [](const StructInfo& lhs, const StructInfo& rhs) { return StructInfoLCA(lhs, rhs); }); -}); +} //-------------------------- // TIRVarsInStructInfo @@ -1191,7 +1191,7 @@ class TIRVarsDetector : public StructInfoVisitor { Definition, Usage, }; - TIRVarsDetector(VarType collection_type) : collection_type(collection_type) {} + explicit TIRVarsDetector(VarType collection_type) : collection_type(collection_type) {} ffi::Array GetTIRVars() const { return tir_vars_; } @@ -1259,12 +1259,12 @@ ffi::Array DefinableTIRVarsInStructInfo(const StructInfo& sinfo) { return detector.GetTIRVars(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.analysis.TIRVarsInStructInfo", TIRVarsInStructInfo) .def("relax.analysis.DefinableTIRVarsInStructInfo", DefinableTIRVarsInStructInfo); -}); +} class NonNegativeExpressionCollector : relax::StructInfoVisitor { public: @@ -1308,11 +1308,11 @@ ffi::Array CollectNonNegativeExpressions(const StructInfo& sinfo) { return NonNegativeExpressionCollector::Collect(sinfo); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.CollectNonNegativeExpressions", CollectNonNegativeExpressions); -}); +} class SymbolicVarCollector : public relax::ExprVisitor, public relax::StructInfoVisitor, @@ -1460,12 +1460,12 @@ ffi::Array DefinedSymbolicVars(const Expr& expr) { } ffi::Array FreeSymbolicVars(const Expr& expr) { return SymbolicVarCollector::Free(expr); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.analysis.DefinedSymbolicVars", DefinedSymbolicVars) .def("relax.analysis.FreeSymbolicVars", FreeSymbolicVars); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/analysis/tir_op_pattern_kind.cc b/src/relax/analysis/tir_op_pattern_kind.cc index 0d9e92c17a84..58c47529a103 100644 --- a/src/relax/analysis/tir_op_pattern_kind.cc +++ b/src/relax/analysis/tir_op_pattern_kind.cc @@ -539,10 +539,10 @@ bool HasReshapePattern(const PrimFunc& func) { return ReshapeDetector::Detect(src_buffer, dst_buffer, func->body); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.has_reshape_pattern", HasReshapePattern); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/analysis/udchain.cc b/src/relax/analysis/udchain.cc index 0045753ff619..bbdbb7b644ef 100644 --- a/src/relax/analysis/udchain.cc +++ b/src/relax/analysis/udchain.cc @@ -119,10 +119,10 @@ ffi::Map> DataflowBlockUseDef(const DataflowBlock& dfb) { return usage.downstream_usage; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.udchain", DataflowBlockUseDef); -}); +} VarUsageInfo CollectVarUsage(const Expr& expr) { return UDChain::Collect(expr); } diff --git a/src/relax/analysis/var2value.cc b/src/relax/analysis/var2value.cc index 3a8a5c0ce80a..17a439b408ff 100644 --- a/src/relax/analysis/var2value.cc +++ b/src/relax/analysis/var2value.cc @@ -59,11 +59,11 @@ ffi::Map AnalyzeVar2Value(const IRModule& m) { return std::move(var2val_analysis.var2value_); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.get_var2val", [](const Function& f) { return AnalyzeVar2Value(f); }); -}); +} class Name2BindingAnalysis : public relax::ExprVisitor { public: @@ -89,10 +89,10 @@ ffi::Map> NameToBinding(const Function& fn) { std::make_move_iterator(analysis.name2bindings_.end())); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.name_to_binding", NameToBinding); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/analysis/well_formed.cc b/src/relax/analysis/well_formed.cc index 14694b31f4da..0cfc9efad835 100644 --- a/src/relax/analysis/well_formed.cc +++ b/src/relax/analysis/well_formed.cc @@ -650,10 +650,10 @@ bool WellFormed(ffi::Variant obj, bool check_struct_info) { return WellFormedChecker::Check(obj, check_struct_info); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.well_formed", WellFormed); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/backend/contrib/clml/codegen.cc b/src/relax/backend/contrib/clml/codegen.cc index ba37dabe964d..362621f4238e 100644 --- a/src/relax/backend/contrib/clml/codegen.cc +++ b/src/relax/backend/contrib/clml/codegen.cc @@ -58,7 +58,7 @@ class OpenCLMLCompilerConfig : public Attrs { OpenCLMLCompilerConfigNode); }; -TVM_FFI_STATIC_INIT_BLOCK({ OpenCLMLCompilerConfigNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { OpenCLMLCompilerConfigNode::RegisterReflection(); } TVM_REGISTER_PASS_CONFIG_OPTION("relax.ext.clml.options", OpenCLMLCompilerConfig); @@ -329,10 +329,10 @@ ffi::Array OpenCLMLCompiler(ffi::Array functions, return compiled_functions; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ext.openclml", OpenCLMLCompiler); -}); +} /*! * \brief Check whether OpenCLML graph executor is enabled. @@ -358,12 +358,12 @@ Integer GetOpenCLMLVersion() { #endif // TVM_GRAPH_EXECUTOR_CLML } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.is_openclml_runtime_enabled", IsOpenCLMLRuntimeEnabled) .def("relax.get_openclml_version", GetOpenCLMLVersion); -}); +} } // namespace contrib } // namespace relax diff --git a/src/relax/backend/contrib/cublas/codegen.cc b/src/relax/backend/contrib/cublas/codegen.cc index c403cac30696..ab8336bfd5b2 100644 --- a/src/relax/backend/contrib/cublas/codegen.cc +++ b/src/relax/backend/contrib/cublas/codegen.cc @@ -127,10 +127,10 @@ ffi::Array CublasCompiler(ffi::Array functions, return compiled_functions; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ext.cublas", CublasCompiler); -}); +} } // namespace contrib } // namespace relax diff --git a/src/relax/backend/contrib/cudnn/codegen.cc b/src/relax/backend/contrib/cudnn/codegen.cc index b612a9aa3b02..0773a627accd 100644 --- a/src/relax/backend/contrib/cudnn/codegen.cc +++ b/src/relax/backend/contrib/cudnn/codegen.cc @@ -151,10 +151,10 @@ ffi::Array cuDNNCompiler(ffi::Array functions, return compiled_functions; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ext.cudnn", cuDNNCompiler); -}); +} } // namespace contrib } // namespace relax diff --git a/src/relax/backend/contrib/cutlass/codegen.cc b/src/relax/backend/contrib/cutlass/codegen.cc index 69efd93ac02f..69da3d6058ed 100644 --- a/src/relax/backend/contrib/cutlass/codegen.cc +++ b/src/relax/backend/contrib/cutlass/codegen.cc @@ -101,15 +101,15 @@ class CodegenResult : public ObjectRef { TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(CodegenResult, ObjectRef, CodegenResultNode); }; -TVM_FFI_STATIC_INIT_BLOCK({ CodegenResultNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { CodegenResultNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("contrib.cutlass.CodegenResult", [](ffi::String code, ffi::Array headers) { return CodegenResult(code, headers); }); -}); +} GenerateBodyOutput GenerateBody(const std::string& func_name, const std::string& ext_func_id, const std::vector& output_types, @@ -391,10 +391,10 @@ ffi::Array CUTLASSCompiler(ffi::Array functions, return {cutlass_mod}; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ext.cutlass", CUTLASSCompiler); -}); +} } // namespace contrib } // namespace relax diff --git a/src/relax/backend/contrib/dnnl/codegen.cc b/src/relax/backend/contrib/dnnl/codegen.cc index 6db5ae7dd628..e903ed885296 100644 --- a/src/relax/backend/contrib/dnnl/codegen.cc +++ b/src/relax/backend/contrib/dnnl/codegen.cc @@ -99,10 +99,10 @@ ffi::Array DNNLCompiler(ffi::Array functions, return compiled_functions; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ext.dnnl", DNNLCompiler); -}); +} } // namespace contrib } // namespace relax diff --git a/src/relax/backend/contrib/hipblas/codegen.cc b/src/relax/backend/contrib/hipblas/codegen.cc index 872ac23c5909..09a0f0026789 100644 --- a/src/relax/backend/contrib/hipblas/codegen.cc +++ b/src/relax/backend/contrib/hipblas/codegen.cc @@ -105,10 +105,10 @@ ffi::Array HipblasCompiler(ffi::Array functions, return compiled_functions; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ext.hipblas", HipblasCompiler); -}); +} } // namespace contrib } // namespace relax diff --git a/src/relax/backend/contrib/nnapi/codegen.cc b/src/relax/backend/contrib/nnapi/codegen.cc index 37f16ebf1493..92933ba070b9 100644 --- a/src/relax/backend/contrib/nnapi/codegen.cc +++ b/src/relax/backend/contrib/nnapi/codegen.cc @@ -269,10 +269,10 @@ ffi::Array NNAPICompiler(ffi::Array functions, return compiled_functions; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ext.nnapi", NNAPICompiler); -}); +} } // namespace contrib } // namespace relax diff --git a/src/relax/backend/contrib/tensorrt/codegen.cc b/src/relax/backend/contrib/tensorrt/codegen.cc index a115d9c3483c..0adeb2d47570 100644 --- a/src/relax/backend/contrib/tensorrt/codegen.cc +++ b/src/relax/backend/contrib/tensorrt/codegen.cc @@ -80,7 +80,7 @@ class TensorRTCompilerConfig : public Attrs { TensorRTCompilerConfigNode); }; -TVM_FFI_STATIC_INIT_BLOCK({ TensorRTCompilerConfigNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { TensorRTCompilerConfigNode::RegisterReflection(); } TVM_REGISTER_PASS_CONFIG_OPTION("relax.ext.tensorrt.options", TensorRTCompilerConfig); @@ -244,10 +244,10 @@ ffi::Array TensorRTCompiler(ffi::Array functions, return compiled_functions; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ext.tensorrt", TensorRTCompiler); -}); +} /*! * \brief Check whether TensorRT graph executor is enabled. @@ -274,12 +274,12 @@ ffi::Array GetTensorRTVersion() { #endif // TVM_GRAPH_EXECUTOR_TENSORRT } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.is_tensorrt_runtime_enabled", IsTensorRTRuntimeEnabled) .def("relax.get_tensorrt_version", GetTensorRTVersion); -}); +} } // namespace contrib } // namespace relax diff --git a/src/relax/backend/contrib/utils.cc b/src/relax/backend/contrib/utils.cc index 3855c67702ff..1840986c019d 100644 --- a/src/relax/backend/contrib/utils.cc +++ b/src/relax/backend/contrib/utils.cc @@ -76,10 +76,10 @@ bool EndsWithPattern(const std::string& str, const std::string& pattern) { return str.compare(str.length() - pattern.length(), pattern.length(), pattern) == 0; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.contrib.extract_arg_idx", ExtractArgIdx); -}); +} } // namespace backend } // namespace relax diff --git a/src/relax/backend/pattern_registry.cc b/src/relax/backend/pattern_registry.cc index fe6ef60073d6..c11ef6a35e07 100644 --- a/src/relax/backend/pattern_registry.cc +++ b/src/relax/backend/pattern_registry.cc @@ -69,14 +69,14 @@ ffi::Optional GetPattern(const ffi::String& pattern_name) { return std::nullopt; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.backend.RegisterPatterns", RegisterPatterns) .def("relax.backend.RemovePatterns", RemovePatterns) .def("relax.backend.GetPatternsWithPrefix", GetPatternsWithPrefix) .def("relax.backend.GetPattern", GetPattern); -}); +} } // namespace backend } // namespace relax diff --git a/src/relax/backend/task_extraction.cc b/src/relax/backend/task_extraction.cc index 97dd75945ce5..71c024b9d7a0 100644 --- a/src/relax/backend/task_extraction.cc +++ b/src/relax/backend/task_extraction.cc @@ -141,13 +141,13 @@ class TaskExtractor : public ExprVisitor { std::optional normalize_mod_func_; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.backend.MetaScheduleExtractTask", [](IRModule mod, Target target, ffi::String mod_eq_name) { return TaskExtractor::ExtractTask(std::move(mod), std::move(target), std::move(mod_eq_name)); }); -}); +} } // namespace backend } // namespace relax diff --git a/src/relax/backend/vm/codegen_vm.cc b/src/relax/backend/vm/codegen_vm.cc index e29f580793b1..96dac05cb63e 100644 --- a/src/relax/backend/vm/codegen_vm.cc +++ b/src/relax/backend/vm/codegen_vm.cc @@ -427,10 +427,10 @@ IRModule VMCodeGen(ExecBuilder exec_builder, IRModule mod) { return CodeGenVM::Run(exec_builder, mod); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.VMCodeGen", VMCodeGen); -}); +} /*! * \brief Link the modules together, possibly create a constant module. @@ -496,10 +496,10 @@ ffi::Module VMLink(ExecBuilder builder, Target target, ffi::Optional()); @@ -319,7 +319,7 @@ void ExecBuilderNode::Formalize() { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.ExecBuilderCreate", ExecBuilderNode::Create) @@ -377,7 +377,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ObjectPtr p_exec = builder->Get(); return ffi::Module(p_exec); }); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/backend/vm/lower_runtime_builtin.cc b/src/relax/backend/vm/lower_runtime_builtin.cc index cb5b8e8b1360..d52155c615ac 100644 --- a/src/relax/backend/vm/lower_runtime_builtin.cc +++ b/src/relax/backend/vm/lower_runtime_builtin.cc @@ -232,10 +232,10 @@ Pass LowerRuntimeBuiltin() { return CreateFunctionPass(pass_func, 0, "LowerRuntimeBuiltin", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.LowerRuntimeBuiltin", LowerRuntimeBuiltin); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/backend/vm/vm_shape_lower.cc b/src/relax/backend/vm/vm_shape_lower.cc index da9f1a029a44..bbc227d1d559 100644 --- a/src/relax/backend/vm/vm_shape_lower.cc +++ b/src/relax/backend/vm/vm_shape_lower.cc @@ -815,11 +815,11 @@ Pass VMShapeLower(bool emit_err_ctx) { return CreateModulePass(pass_func, 0, "VMShapeLower", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.VMShapeLower", [](bool emit_err_ctx) { return VMShapeLower(emit_err_ctx); }); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/distributed/global_info.cc b/src/relax/distributed/global_info.cc index 4ac44d252560..408d31680c79 100644 --- a/src/relax/distributed/global_info.cc +++ b/src/relax/distributed/global_info.cc @@ -24,7 +24,7 @@ namespace tvm { namespace relax { namespace distributed { -TVM_FFI_STATIC_INIT_BLOCK({ DeviceMeshNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { DeviceMeshNode::RegisterReflection(); } DeviceMesh::DeviceMesh(ffi::Shape shape, ffi::Array device_ids) { int prod = 1; @@ -59,7 +59,7 @@ DeviceMesh::DeviceMesh(ffi::Shape shape, Range device_range) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.distributed.DeviceMesh", @@ -69,7 +69,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ else return DeviceMesh(shape, device_ids); }); -}); +} } // namespace distributed } // namespace relax diff --git a/src/relax/distributed/struct_info.cc b/src/relax/distributed/struct_info.cc index 64ee815b19ba..5c51920fa7e6 100644 --- a/src/relax/distributed/struct_info.cc +++ b/src/relax/distributed/struct_info.cc @@ -28,11 +28,11 @@ namespace tvm { namespace relax { namespace distributed { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { DTensorStructInfoNode::RegisterReflection(); PlacementNode::RegisterReflection(); PlacementSpecNode::RegisterReflection(); -}); +} PlacementSpec PlacementSpec::Sharding(int axis) { ObjectPtr n = ffi::make_object(); @@ -48,12 +48,12 @@ PlacementSpec PlacementSpec::Replica() { return PlacementSpec(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.distributed.Sharding", [](int axis) { return PlacementSpec::Sharding(axis); }) .def("relax.distributed.Replica", []() { return PlacementSpec::Replica(); }); -}); +} ffi::String PlacementNode::ToString() const { std::stringstream ss; @@ -109,13 +109,13 @@ Placement Placement::FromText(ffi::String text_repr) { return Placement(dim_specs); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.distributed.PlacementFromText", Placement::FromText) .def("relax.distributed.Placement", [](ffi::Array dim_specs) { return Placement(dim_specs); }); -}); +} // DTensor DTensorStructInfo::DTensorStructInfo(TensorStructInfo tensor_sinfo, DeviceMesh device_mesh, @@ -135,14 +135,14 @@ DTensorStructInfo::DTensorStructInfo(TensorStructInfo tensor_sinfo, DeviceMesh d data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.distributed.DTensorStructInfo", [](TensorStructInfo tensor_sinfo, DeviceMesh device_mesh, Placement placement, Span span) { return DTensorStructInfo(tensor_sinfo, device_mesh, placement, span); }); -}); +} } // namespace distributed } // namespace relax diff --git a/src/relax/distributed/transform/legalize_redistribute.cc b/src/relax/distributed/transform/legalize_redistribute.cc index d9a786867453..aaac39c61b20 100644 --- a/src/relax/distributed/transform/legalize_redistribute.cc +++ b/src/relax/distributed/transform/legalize_redistribute.cc @@ -116,10 +116,10 @@ Pass LegalizeRedistribute() { }; return CreateModulePass(pass_func, 1, "LegalizeRedistribute", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.distributed.transform.LegalizeRedistribute", LegalizeRedistribute); -}); +} } // namespace transform } // namespace distributed diff --git a/src/relax/distributed/transform/lower_distir.cc b/src/relax/distributed/transform/lower_distir.cc index e4131549f487..7930e2dfe7fc 100644 --- a/src/relax/distributed/transform/lower_distir.cc +++ b/src/relax/distributed/transform/lower_distir.cc @@ -264,10 +264,10 @@ Pass LowerDistIR() { auto pass_func = [=](IRModule m, PassContext pc) { return DistIRSharder::LowerDistIR(m); }; return CreateModulePass(pass_func, 1, "LowerDistIR", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.distributed.transform.LowerDistIR", LowerDistIR); -}); +} } // namespace transform } // namespace distributed diff --git a/src/relax/distributed/transform/lower_global_view_to_local_view.cc b/src/relax/distributed/transform/lower_global_view_to_local_view.cc index b93deb9d2b13..f83edb3e90c6 100644 --- a/src/relax/distributed/transform/lower_global_view_to_local_view.cc +++ b/src/relax/distributed/transform/lower_global_view_to_local_view.cc @@ -432,11 +432,11 @@ Pass LowerGlobalViewToLocalView() { auto pass_func = [=](IRModule m, PassContext pc) { return LowerTIRToLocalView(m).Lower(); }; return CreateModulePass(pass_func, 1, "LowerGlobalViewToLocalView", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.distributed.transform.LowerGlobalViewToLocalView", LowerGlobalViewToLocalView); -}); +} } // namespace transform } // namespace distributed diff --git a/src/relax/distributed/transform/propagate_sharding.cc b/src/relax/distributed/transform/propagate_sharding.cc index 71e27e8ffd52..1ff614c019c8 100644 --- a/src/relax/distributed/transform/propagate_sharding.cc +++ b/src/relax/distributed/transform/propagate_sharding.cc @@ -617,10 +617,10 @@ Pass PropagateSharding() { }; return CreateModulePass(pass_func, 1, "PropagateSharding", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.distributed.transform.PropagateSharding", PropagateSharding); -}); +} } // namespace transform } // namespace distributed diff --git a/src/relax/ir/binding_rewrite.cc b/src/relax/ir/binding_rewrite.cc index 44688e27e162..0bbfef31b83a 100644 --- a/src/relax/ir/binding_rewrite.cc +++ b/src/relax/ir/binding_rewrite.cc @@ -36,7 +36,7 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ DataflowBlockRewriteNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { DataflowBlockRewriteNode::RegisterReflection(); } DataflowBlockRewrite::DataflowBlockRewrite(DataflowBlock dfb, Function root_fn) { auto n = ffi::make_object(); @@ -52,12 +52,12 @@ DataflowBlockRewrite::DataflowBlockRewrite(DataflowBlock dfb, Function root_fn) data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.DataflowBlockRewrite", [](DataflowBlock dfb, Function root_fn) { return DataflowBlockRewrite(dfb, root_fn); }); -}); +} void DataflowBlockRewriteNode::ReplaceAllUses(Var old_var, Var new_var) { class ReplaceAllUsePass : public ExprMutator { @@ -113,13 +113,13 @@ void DataflowBlockRewriteNode::ReplaceAllUses(Var old_var, Var new_var) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dfb_rewrite_replace_all_uses", [](DataflowBlockRewrite rwt, Var old_var, Var new_var) { rwt->ReplaceAllUses(old_var, new_var); }); -}); +} class UpdateDFB : public ExprMutator { private: @@ -184,7 +184,7 @@ void DataflowBlockRewriteNode::Add(Binding binding) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.dfb_rewrite_add_binding", @@ -197,7 +197,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ rwt->Add(expr, is_dfvar); } }); -}); +} std::set GetUnusedVars(ffi::Map> users_map, ffi::Array fn_outputs) { std::vector unused; @@ -246,7 +246,7 @@ class RemoveUnusedVars : public ExprMutator { std::set unused_vars; ffi::Optional caught_rewrite = std::nullopt; - RemoveUnusedVars(std::set unused_vars) : unused_vars(std::move(unused_vars)) {} + explicit RemoveUnusedVars(std::set unused_vars) : unused_vars(std::move(unused_vars)) {} RemoveUnusedVars(ffi::Map> users, ffi::Array fn_outputs) : RemoveUnusedVars(GetUnusedVars(users, fn_outputs)) {} @@ -301,13 +301,13 @@ void DataflowBlockRewriteNode::RemoveUnused(Var unused, bool allow_undef) { to_users_.erase(unused); // update use-def chain. } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dfb_rewrite_remove_unused", [](DataflowBlockRewrite rwt, Var unused, bool allow_undef) { rwt->RemoveUnused(unused, allow_undef); }); -}); +} void DataflowBlockRewriteNode::RemoveAllUnused() { RemoveUnusedVars remover(to_users_, fn_outputs_); @@ -326,11 +326,11 @@ void DataflowBlockRewriteNode::RemoveAllUnused() { for (const auto& unused : remover.unused_vars) to_users_.erase(unused); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dfb_rewrite_remove_all_unused", [](DataflowBlockRewrite rwt) { rwt->RemoveAllUnused(); }); -}); +} Expr RemoveAllUnused(Expr expr) { auto var_usage = CollectVarUsage(expr); @@ -349,10 +349,10 @@ Expr RemoveAllUnused(Expr expr) { return remover.VisitExpr(std::move(expr)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.remove_all_unused", RemoveAllUnused); -}); +} IRModule DataflowBlockRewriteNode::MutateIRModule(IRModule irmod) { BlockBuilder builder = BlockBuilder::Create(irmod); @@ -367,12 +367,12 @@ IRModule DataflowBlockRewriteNode::MutateIRModule(IRModule irmod) { return builder->GetContextIRModule(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.dfb_rewrite_mutate_irmodule", [](DataflowBlockRewrite rwt, IRModule irmod) { return rwt->MutateIRModule(irmod); }); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/ir/block_builder.cc b/src/relax/ir/block_builder.cc index c3ead8cb4676..00be02270b89 100644 --- a/src/relax/ir/block_builder.cc +++ b/src/relax/ir/block_builder.cc @@ -1053,7 +1053,7 @@ BlockBuilder BlockBuilder::Create(ffi::Optional mod, // User facing function registration. //--------------------------------------- -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.BlockBuilderCreate", @@ -1090,6 +1090,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_method("relax.BlockBuilderLookupBinding", &BlockBuilderNode::LookupBinding) .def_method("relax.BlockBuilderBeginScope", &BlockBuilderNode::BeginScope) .def_method("relax.BlockBuilderEndScope", &BlockBuilderNode::EndScope); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/ir/dataflow_block_rewriter.cc b/src/relax/ir/dataflow_block_rewriter.cc index 27b012d8b1a7..249ec14f89dd 100644 --- a/src/relax/ir/dataflow_block_rewriter.cc +++ b/src/relax/ir/dataflow_block_rewriter.cc @@ -364,12 +364,12 @@ ffi::Optional> MatchGraph(const PatternContext& ctx, return MatchGraph(ctx, dfb->bindings, AnalyzeVar2Value(dfb)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.dpl.match_dfb", [](const PatternContext& ctx, const DataflowBlock& dfb) { return MatchGraph(ctx, dfb); }); -}); +} class PatternContextRewriterNode : public PatternMatchingRewriterNode { public: @@ -454,12 +454,12 @@ Function RewriteBindings( return Downcast(PatternContextRewriter(ctx, rewriter)(func)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.rewrite_bindings", RewriteBindings); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ PatternContextRewriterNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { PatternContextRewriterNode::RegisterReflection(); } } // namespace relax } // namespace tvm diff --git a/src/relax/ir/dataflow_expr_rewriter.cc b/src/relax/ir/dataflow_expr_rewriter.cc index a01bdddb9804..4aca923a4b80 100644 --- a/src/relax/ir/dataflow_expr_rewriter.cc +++ b/src/relax/ir/dataflow_expr_rewriter.cc @@ -192,7 +192,7 @@ void RewriteSpec::Append(RewriteSpec other) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.dpl.PatternMatchingRewriterFromPattern", @@ -213,7 +213,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ LOG(FATAL) << "Unreachable: object does not contain either variant type"; } }); -}); +} RewriteSpec ExprPatternRewriterNode::RewriteBindings(const ffi::Array& bindings) const { ffi::Map variable_rewrites; @@ -257,7 +257,7 @@ ffi::Optional ExprPatternRewriterNode::RewriteExpr( return std::nullopt; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.dpl.PatternRewriter", @@ -265,7 +265,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ffi::TypedFunction(Expr, ffi::Map)> func) { return ExprPatternRewriter(pattern, func); }); -}); +} ExprPatternRewriter::ExprPatternRewriter( DFPattern pattern, @@ -310,13 +310,13 @@ RewriteSpec OrRewriterNode::RewriteBindings(const ffi::Array& bindings) return lhs_match; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.OrRewriter", [](PatternMatchingRewriter lhs, PatternMatchingRewriter rhs) { return OrRewriter(lhs, rhs); }); -}); +} OrRewriter::OrRewriter(PatternMatchingRewriter lhs, PatternMatchingRewriter rhs) { auto node = ffi::make_object(); @@ -608,7 +608,7 @@ std::optional> TupleRewriterNode::TryMatchByBindingIndex( return rewrites; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.dpl.TupleRewriter", @@ -616,7 +616,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ffi::TypedFunction(Expr, ffi::Map)> func) { return TupleRewriter(patterns, func); }); -}); +} TupleRewriter::TupleRewriter( ffi::Array patterns, @@ -807,19 +807,19 @@ ffi::Optional> ExtractMatchedExpr( return matcher.GetMemo(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.extract_matched_expr", ExtractMatchedExpr); -}); +} bool MatchExpr(DFPattern pattern, Expr expr, ffi::Optional> bindings_opt) { return static_cast(ExtractMatchedExpr(pattern, expr, bindings_opt)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.match_expr", MatchExpr); -}); +} /*! * \brief Apply pattern matching to each expression, replacing @@ -829,7 +829,8 @@ class PatternMatchingMutator : public ExprMutator { public: using ExprMutator::VisitExpr_; - PatternMatchingMutator(const PatternMatchingRewriterNode* rewriter) : rewriter_(rewriter) {} + explicit PatternMatchingMutator(const PatternMatchingRewriterNode* rewriter) + : rewriter_(rewriter) {} ffi::Map GetNewSubroutines() const { return new_subroutines_; } @@ -1092,17 +1093,17 @@ Function RewriteCall(const DFPattern& pat, return Downcast(PatternMatchingRewriter::FromPattern(pat, rewriter)(func)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.rewrite_call", RewriteCall); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { PatternMatchingRewriterNode::RegisterReflection(); ExprPatternRewriterNode::RegisterReflection(); OrRewriterNode::RegisterReflection(); TupleRewriterNode::RegisterReflection(); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/ir/dataflow_pattern.cc b/src/relax/ir/dataflow_pattern.cc index 581752e6257f..99e7dc6dfe05 100644 --- a/src/relax/ir/dataflow_pattern.cc +++ b/src/relax/ir/dataflow_pattern.cc @@ -32,7 +32,7 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { PatternSeqNode::RegisterReflection(); ExprPatternNode::RegisterReflection(); VarPatternNode::RegisterReflection(); @@ -54,7 +54,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ AttrPatternNode::RegisterReflection(); ExternFuncPatternNode::RegisterReflection(); ConstantPatternNode::RegisterReflection(); -}); +} #define RELAX_PATTERN_PRINTER_DEF(NODE_TYPE, REPR_LAMBDA) \ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) \ @@ -68,11 +68,11 @@ ExternFuncPattern::ExternFuncPattern(ffi::String global_symbol) { n->global_symbol_ = std::move(global_symbol); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.ExternFuncPattern", [](ffi::String global_symbol) { return ExternFuncPattern(global_symbol); }); -}); +} RELAX_PATTERN_PRINTER_DEF(ExternFuncPatternNode, [](auto p, auto node) { p->stream << "ExternFuncPattern(" << node->global_symbol() << ")"; }); @@ -82,20 +82,20 @@ VarPattern::VarPattern(ffi::String name_hint) { n->name = std::move(name_hint); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.VarPattern", [](ffi::String name_hint) { return VarPattern(name_hint); }); -}); +} RELAX_PATTERN_PRINTER_DEF(VarPatternNode, [](auto p, auto node) { p->stream << "VarPattern(" << node->name_hint() << ")"; }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.DataflowVarPattern", [](ffi::String name_hint) { return DataflowVarPattern(name_hint); }); -}); +} DataflowVarPattern::DataflowVarPattern(ffi::String name_hint) { ObjectPtr n = ffi::make_object(); n->name = std::move(name_hint); @@ -110,11 +110,11 @@ GlobalVarPattern::GlobalVarPattern(ffi::String name_hint) { n->name = std::move(name_hint); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.GlobalVarPattern", [](ffi::String name_hint) { return GlobalVarPattern(name_hint); }); -}); +} RELAX_PATTERN_PRINTER_DEF(GlobalVarPatternNode, [](auto p, auto node) { p->stream << "GlobalVarPattern(" << node->name_hint() << ")"; }); @@ -124,19 +124,19 @@ ExprPattern::ExprPattern(Expr expr) { n->expr = std::move(expr); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.ExprPattern", [](Expr e) { return ExprPattern(e); }); -}); +} RELAX_PATTERN_PRINTER_DEF(ExprPatternNode, [](auto p, auto node) { p->Print(node->expr); }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.ConstantPattern", []() { auto c = ConstantPattern(ffi::make_object()); return c; }); -}); +} RELAX_PATTERN_PRINTER_DEF(ConstantPatternNode, [](auto p, auto node) { p->stream << "ConstantPattern()"; }); @@ -147,13 +147,13 @@ CallPattern::CallPattern(DFPattern op, ffi::Array args, bool varg_def n->varg_default_wildcard = varg_default_wildcard; data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.CallPattern", [](DFPattern op, ffi::Array args, bool varg_default_wildcard) { return CallPattern(op, args, varg_default_wildcard); }); -}); +} RELAX_PATTERN_PRINTER_DEF(CallPatternNode, [](auto p, auto node) { p->stream << node->op << "("; for (size_t i = 0; i < node->args.size(); ++i) { @@ -172,11 +172,11 @@ PrimArrPattern::PrimArrPattern(ffi::Array arr) { n->fields = std::move(arr); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.PrimArrPattern", [](ffi::Array arr) { return PrimArrPattern(std::move(arr)); }); -}); +} RELAX_PATTERN_PRINTER_DEF(PrimArrPatternNode, [](auto p, auto node) { p->stream << "PrimArrPattern(" << node->fields << ")"; }); @@ -187,12 +187,12 @@ FunctionPattern::FunctionPattern(ffi::Array params, DFPattern body) { n->body = std::move(body); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.dpl.FunctionPattern", [](ffi::Array params, DFPattern body) { return FunctionPattern(params, body); }); -}); +} RELAX_PATTERN_PRINTER_DEF(FunctionPatternNode, [](auto p, auto node) { p->stream << "FunctionPattern(" << node->params << ", " << node->body << ")"; }); @@ -202,11 +202,11 @@ TuplePattern::TuplePattern(tvm::ffi::Array fields) { n->fields = std::move(fields); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.TuplePattern", [](tvm::ffi::Array fields) { return TuplePattern(fields); }); -}); +} RELAX_PATTERN_PRINTER_DEF(TuplePatternNode, [](auto p, auto node) { p->stream << "TuplePattern(" << node->fields << ")"; }); @@ -216,12 +216,12 @@ UnorderedTuplePattern::UnorderedTuplePattern(tvm::ffi::Array fields) n->fields = std::move(fields); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.UnorderedTuplePattern", [](tvm::ffi::Array fields) { return UnorderedTuplePattern(fields); }); -}); +} RELAX_PATTERN_PRINTER_DEF(UnorderedTuplePatternNode, [](auto p, auto node) { p->stream << "UnorderedTuplePattern(" << node->fields << ")"; }); @@ -232,12 +232,12 @@ TupleGetItemPattern::TupleGetItemPattern(DFPattern tuple, int index) { n->index = index; data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.TupleGetItemPattern", [](DFPattern tuple, int index) { return TupleGetItemPattern(tuple, index); }); -}); +} RELAX_PATTERN_PRINTER_DEF(TupleGetItemPatternNode, [](auto p, auto node) { p->stream << "TupleGetItemPattern(" << node->tuple << ", " << node->index << ")"; }); @@ -248,11 +248,11 @@ AndPattern::AndPattern(DFPattern left, DFPattern right) { n->right = std::move(right); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.AndPattern", [](DFPattern left, DFPattern right) { return AndPattern(left, right); }); -}); +} RELAX_PATTERN_PRINTER_DEF(AndPatternNode, [](auto p, auto node) { p->stream << "AndPattern(" << node->left << " & " << node->right << ")"; }); @@ -263,11 +263,11 @@ OrPattern::OrPattern(DFPattern left, DFPattern right) { n->right = std::move(right); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.OrPattern", [](DFPattern left, DFPattern right) { return OrPattern(left, right); }); -}); +} RELAX_PATTERN_PRINTER_DEF(OrPatternNode, [](auto p, auto node) { p->stream << "OrPattern(" << node->left << " | " << node->right << ")"; }); @@ -277,19 +277,19 @@ NotPattern::NotPattern(DFPattern reject) { n->reject = std::move(reject); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.NotPattern", [](DFPattern reject) { return NotPattern(reject); }); -}); +} RELAX_PATTERN_PRINTER_DEF(NotPatternNode, [](auto p, auto node) { p->stream << "!(" << node->reject << ")"; }); WildcardPattern::WildcardPattern() { data_ = ffi::make_object(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.WildcardPattern", []() { return WildcardPattern(); }); -}); +} RELAX_PATTERN_PRINTER_DEF(WildcardPatternNode, [](auto p, auto node) { p->stream << "*"; }); StructInfoPattern::StructInfoPattern(DFPattern pattern, StructInfo struct_info) { @@ -298,13 +298,13 @@ StructInfoPattern::StructInfoPattern(DFPattern pattern, StructInfo struct_info) n->struct_info = std::move(struct_info); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.StructInfoPattern", [](DFPattern pattern, StructInfo struct_info) { return StructInfoPattern(pattern, struct_info); }); -}); +} RELAX_PATTERN_PRINTER_DEF(StructInfoPatternNode, [](auto p, auto node) { p->stream << "StructInfoPattern(" << node->pattern << " has relax StructInfo " << node->struct_info << ")"; @@ -316,12 +316,12 @@ ShapePattern::ShapePattern(DFPattern pattern, ffi::Array shape) { n->shape = std::move(shape); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.dpl.ShapePattern", [](DFPattern pattern, ffi::Array shape) { return ShapePattern(pattern, shape); }); -}); +} RELAX_PATTERN_PRINTER_DEF(ShapePatternNode, [](auto p, auto node) { p->stream << "ShapePattern(" << node->pattern << " has shape " << node->shape << ")"; }); @@ -335,11 +335,11 @@ SameShapeConstraint::SameShapeConstraint(ffi::Array args) { ctx.value().add_constraint(*this); } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.SameShapeConstraint", [](ffi::Array args) { return SameShapeConstraint(args); }); -}); +} RELAX_PATTERN_PRINTER_DEF(SameShapeConstraintNode, [](auto p, auto node) { p->stream << "SameShapeConstraint("; for (size_t i = 0; i < node->args.size(); i++) { @@ -357,12 +357,12 @@ DataTypePattern::DataTypePattern(DFPattern pattern, DataType dtype) { n->dtype = std::move(dtype); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.DataTypePattern", [](DFPattern pattern, DataType dtype) { return DataTypePattern(pattern, dtype); }); -}); +} RELAX_PATTERN_PRINTER_DEF(DataTypePatternNode, [](auto p, auto node) { p->stream << "DataTypePattern(" << node->pattern << " has dtype " << node->dtype << ")"; }); @@ -373,12 +373,12 @@ AttrPattern::AttrPattern(DFPattern pattern, DictAttrs attrs) { n->attrs = std::move(attrs); data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.AttrPattern", [](DFPattern pattern, DictAttrs attrs) { return AttrPattern(pattern, attrs); }); -}); +} RELAX_PATTERN_PRINTER_DEF(AttrPatternNode, [](auto p, auto node) { p->stream << "AttrPattern(" << node->pattern << " has attributes " << node->attrs << ")"; }); @@ -548,13 +548,13 @@ PatternSeq PatternSeq::dup() const { return ret; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.dpl.PatternSeq", [](ffi::Array patterns, bool only_used_by) { return PatternSeq(std::move(patterns), only_used_by); }); -}); +} RELAX_PATTERN_PRINTER_DEF(PatternSeqNode, [](auto p, auto node) { p->stream << "["; for (size_t i = 0; i < node->patterns.size(); ++i) { @@ -565,14 +565,14 @@ RELAX_PATTERN_PRINTER_DEF(PatternSeqNode, [](auto p, auto node) { p->stream << "]"; }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.dpl.used_by", [](PatternSeq lhs, PatternSeq rhs, int index) { return lhs.UsedBy(rhs, index); }) .def("relax.dpl.only_used_by", [](PatternSeq lhs, PatternSeq rhs, int index) { return lhs.OnlyUsedBy(rhs, index); }); -}); +} PatternSeq UsedBy(const PatternSeq& lhs, const PatternSeq& rhs, int index) { PatternSeq ret; @@ -682,7 +682,7 @@ DFPattern DFPattern::dup() const { return pattern; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.dpl.dup_pattern", [](DFPattern pattern) { return pattern.dup(); }) @@ -691,7 +691,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("relax.dpl.current_context", [] { return PatternContext::Current(); }) .def("relax.dpl.enter_context", [](const PatternContext& ctx) { ctx.EnterWithScope(); }) .def("relax.dpl.exit_context", [](const PatternContext& ctx) { ctx.ExitWithScope(); }); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/ir/emit_te.cc b/src/relax/ir/emit_te.cc index a57434567185..ee10a97aa0e7 100644 --- a/src/relax/ir/emit_te.cc +++ b/src/relax/ir/emit_te.cc @@ -36,7 +36,7 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) p->stream << "rxplaceholder(" << op->name << ", " << op << ")"; }); -TVM_FFI_STATIC_INIT_BLOCK({ RXPlaceholderOpNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { RXPlaceholderOpNode::RegisterReflection(); } te::Tensor TETensor(Expr value, ffi::Map tir_var_map, std::string name) { auto n = ffi::make_object(); @@ -73,10 +73,10 @@ te::Tensor TETensor(Expr value, ffi::Map tir_var_map, std::s return te::PlaceholderOp(n).output(0); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.TETensor", TETensor); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/ir/expr.cc b/src/relax/ir/expr.cc index b7123259456c..2c681b00bc22 100644 --- a/src/relax/ir/expr.cc +++ b/src/relax/ir/expr.cc @@ -29,7 +29,7 @@ namespace relax { using tvm::ReprPrinter; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { IdNode::RegisterReflection(); CallNode::RegisterReflection(); TupleNode::RegisterReflection(); @@ -50,7 +50,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ IfNode::RegisterReflection(); FunctionNode::RegisterReflection(); ExternFuncNode::RegisterReflection(); -}); +} Id::Id(ffi::String name_hint) { ObjectPtr n = ffi::make_object(); @@ -119,13 +119,13 @@ Call WithFields(Call call, ffi::Optional opt_op, ffi::Optional args, Attrs attrs, ffi::Array sinfo_args, Span span) { return Call(op, args, attrs, sinfo_args, span); }); -}); +} If::If(Expr cond, Expr true_branch, Expr false_branch, Span span) { ObjectPtr n = ffi::make_object(); @@ -156,12 +156,12 @@ If WithFields(If if_expr, ffi::Optional opt_cond, ffi::Optional opt_ return if_expr; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.If", [](Expr cond, Expr true_branch, Expr false_branch, Span span) { return If(cond, true_branch, false_branch, span); }); -}); +} Tuple::Tuple(tvm::ffi::Array fields, Span span) { ffi::Optional tuple_sinfo = [&]() -> ffi::Optional { @@ -183,11 +183,11 @@ Tuple::Tuple(tvm::ffi::Array fields, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.Tuple", [](tvm::ffi::Array fields, Span span) { return Tuple(fields, span); }); -}); +} Tuple WithFields(Tuple tuple, ffi::Optional> opt_fields, ffi::Optional opt_span) { @@ -247,12 +247,12 @@ TupleGetItem WithFields(TupleGetItem tuple_get_item, ffi::Optional opt_tup return tuple_get_item; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.TupleGetItem", [](Expr tuple, int index, Span span) { return TupleGetItem(tuple, index, span); }); -}); +} ShapeExpr::ShapeExpr(ffi::Array values, Span span) { ObjectPtr n = ffi::make_object(); @@ -270,12 +270,12 @@ ShapeExpr::ShapeExpr(ffi::Array values, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ShapeExpr", [](ffi::Array values, Span span) { return ShapeExpr(values, span); }); -}); +} Var::Var(Id vid, ffi::Optional struct_info_annotation, Span span) { ObjectPtr n = ffi::make_object(); @@ -304,14 +304,14 @@ VarNode* Var::CopyOnWrite() { return static_cast(data_.get()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.Var", [](ffi::String name_hint, ffi::Optional struct_info_annotation, Span span) { return Var(name_hint, struct_info_annotation, span); }) .def("relax.VarFromId", [](Id vid, ffi::Optional struct_info_annotation, Span span) { return Var(vid, struct_info_annotation, span); }); -}); +} DataflowVar::DataflowVar(Id vid, ffi::Optional struct_info_annotation, Span span) { ObjectPtr n = ffi::make_object(); @@ -322,7 +322,7 @@ DataflowVar::DataflowVar(Id vid, ffi::Optional struct_info_annotatio data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.DataflowVar", @@ -333,7 +333,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ [](Id vid, ffi::Optional struct_info_annotation, Span span) { return DataflowVar(vid, struct_info_annotation, span); }); -}); +} Constant::Constant(runtime::Tensor data, ffi::Optional struct_info_annotation, Span span) { @@ -357,13 +357,13 @@ Constant::Constant(runtime::Tensor data, ffi::Optional struct_info_a data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.Constant", [](runtime::Tensor data, ffi::Optional struct_info_annotation = std::nullopt, Span span = Span()) { return Constant(data, struct_info_annotation, span); }); -}); +} PrimValue::PrimValue(PrimExpr value, Span span) { ObjectPtr n = ffi::make_object(); @@ -377,11 +377,11 @@ PrimValue PrimValue::Int64(int64_t value, Span span) { return PrimValue(IntImm(DataType::Int(64), value), span); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.PrimValue", [](PrimExpr value, Span span) { return PrimValue(value, span); }); -}); +} StringImm::StringImm(ffi::String value, Span span) { ObjectPtr n = ffi::make_object(); @@ -391,11 +391,11 @@ StringImm::StringImm(ffi::String value, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.StringImm", [](ffi::String value, Span span) { return StringImm(value, span); }); -}); +} DataTypeImm::DataTypeImm(DataType value, Span span) { ObjectPtr n = ffi::make_object(); @@ -405,11 +405,11 @@ DataTypeImm::DataTypeImm(DataType value, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.DataTypeImm", [](DataType value, Span span) { return DataTypeImm(value, span); }); -}); +} MatchCast::MatchCast(Var var, Expr value, StructInfo struct_info, Span span) { ObjectPtr n = ffi::make_object(); @@ -421,13 +421,13 @@ MatchCast::MatchCast(Var var, Expr value, StructInfo struct_info, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.MatchCast", [](Var var, Expr value, StructInfo struct_info, Span span) { return MatchCast(var, value, struct_info, span); }); -}); +} VarBinding::VarBinding(Var var, Expr value, Span span) { ObjectPtr n = ffi::make_object(); @@ -437,12 +437,12 @@ VarBinding::VarBinding(Var var, Expr value, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.VarBinding", [](Var var, Expr value, Span span) { return VarBinding(var, value, span); }); -}); +} bool VarBindingNode::SEqual(const VarBindingNode* other, ffi::TypedFunction equal) const { @@ -498,12 +498,12 @@ BindingBlockNode* BindingBlock::CopyOnWrite() { return static_cast(data_.get()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.BindingBlock", [](ffi::Array bindings, Span span) { return BindingBlock(bindings, span); }); -}); +} DataflowBlock::DataflowBlock(ffi::Array bindings, Span span) { ObjectPtr n = ffi::make_object(); @@ -512,12 +512,12 @@ DataflowBlock::DataflowBlock(ffi::Array bindings, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.DataflowBlock", [](ffi::Array bindings, Span span) { return DataflowBlock(bindings, span); }); -}); +} SeqExpr::SeqExpr(Expr body) { if (auto seq = body.as()) { @@ -535,12 +535,12 @@ SeqExpr::SeqExpr(ffi::Array blocks, Expr body, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.SeqExpr", [](ffi::Array blocks, Expr body, Span span) { return SeqExpr(blocks, body, span); }); -}); +} Function::Function(ffi::Array params, Expr body, ffi::Optional ret_struct_info, bool is_pure, DictAttrs attrs, Span span) { @@ -610,14 +610,14 @@ Function::Function(ffi::Array params, Expr body, ffi::Optional data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.Function", [](ffi::Array params, Expr body, ffi::Optional ret_struct_info, bool is_pure, DictAttrs attrs, Span span) { return Function(params, body, ret_struct_info, is_pure, attrs, span); }); -}); +} Function Function::CreateEmpty(ffi::Array params, StructInfo ret_struct_info, bool is_pure, DictAttrs attrs, Span span) { @@ -650,18 +650,18 @@ Function Function::CreateEmpty(ffi::Array params, StructInfo ret_struct_inf return Function(std::move(n)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.FunctionCreateEmpty", [](ffi::Array params, StructInfo ret_struct_info, bool is_pure, DictAttrs attrs, Span span) { return Function::CreateEmpty(params, ret_struct_info, is_pure, attrs, span); }); -}); +} // Special opaque derivation function for ExternFunc // Take look at sinfo_args to figure out the return StructInfo. -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tvm.relax.struct_info.infer_by_sinfo_args", [](const Call& call, const BlockBuilder& ctx) -> StructInfo { @@ -675,7 +675,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return TupleStructInfo(call->sinfo_args); } }); -}); +} // Get the derive function. FuncStructInfo GetExternFuncStructInfo() { @@ -700,7 +700,7 @@ ExternFunc::ExternFunc(ffi::String global_symbol, StructInfo struct_info, Span s data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ExternFunc", [](ffi::String global_symbol, ffi::Optional struct_info, Span span) { @@ -710,7 +710,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return ExternFunc(global_symbol, span); } }); -}); +} Expr GetShapeOf(const Expr& expr) { // default case, to be normalized. @@ -727,7 +727,7 @@ Expr GetShapeOf(const Expr& expr) { return call_shape_of; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.GetShapeOf", [](const Expr& expr) { return GetShapeOf(expr); }) @@ -751,7 +751,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } return std::nullopt; }); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/ir/expr_functor.cc b/src/relax/ir/expr_functor.cc index 9ddf0f274aff..6ebc56feebe2 100644 --- a/src/relax/ir/expr_functor.cc +++ b/src/relax/ir/expr_functor.cc @@ -327,12 +327,12 @@ void PostOrderVisit(const Expr& e, std::function fvisit) { ExprApplyVisit(fvisit).VisitExpr(e); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.analysis.post_order_visit", [](Expr expr, ffi::Function f) { PostOrderVisit(expr, [f](const Expr& n) { f(n); }); }); -}); +} // ================== // ExprMutatorBase diff --git a/src/relax/ir/py_expr_functor.cc b/src/relax/ir/py_expr_functor.cc index 367f4fef0ad9..73f41f185d29 100644 --- a/src/relax/ir/py_expr_functor.cc +++ b/src/relax/ir/py_expr_functor.cc @@ -552,7 +552,7 @@ class PyExprMutator : public ObjectRef { TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(PyExprMutator, ObjectRef, PyExprMutatorNode); }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.MakePyExprVisitor", PyExprVisitor::MakePyExprVisitor) @@ -660,12 +660,12 @@ TVM_FFI_STATIC_INIT_BLOCK({ [](PyExprMutator mutator, Id id, Var var) { return mutator->var_remap_[id] = var; }) .def("relax.PyExprMutatorGetVarRemap", [](PyExprMutator mutator, Id id) { return mutator->var_remap_[id]; }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { PyExprVisitorNode::RegisterReflection(); PyExprMutatorNode::RegisterReflection(); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/ir/struct_info.cc b/src/relax/ir/struct_info.cc index 945c2e69ac89..22ed4e9ea382 100644 --- a/src/relax/ir/struct_info.cc +++ b/src/relax/ir/struct_info.cc @@ -30,7 +30,7 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { StructInfoNode::RegisterReflection(); ObjectStructInfoNode::RegisterReflection(); PrimStructInfoNode::RegisterReflection(); @@ -38,7 +38,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ TensorStructInfoNode::RegisterReflection(); TupleStructInfoNode::RegisterReflection(); FuncStructInfoNode::RegisterReflection(); -}); +} ObjectStructInfo::ObjectStructInfo(Span span) { ObjectPtr n = ffi::make_object(); @@ -46,10 +46,10 @@ ObjectStructInfo::ObjectStructInfo(Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ObjectStructInfo", [](Span span) { return ObjectStructInfo(span); }); -}); +} // Prim PrimStructInfo::PrimStructInfo(PrimExpr value, Span span) { @@ -68,14 +68,14 @@ PrimStructInfo::PrimStructInfo(DataType dtype, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.PrimStructInfoFromDtype", [](DataType dtype, Span span) { return PrimStructInfo(dtype, span); }) .def("relax.PrimStructInfoFromValue", [](PrimExpr value, Span span) { return PrimStructInfo(value, span); }); -}); +} // Shape ShapeStructInfo::ShapeStructInfo(ffi::Array values, Span span) { @@ -101,7 +101,7 @@ ShapeStructInfo::ShapeStructInfo(int ndim, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.ShapeStructInfo", [](ffi::Optional> values, int ndim, Span span) { @@ -112,7 +112,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return ShapeStructInfo(ndim, span); } }); -}); +} // Tensor TensorStructInfo::TensorStructInfo(Expr shape, DataType dtype, ffi::Optional vdevice, @@ -144,7 +144,7 @@ TensorStructInfo::TensorStructInfo(DataType dtype, int ndim, ffi::Optional shape, ffi::Optional dtype, @@ -156,7 +156,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return TensorStructInfo(dtype.value_or(DataType::Void()), ndim, vdevice, span); } }); -}); +} // Tuple TupleStructInfo::TupleStructInfo(ffi::Array fields, Span span) { @@ -166,12 +166,12 @@ TupleStructInfo::TupleStructInfo(ffi::Array fields, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.TupleStructInfo", [](ffi::Array fields, Span span) { return TupleStructInfo(fields, span); }); -}); +} // Func FuncStructInfo::FuncStructInfo(ffi::Array params, StructInfo ret, bool purity, @@ -202,7 +202,7 @@ FuncStructInfo FuncStructInfo::OpaqueFunc(StructInfo ret, bool purity, Span span return FuncStructInfo(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.FuncStructInfo", @@ -219,7 +219,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return FuncStructInfo::OpaqueFunc(ret.value_or(ObjectStructInfo()), purity, span); } }); -}); +} // Helper functions void UpdateStructInfo(Expr expr, StructInfo struct_info) { @@ -232,13 +232,13 @@ void UpdateStructInfo(Expr expr, StructInfo struct_info) { expr->struct_info_ = struct_info; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.UpdateStructInfo", [](Expr expr, StructInfo struct_info) { UpdateStructInfo(expr, struct_info); }) .def("ir.ExprStructInfo", [](Expr expr) { return GetStructInfo(expr); }); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/ir/tir_pattern.cc b/src/relax/ir/tir_pattern.cc index b5bd9df27777..d579aea632bc 100644 --- a/src/relax/ir/tir_pattern.cc +++ b/src/relax/ir/tir_pattern.cc @@ -22,7 +22,7 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ MatchResultNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { MatchResultNode::RegisterReflection(); } MatchResult::MatchResult(TIRPattern pattern, ffi::Array symbol_values, ffi::Array matched_buffers) { diff --git a/src/relax/ir/transform.cc b/src/relax/ir/transform.cc index e88e33704086..39c754361360 100644 --- a/src/relax/ir/transform.cc +++ b/src/relax/ir/transform.cc @@ -164,7 +164,7 @@ Pass CreateFunctionPass(std::function return FunctionPass(std::move(pass_func), pass_info); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.transform.MakeFunctionPass", @@ -175,7 +175,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ }; return FunctionPass(wrapped_pass_func, pass_info); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { @@ -386,7 +386,7 @@ Pass CreateDataflowBlockPass( return DataflowBlockPass(std::move(pass_func), pass_info); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.transform.MakeDataflowBlockPass", @@ -398,7 +398,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ }; return DataflowBlockPass(wrapped_pass_func, pass_info); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { @@ -408,10 +408,10 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) << info->opt_level; }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { FunctionPassNode::RegisterReflection(); DataflowBlockPassNode::RegisterReflection(); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/ir/type.cc b/src/relax/ir/type.cc index 9288801ab6dd..faa0814f4c9d 100644 --- a/src/relax/ir/type.cc +++ b/src/relax/ir/type.cc @@ -28,12 +28,12 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { ShapeTypeNode::RegisterReflection(); TensorTypeNode::RegisterReflection(); ObjectTypeNode::RegisterReflection(); PackedFuncTypeNode::RegisterReflection(); -}); +} ShapeType::ShapeType(int ndim, Span span) { ObjectPtr n = ffi::make_object(); @@ -42,11 +42,11 @@ ShapeType::ShapeType(int ndim, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ShapeType", [](int ndim, Span span) { return ShapeType(ndim, span); }); -}); +} ObjectType::ObjectType(Span span) { ObjectPtr n = ffi::make_object(); @@ -54,10 +54,10 @@ ObjectType::ObjectType(Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ObjectType", [](Span span) { return ObjectType(span); }); -}); +} TensorType::TensorType(int ndim, DataType dtype, Span span) { ObjectPtr n = ffi::make_object(); @@ -75,12 +75,12 @@ TensorType TensorType::CreateUnknownNDim(DataType dtype, Span span) { return TensorType(std::move(n)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.TensorType", [](int ndim, DataType dtype, Span span) { return TensorType(ndim, dtype, span); }); -}); +} PackedFuncType::PackedFuncType(Span span) { ObjectPtr n = ffi::make_object(); @@ -88,10 +88,10 @@ PackedFuncType::PackedFuncType(Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.PackedFuncType", [](Span span) { return PackedFuncType(span); }); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/op/ccl/ccl.cc b/src/relax/op/ccl/ccl.cc index 9f48f72a3fec..29036f42f846 100644 --- a/src/relax/op/ccl/ccl.cc +++ b/src/relax/op/ccl/ccl.cc @@ -28,11 +28,11 @@ namespace relax { /* relax.ccl.allreduce */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { AllReduceAttrs::RegisterReflection(); AllGatherAttrs::RegisterReflection(); ScatterCollectiveAttrs::RegisterReflection(); -}); +} Expr allreduce(Expr x, ffi::String op_type, bool in_group) { ObjectPtr attrs = ffi::make_object(); @@ -43,10 +43,10 @@ Expr allreduce(Expr x, ffi::String op_type, bool in_group) { return Call(op, {std::move(x)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.ccl.allreduce", allreduce); -}); +} StructInfo InferStructInfoAllReduce(const Call& call, const BlockBuilder& ctx) { TensorStructInfo input_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -72,10 +72,10 @@ Expr allgather(Expr x, int num_workers, bool in_group) { return Call(op, {std::move(x)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.ccl.allgather", allgather); -}); +} StructInfo InferStructInfoAllGather(const Call& call, const BlockBuilder& ctx) { TensorStructInfo input_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -106,10 +106,10 @@ Expr broadcast_from_worker0(Expr x) { return Call(op, {std::move(x)}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.ccl.broadcast_from_worker0", broadcast_from_worker0); -}); +} StructInfo InferStructInfoBroadcastFromZero(const Call& call, const BlockBuilder& ctx) { TensorStructInfo input_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -134,10 +134,10 @@ Expr scatter_from_worker0(Expr data, int num_workers, int axis) { return Call(op, {std::move(data)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.ccl.scatter_from_worker0", scatter_from_worker0); -}); +} StructInfo InferStructInfoScatter(const Call& call, const BlockBuilder& ctx) { TensorStructInfo input_sinfo = GetUnaryInputTensorStructInfo(call, ctx); diff --git a/src/relax/op/distributed/distributed.cc b/src/relax/op/distributed/distributed.cc index 87118074c95f..636891366194 100644 --- a/src/relax/op/distributed/distributed.cc +++ b/src/relax/op/distributed/distributed.cc @@ -37,7 +37,7 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ DistributionAttrs::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { DistributionAttrs::RegisterReflection(); } /* relax.dist.annotate_sharding */ @@ -51,10 +51,10 @@ Expr annotate_sharding(Expr input, distributed::DeviceMesh device_mesh, return Call(op, {std::move(input)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.dist.annotate_sharding", annotate_sharding); -}); +} StructInfo InferStructInfoAnnotateSharding(const Call& call, const BlockBuilder& ctx) { return GetStructInfo(call->args[0]); @@ -79,10 +79,10 @@ Expr redistribute(Expr input, distributed::DeviceMesh device_mesh, return Call(op, {std::move(input)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.dist.redistribute", redistribute); -}); +} StructInfo InferDistStructInfoRedistribute(const Call& call, const BlockBuilder& ctx) { const auto* attrs = call->attrs.as(); @@ -148,10 +148,10 @@ Expr MakeCallTIRLocalView(Expr func, Tuple args, return call; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.dist.call_tir_local_view", MakeCallTIRLocalView); -}); +} StructInfo InferStructInfoRtoS(const Call& call, const BlockBuilder& ctx) { TensorStructInfo input_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -220,11 +220,11 @@ Expr redistribute_replica_to_shard(Expr input, int num_workers, int axis) { return Call(op, {std::move(input)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.dist.redistribute_replica_to_shard", redistribute_replica_to_shard); -}); +} TVM_REGISTER_OP("relax.dist.redistribute_replica_to_shard") .set_num_inputs(1) diff --git a/src/relax/op/image/resize.cc b/src/relax/op/image/resize.cc index e0aba16d8311..8b7b8dd2a5f9 100644 --- a/src/relax/op/image/resize.cc +++ b/src/relax/op/image/resize.cc @@ -31,7 +31,7 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ Resize2DAttrs::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { Resize2DAttrs::RegisterReflection(); } /* relax.resize2d */ @@ -54,10 +54,10 @@ Expr resize2d(Expr data, Expr size, ffi::Array roi, ffi::String layout return Call(op, {std::move(data), std::move(size)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.image.resize2d", resize2d); -}); +} StructInfo InferStructInfoResize2D(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 1 && call->args.size() != 2) { diff --git a/src/relax/op/memory/view.cc b/src/relax/op/memory/view.cc index 5c7fc47057d7..04a845bd816d 100644 --- a/src/relax/op/memory/view.cc +++ b/src/relax/op/memory/view.cc @@ -43,10 +43,10 @@ Expr view(Expr x, ffi::Optional shape, ffi::Optional dtype, }); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.memory.view", view); -}); +} StructInfo InferStructInfoView(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 4) { @@ -296,10 +296,10 @@ StructInfo InferStructInfoView(const Call& call, const BlockBuilder& ctx) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tvm.relax.struct_info.infer_view_sinfo", InferStructInfoView); -}); +} Expr LowerBuiltinView(const BlockBuilder& bb, const Call& call) { Expr data = call->args[0]; @@ -370,10 +370,10 @@ Expr ensure_zero_offset(const Expr& x) { return Call(op, {x}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.memory.ensure_zero_offset", ensure_zero_offset); -}); +} StructInfo InferStructInfoEnsureZeroOffset(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 1) { diff --git a/src/relax/op/nn/attention.cc b/src/relax/op/nn/attention.cc index 288214cebb6b..bf384e863443 100644 --- a/src/relax/op/nn/attention.cc +++ b/src/relax/op/nn/attention.cc @@ -58,12 +58,12 @@ Expr attention_var_len(Expr query, Expr key, Expr value, Expr seqstart_q, Expr s {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.op.nn.attention", attention) .def("relax.op.nn.attention_var_len", attention_var_len); -}); +} StructInfo InferStructInfoAttention(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -186,7 +186,7 @@ TVM_REGISTER_OP("relax.nn.attention_var_len") .set_attr("FInferStructInfo", InferStructInfoAttention) .set_attr("FPurity", Bool(true)); -TVM_FFI_STATIC_INIT_BLOCK({ AttentionAttrs::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { AttentionAttrs::RegisterReflection(); } } // namespace relax } // namespace tvm diff --git a/src/relax/op/nn/convolution.cc b/src/relax/op/nn/convolution.cc index b8cf8b95ee46..4f3c3382536c 100644 --- a/src/relax/op/nn/convolution.cc +++ b/src/relax/op/nn/convolution.cc @@ -31,13 +31,13 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { Conv1DAttrs::RegisterReflection(); Conv2DAttrs::RegisterReflection(); Conv3DAttrs::RegisterReflection(); Conv1DTransposeAttrs::RegisterReflection(); Conv2DTransposeAttrs::RegisterReflection(); -}); +} /* relax.nn.conv1d */ @@ -61,10 +61,10 @@ Expr conv1d(Expr data, Expr weight, ffi::Array strides, ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -228,10 +228,10 @@ Expr conv2d(Expr data, Expr weight, ffi::Array strides, ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -433,10 +433,10 @@ Expr conv3d(Expr data, Expr weight, ffi::Array strides, ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -616,10 +616,10 @@ Expr conv1d_transpose(Expr data, Expr weight, ffi::Array strides, return Call(op, {data, weight}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.conv1d_transpose", conv1d_transpose); -}); +} StructInfo InferStructInfoConv1dTranspose(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -757,10 +757,10 @@ Expr conv2d_transpose(Expr data, Expr weight, ffi::Array strides, return Call(op, {data, weight}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.conv2d_transpose", conv2d_transpose); -}); +} StructInfo InferStructInfoConv2dTranspose(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); diff --git a/src/relax/op/nn/nn.cc b/src/relax/op/nn/nn.cc index 7a2bb0e607d2..f4b9fe400bee 100644 --- a/src/relax/op/nn/nn.cc +++ b/src/relax/op/nn/nn.cc @@ -27,7 +27,7 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { SoftmaxAttrs::RegisterReflection(); LeakyReluAttrs::RegisterReflection(); SoftplusAttrs::RegisterReflection(); @@ -41,7 +41,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ DropoutAttrs::RegisterReflection(); PadAttrs::RegisterReflection(); PixelShuffleAttrs::RegisterReflection(); -}); +} /* relax.nn.relu */ RELAX_REGISTER_UNARY_NN_OP_AND_IMPL(relu, "nn.relu", /*require_float_dtype=*/false); @@ -67,10 +67,10 @@ Expr leakyrelu(Expr data, double alpha) { return Call(op, {data}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.leakyrelu", leakyrelu); -}); +} TVM_REGISTER_OP("relax.nn.leakyrelu") .set_num_inputs(1) @@ -90,10 +90,10 @@ Expr softplus(Expr data, double beta, double threshold) { return Call(op, {data}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.softplus", softplus); -}); +} TVM_REGISTER_OP("relax.nn.softplus") .set_num_inputs(1) @@ -112,10 +112,10 @@ Expr prelu(Expr data, Expr alpha, int axis = 1) { return Call(op, {data, alpha}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.prelu", prelu); -}); +} StructInfo InferStructInfoPRelu(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -176,10 +176,10 @@ Expr softmax(Expr data, int axis) { return Call(op, {data}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.softmax", softmax); -}); +} StructInfo InferStructInfoSoftmax(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -237,10 +237,10 @@ Expr log_softmax(Expr data, int axis) { return Call(op, {data}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.log_softmax", log_softmax); -}); +} TVM_REGISTER_OP("relax.nn.log_softmax") .set_num_inputs(1) @@ -260,10 +260,10 @@ Expr pad(Expr data, ffi::Array pad_width, ffi::String pad_mode, double return Call(op, {data}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.pad", pad); -}); +} StructInfo InferStructInfoPad(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -305,10 +305,10 @@ Expr pixel_shuffle(Expr data, int upscale_factor) { return Call(op, {data}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.pixel_shuffle", pixel_shuffle); -}); +} StructInfo InferStructInfoPixelShuffle(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -457,10 +457,10 @@ Expr batch_norm(Expr data, Expr gamma, Expr beta, Expr moving_mean, Expr moving_ std::move(moving_var)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.batch_norm", batch_norm); -}); +} StructInfo InferStructInfoBatchNorm(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -536,10 +536,10 @@ Expr layer_norm(Expr data, Expr gamma, Expr beta, ffi::Array axes, doub return Call(op, {std::move(data), std::move(gamma), std::move(beta)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.layer_norm", layer_norm); -}); +} StructInfo InferStructInfoLayerNorm(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -606,10 +606,10 @@ Expr group_norm(Expr data, Expr gamma, Expr beta, int num_groups, int channel_ax return Call(op, {std::move(data), std::move(gamma), std::move(beta)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.group_norm", group_norm); -}); +} StructInfo InferStructInfoGroupNorm(const Call& call, const BlockBuilder& ctx) { Op op = Downcast(call->op); @@ -719,10 +719,10 @@ Expr instance_norm(Expr data, Expr gamma, Expr beta, int channel_axis, ffi::Arra return Call(op, {std::move(data), std::move(gamma), std::move(beta)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.instance_norm", instance_norm); -}); +} StructInfo InferStructInfoInstanceNorm(const Call& call, const BlockBuilder& ctx) { Op op = Downcast(call->op); @@ -817,10 +817,10 @@ Expr rms_norm(Expr data, Expr weight, ffi::Array axes, double epsilon) return Call(op, {std::move(data), std::move(weight)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.rms_norm", rms_norm); -}); +} StructInfo InferStructInfoRMSNorm(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -877,10 +877,10 @@ Expr dropout(Expr data, double rate) { return Call(op, {std::move(data)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.dropout", dropout); -}); +} StructInfo InferStructInfoDropout(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -948,10 +948,10 @@ Expr cross_entropy_with_logits(Expr predictions, Expr labels) { return Call(op, {std::move(predictions), std::move(labels)}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.cross_entropy_with_logits", cross_entropy_with_logits); -}); +} TVM_REGISTER_OP("relax.nn.cross_entropy_with_logits") .set_num_inputs(2) @@ -983,10 +983,10 @@ Expr nll_loss(Expr predictions, Expr targets, ffi::Optional weights, ffi:: } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.nll_loss", nll_loss); -}); +} StructInfo InferStructInfoNLLLoss(const Call& call, const BlockBuilder& ctx) { if (call->args.size() < 2 || call->args.size() > 3) { diff --git a/src/relax/op/nn/nn.h b/src/relax/op/nn/nn.h index c2f4aad2f8a4..989dfbb3f613 100644 --- a/src/relax/op/nn/nn.h +++ b/src/relax/op/nn/nn.h @@ -41,9 +41,9 @@ namespace relax { * \param RequireFloatDtype A boolean indicating if the input is required to have float dtype. */ #define RELAX_REGISTER_UNARY_NN_OP_AND_IMPL(OpName, OpRegName, RequireFloatDtype) \ + RELAX_UNARY_OP_INTERFACE(OpName, OpRegName) \ RELAX_REGISTER_UNARY_OP(OpRegName).set_attr( \ - "FInferStructInfo", InferStructInfoUnaryArith); \ - RELAX_UNARY_OP_INTERFACE(OpName, OpRegName); + "FInferStructInfo", InferStructInfoUnaryArith) /*! \brief Rectified linear unit. */ Expr relu(Expr data); diff --git a/src/relax/op/nn/pooling.cc b/src/relax/op/nn/pooling.cc index fe134a76bb1a..584135520000 100644 --- a/src/relax/op/nn/pooling.cc +++ b/src/relax/op/nn/pooling.cc @@ -27,14 +27,14 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { Pool1DAttrs::RegisterReflection(); Pool2DAttrs::RegisterReflection(); Pool3DAttrs::RegisterReflection(); AdaptivePool1DAttrs::RegisterReflection(); AdaptivePool2DAttrs::RegisterReflection(); AdaptivePool3DAttrs::RegisterReflection(); -}); +} /* relax.nn.max_pool1d */ @@ -73,10 +73,10 @@ Expr max_pool1d(Expr data, ffi::Array pool_size, ffi::Array stri count_include_pad, layout, out_layout); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.max_pool1d", max_pool1d); -}); +} StructInfo InferStructInfoPool1D(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -189,10 +189,10 @@ Expr max_pool2d(Expr data, ffi::Array pool_size, ffi::Array stri count_include_pad, layout, out_layout); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.max_pool2d", max_pool2d); -}); +} StructInfo InferStructInfoPool2D(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -332,10 +332,10 @@ Expr max_pool3d(Expr data, ffi::Array pool_size, ffi::Array stri count_include_pad, layout, out_layout); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.max_pool3d", max_pool3d); -}); +} StructInfo InferStructInfoPool3D(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -422,10 +422,10 @@ Expr avg_pool1d(Expr data, ffi::Array pool_size, ffi::Array stri count_include_pad, layout, out_layout); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.avg_pool1d", avg_pool1d); -}); +} TVM_REGISTER_OP("relax.nn.avg_pool1d") .set_num_inputs(1) @@ -444,10 +444,10 @@ Expr avg_pool2d(Expr data, ffi::Array pool_size, ffi::Array stri count_include_pad, layout, out_layout); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.avg_pool2d", avg_pool2d); -}); +} TVM_REGISTER_OP("relax.nn.avg_pool2d") .set_num_inputs(1) @@ -466,10 +466,10 @@ Expr avg_pool3d(Expr data, ffi::Array pool_size, ffi::Array stri count_include_pad, layout, out_layout); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.avg_pool3d", avg_pool3d); -}); +} TVM_REGISTER_OP("relax.nn.avg_pool3d") .set_num_inputs(1) @@ -499,10 +499,10 @@ Expr adaptive_avg_pool1d(Expr data, ffi::Optional> output_siz return Call(op, {std::move(data)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.adaptive_avg_pool1d", adaptive_avg_pool1d); -}); +} StructInfo InferStructInfoAdaptiveAvgPool1D(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -584,10 +584,10 @@ Expr adaptive_avg_pool2d(Expr data, ffi::Optional> output_siz return Call(op, {std::move(data)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.adaptive_avg_pool2d", adaptive_avg_pool2d); -}); +} StructInfo InferStructInfoAdaptiveAvgPool2D(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -686,10 +686,10 @@ Expr adaptive_avg_pool3d(Expr data, ffi::Optional> output_siz return Call(op, {std::move(data)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nn.adaptive_avg_pool3d", adaptive_avg_pool3d); -}); +} StructInfo InferStructInfoAdaptiveAvgPool3D(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); diff --git a/src/relax/op/op.cc b/src/relax/op/op.cc index ddf6a056f00a..e15d87472316 100644 --- a/src/relax/op/op.cc +++ b/src/relax/op/op.cc @@ -28,13 +28,13 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { CallTIRWithGradAttrs::RegisterReflection(); CallTIRInplaceAttrs::RegisterReflection(); CallInplacePackedAttrs::RegisterReflection(); ToVDeviceAttrs::RegisterReflection(); HintOnDeviceAttrs::RegisterReflection(); -}); +} bool EqualConstInt(const PrimExpr& lhs, int64_t value) { if (const int64_t* pvalue = tir::as_const_int(lhs)) { @@ -128,10 +128,10 @@ Expr MakeCallPurePacked(const Expr& callee, ffi::Array args, const Attrs& return Call(op, call_args, attrs, sinfo_args); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.call_pure_packed", MakeCallPurePacked); -}); +} // call_inplace_packed @@ -248,10 +248,10 @@ Expr MakeCallInplacePacked(Expr func, ffi::Array args, ffi::Array return Call(op, call_args, Attrs(attrs), sinfo_args); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.call_inplace_packed", MakeCallInplacePacked); -}); +} // call_tir @@ -613,10 +613,10 @@ Expr MakeCallTIR(Expr func, Tuple args, ffi::Array out_sinfo_l return call; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.call_tir", MakeCallTIR); -}); +} // call_tir_with_grad @@ -666,10 +666,10 @@ Expr MakeCallTIRWithGrad(Expr func, Tuple args, ffi::Array out return call; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.call_tir_with_grad", MakeCallTIRWithGrad); -}); +} // call_tir_inplace @@ -809,10 +809,10 @@ Expr MakeCallTIRInplace(Expr func, Tuple args, ffi::Array inplace_indic return call; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.call_tir_inplace", MakeCallTIRInplace); -}); +} // call_dps_packed @@ -853,10 +853,10 @@ Expr MakeCallDPSPacked(Expr func, Tuple args, ffi::Array out_s return Call(op, {func, args}, {}, {out_sinfo}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.call_dps_packed", MakeCallDPSPacked); -}); +} // call builtin StructInfo InferStructInfoCallBuiltinWithCtx(const Call& call, const BlockBuilder& ctx) { @@ -882,10 +882,10 @@ Expr MakeCallBuiltinWithCtx(Expr func, Tuple args, ffi::Array sinfo_ return Call(op, {func, args}, Attrs(), sinfo_args); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.call_builtin_with_ctx", MakeCallBuiltinWithCtx); -}); +} TVM_REGISTER_OP("relax.null_value") .set_num_inputs(0) @@ -897,10 +897,10 @@ Expr MakeCallNullValue() { return Call(op, {}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.null_value", MakeCallNullValue); -}); +} // print @@ -923,10 +923,10 @@ Expr MakePrint(ffi::Array vals, StringImm format) { return Call(op, params); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.print", MakePrint); -}); +} // assert_op @@ -969,10 +969,10 @@ Expr MakeAssertOp(Expr condition, ffi::Array vals, StringImm format) { return Call(op, args); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.assert_op", MakeAssertOp); -}); +} // make_closure @@ -988,10 +988,10 @@ Expr MakeClosure(Expr func, Tuple args) { return Call(op, {func, args}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.make_closure", MakeClosure); -}); +} // invoke_closure @@ -1018,10 +1018,10 @@ Expr InvokeClosure(Expr closure, Tuple args, ffi::Array sinfo_args) return Call(op, {closure, args}, {}, sinfo_args); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.invoke_closure", InvokeClosure); -}); +} // invoke_pure_closure @@ -1037,10 +1037,10 @@ Expr InvokePureClosure(Expr closure, Tuple args, ffi::Array sinfo_ar return Call(op, {closure, args}, {}, sinfo_args); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.invoke_pure_closure", InvokePureClosure); -}); +} // shape_of @@ -1055,10 +1055,10 @@ Expr MakeShapeOf(Expr expr) { return Call(op, {expr}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.shape_of", MakeShapeOf); -}); +} // tensor_to_shape @@ -1092,10 +1092,10 @@ Expr MakeTensorToShape(Expr expr) { return Call(op, {expr}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.tensor_to_shape", MakeTensorToShape); -}); +} // shape_to_tensor StructInfo ReturnShapeToTensorStructInfo(const Call& call, const BlockBuilder& ctx) { @@ -1119,10 +1119,10 @@ Expr MakeShapeToTensor(Expr expr) { return Call(op, {expr}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.shape_to_tensor", MakeShapeToTensor); -}); +} // alloc_tensor @@ -1159,10 +1159,10 @@ Expr MakeAllocTensor(Expr shape, DataTypeImm dtype, PrimValue runtime_device_ind return Call(op, {shape, dtype, runtime_device_index, storage_scope}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.builtin.alloc_tensor", MakeAllocTensor); -}); +} // memory planning alloc_storage @@ -1187,10 +1187,10 @@ Expr MakeAllocStorage(Expr size, PrimValue virtual_device_index, StringImm stora return Call(op, {size, virtual_device_index, storage_scope, dtype}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.memory.alloc_storage", MakeAllocStorage); -}); +} // memory planning alloc_tensor @@ -1221,10 +1221,10 @@ Expr MakeMemAllocTensor(Expr storage, PrimValue offset, Expr shape, DataTypeImm return Call(op, {storage, offset, shape, dtype}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.memory.alloc_tensor", MakeMemAllocTensor); -}); +} // memory planning kill_storage @@ -1240,10 +1240,10 @@ Expr MakeMemKillStorage(Expr storage) { return Call(op, {storage}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.memory.kill_storage", MakeMemKillStorage); -}); +} // memory planning kill_tensor @@ -1259,10 +1259,10 @@ Expr MakeMemKillTensor(Expr tensor) { return Call(op, {tensor}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.memory.kill_tensor", MakeMemKillTensor); -}); +} // vm alloc_storage @@ -1286,10 +1286,10 @@ Expr MakeVMAllocStorage(Expr size, PrimValue runtime_device_index, DataTypeImm d return Call(op, {size, runtime_device_index, dtype, storage_scope}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.vm.alloc_storage", MakeVMAllocStorage); -}); +} // vm alloc_tensor @@ -1327,10 +1327,10 @@ Expr MakeVMAllocTensor(Expr storage, PrimValue offset, Expr shape, DataTypeImm d return Call(op, {storage, offset, shape, dtype}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.vm.alloc_tensor", MakeVMAllocTensor); -}); +} // vm kill_object @@ -1346,10 +1346,10 @@ Expr MakeVMKillObject(Expr obj) { return Call(op, {std::move(obj)}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.vm.kill_object", MakeVMKillObject); -}); +} // vm call_tir_dyn @@ -1367,10 +1367,10 @@ Expr MakeCallTIRDyn(Expr func, Tuple args) { return Call(op, {func, args}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.vm.call_tir_dyn", MakeCallTIRDyn); -}); +} // builtin stop_lift_params StructInfo InferStructInfoStopLiftParams(const Call& call, const BlockBuilder& ctx) { @@ -1388,10 +1388,10 @@ Expr MakeStopLiftParams(Expr x) { return Call(op, {x}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.builtin.stop_lift_params", MakeStopLiftParams); -}); +} // to_vdevice @@ -1421,10 +1421,10 @@ Expr MakeToVDevice(Expr data, VDevice dst_vdev) { return Call(op, {data}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.to_vdevice", MakeToVDevice); -}); +} // hint_on_device @@ -1450,10 +1450,10 @@ Expr MakeHintOnDevice(Expr data, Device device) { return Call(op, {data}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.hint_on_device", MakeHintOnDevice); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/op/op_common.h b/src/relax/op/op_common.h index b8cc8a64efe0..adec5d3af630 100644 --- a/src/relax/op/op_common.h +++ b/src/relax/op/op_common.h @@ -176,13 +176,14 @@ std::tuple GetArgStructInfo(const Call& call, const BlockBuilder& c * be prepended with a prefix "relax.op." as the FFI identifier string for the make function, * \param OpRegName The identifier of the operator in the registry. */ -#define RELAX_UNARY_OP_INTERFACE(OpName, OpRegName) \ - Expr OpName(Expr x) { \ - static const Op& op = Op::Get("relax." OpRegName); \ - return Call(op, {std::move(x)}, Attrs(), {}); \ - } \ - TVM_FFI_STATIC_INIT_BLOCK( \ - { tvm::ffi::reflection::GlobalDef().def("relax.op." OpRegName, OpName); }) +#define RELAX_UNARY_OP_INTERFACE(OpName, OpRegName) \ + Expr OpName(Expr x) { \ + static const Op& op = Op::Get("relax." OpRegName); \ + return Call(op, {std::move(x)}, Attrs(), {}); \ + } \ + TVM_FFI_STATIC_INIT_BLOCK() { \ + tvm::ffi::reflection::GlobalDef().def("relax.op." OpRegName, OpName); \ + } /************ Utilities ************/ diff --git a/src/relax/op/tensor/binary.h b/src/relax/op/tensor/binary.h index f612ec0598a9..b5650fad2735 100644 --- a/src/relax/op/tensor/binary.h +++ b/src/relax/op/tensor/binary.h @@ -42,8 +42,9 @@ namespace relax { static const Op& op = Op::Get("relax." #OpName); \ return Call(op, {x1, x2}, Attrs(), {}); \ } \ - TVM_FFI_STATIC_INIT_BLOCK( \ - { tvm::ffi::reflection::GlobalDef().def("relax.op." #OpName, OpName); }); \ + TVM_FFI_STATIC_INIT_BLOCK() { \ + tvm::ffi::reflection::GlobalDef().def("relax.op." #OpName, OpName); \ + } \ TVM_REGISTER_OP("relax." #OpName) \ .set_num_inputs(2) \ .add_argument("x1", "Tensor", "The first input tensor.") \ diff --git a/src/relax/op/tensor/create.cc b/src/relax/op/tensor/create.cc index 8412fd2784b8..a9a0872d683a 100644 --- a/src/relax/op/tensor/create.cc +++ b/src/relax/op/tensor/create.cc @@ -35,10 +35,10 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { InitAttrs::RegisterReflection(); TriluAttrs::RegisterReflection(); -}); +} /* Initialization operators */ @@ -62,10 +62,10 @@ Expr full(ffi::Variant> shape, Expr fill_value, return Call(op, {std::move(shape_in_expr), std::move(fill_value)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.full", full); -}); +} StructInfo InferStructInfoFull(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 2) { @@ -107,10 +107,10 @@ Expr full_like(Expr x, Expr fill_value, ffi::Optional dtype) { return Call(op, {std::move(x), std::move(fill_value)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.full_like", full_like); -}); +} StructInfo InferStructInfoFullLike(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -188,10 +188,10 @@ Expr ones_like(Expr x, ffi::Optional dtype) { return Call(op, {std::move(x)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.ones", ones).def("relax.op.ones_like", ones_like); -}); +} TVM_REGISTER_OP("relax.ones") .set_attrs_type() @@ -225,10 +225,10 @@ Expr zeros_like(Expr x, ffi::Optional dtype) { return Call(op, {std::move(x)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.zeros", zeros).def("relax.op.zeros_like", zeros_like); -}); +} TVM_REGISTER_OP("relax.zeros") .set_attrs_type() @@ -260,10 +260,10 @@ Expr eye_like(Expr x, PrimValue k, ffi::Optional dtype) { return Call(op, {std::move(x), std::move(k)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.eye", eye).def("relax.op.eye_like", eye_like); -}); +} StructInfo InferStructInfoEye(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 3) { @@ -339,10 +339,10 @@ Expr arange(PrimValue start, PrimValue stop, PrimValue step, DataType dtype) { return Call(op, {std::move(start), std::move(stop), std::move(step)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.arange", arange); -}); +} StructInfo InferStructInfoArange(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 3) { @@ -396,10 +396,10 @@ Expr hamming_window(PrimValue window_size, PrimValue periodic, PrimValue alpha, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.hamming_window", hamming_window); -}); +} StructInfo InferStructInfoHammingWindow(const Call& call, const BlockBuilder& ctx) { DataType dtype = call->attrs.as()->dtype; @@ -456,12 +456,12 @@ Expr triu(Expr x, Expr k) { Expr triu(Expr x, int k) { return triu(x, relax::PrimValue::Int64(k)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.op.tril", static_cast(tril)) .def("relax.op.triu", static_cast(triu)); -}); +} StructInfo InferStructInfoTrilTriu(const Call& call, const BlockBuilder& ctx) { auto [data_sinfo, offset] = GetArgStructInfo(call, ctx); diff --git a/src/relax/op/tensor/datatype.cc b/src/relax/op/tensor/datatype.cc index da54d25e1bc7..f12be685bdbc 100644 --- a/src/relax/op/tensor/datatype.cc +++ b/src/relax/op/tensor/datatype.cc @@ -31,10 +31,10 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { AstypeAttrs::RegisterReflection(); WrapParamAttrs::RegisterReflection(); -}); +} /* relax.astype */ @@ -46,10 +46,10 @@ Expr astype(Expr x, DataType dtype) { return Call(op, {std::move(x)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.astype", astype); -}); +} StructInfo InferStructInfoAstype(const Call& call, const BlockBuilder& ctx) { TensorStructInfo sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -78,10 +78,10 @@ Expr MakeWrapParam(Expr data, DataType dtype) { return Call(op, {std::move(data)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.wrap_param", MakeWrapParam); -}); +} StructInfo InferStructInfoWrapParam(const Call& call, const BlockBuilder& ctx) { TensorStructInfo sinfo = GetUnaryInputTensorStructInfo(call, ctx); diff --git a/src/relax/op/tensor/grad.cc b/src/relax/op/tensor/grad.cc index e120a86470be..52a218b730d0 100644 --- a/src/relax/op/tensor/grad.cc +++ b/src/relax/op/tensor/grad.cc @@ -37,10 +37,10 @@ Expr no_grad(Expr input) { return Call(op, {std::move(input)}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.grad.no_grad", no_grad); -}); +} StructInfo InferStructInfoNoGrad(const Call& call, const BlockBuilder& ctx) { return GetStructInfo(call->args[0]); @@ -58,10 +58,10 @@ Expr start_checkpoint(Expr input) { return Call(op, {std::move(input)}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.grad.start_checkpoint", start_checkpoint); -}); +} StructInfo InferStructInfoStartCheckpoint(const Call& call, const BlockBuilder& ctx) { if (!call->args[0].as()) { @@ -83,10 +83,10 @@ Expr end_checkpoint(Expr input) { return Call(op, {std::move(input)}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.grad.end_checkpoint", end_checkpoint); -}); +} StructInfo InferStructInfoEndCheckpoint(const Call& call, const BlockBuilder& ctx) { if (!call->args[0].as()) { @@ -121,10 +121,10 @@ Expr nll_loss_backward(Expr output_grad, Expr predictions, Expr targets, } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.grad.nll_loss_backward", nll_loss_backward); -}); +} StructInfo InferStructInfoNLLLossBackward(const Call& call, const BlockBuilder& ctx) { return GetStructInfo(call->args[1]); @@ -158,10 +158,10 @@ Expr max_pool2d_backward(Expr output_grad, Expr data, ffi::Array pool_si return Call(op, {std::move(output_grad), std::move(data)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.grad.max_pool2d_backward", max_pool2d_backward); -}); +} StructInfo InferStructInfoMaxPool2DBackward(const Call& call, const BlockBuilder& ctx) { return GetStructInfo(call->args[1]); @@ -193,10 +193,10 @@ Expr avg_pool2d_backward(Expr output_grad, Expr data, ffi::Array pool_si return Call(op, {std::move(output_grad), std::move(data)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.grad.avg_pool2d_backward", avg_pool2d_backward); -}); +} StructInfo InferStructInfoAvgPool2DBackward(const Call& call, const BlockBuilder& ctx) { return GetStructInfo(call->args[1]); @@ -220,10 +220,10 @@ Expr take_backward(Expr output_grad, Expr x, Expr indices, ffi::Optionalargs[1]); diff --git a/src/relax/op/tensor/index.cc b/src/relax/op/tensor/index.cc index 5780cd9cce1f..29bf767f9542 100644 --- a/src/relax/op/tensor/index.cc +++ b/src/relax/op/tensor/index.cc @@ -37,10 +37,10 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { TakeAttrs::RegisterReflection(); StridedSliceAttrs::RegisterReflection(); -}); +} /* relax.take */ @@ -53,10 +53,10 @@ Expr take(Expr x, Expr indices, ffi::Optional axis, ffi::String mode) { return Call(op, {std::move(x), std::move(indices)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.take", take); -}); +} StructInfo InferStructInfoTake(const Call& call, const BlockBuilder& ctx) { CheckNumArguments(call, ctx); @@ -179,10 +179,10 @@ Expr strided_slice(Expr x, Expr axes, Expr begin, Expr end, ffi::Optional return call; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.strided_slice", strided_slice); -}); +} /* \brief Helper function to unpack a relax::Tuple * @@ -490,10 +490,10 @@ Expr dynamic_strided_slice(Expr x, // return Call(op, {std::move(x), std::move(begin), std::move(end), std::move(strides)}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.dynamic_strided_slice", dynamic_strided_slice); -}); +} StructInfo InferStructInfoDynStridedSlice(const Call& call, const BlockBuilder& ctx) { const auto* data_sinfo = GetStructInfoAs(call->args[0]); diff --git a/src/relax/op/tensor/linear_algebra.cc b/src/relax/op/tensor/linear_algebra.cc index e50ca70f60ce..06b7856dd239 100644 --- a/src/relax/op/tensor/linear_algebra.cc +++ b/src/relax/op/tensor/linear_algebra.cc @@ -34,10 +34,10 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { MatmulAttrs::RegisterReflection(); EinsumAttrs::RegisterReflection(); -}); +} /* relax.matmul */ @@ -49,10 +49,10 @@ Expr matmul(Expr x1, Expr x2, ffi::Optional out_dtype) { return Call(op, {std::move(x1), std::move(x2)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.matmul", matmul); -}); +} StructInfo InferStructInfoMatmul(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -183,10 +183,10 @@ Expr einsum(Expr operands, ffi::String subscripts) { return Call(op, {std::move(operands)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.einsum", einsum); -}); +} StructInfo InferStructInfoEinsum(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 1) { @@ -268,10 +268,10 @@ Expr outer(Expr x1, Expr x2) { return Call(op, {std::move(x1), std::move(x2)}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.outer", outer); -}); +} StructInfo InferStructInfoOuter(const Call& call, const BlockBuilder& ctx) { auto input_sinfo = GetInputTensorStructInfo(call, ctx); diff --git a/src/relax/op/tensor/manipulate.cc b/src/relax/op/tensor/manipulate.cc index 1e3844982d4b..79c0687cada5 100644 --- a/src/relax/op/tensor/manipulate.cc +++ b/src/relax/op/tensor/manipulate.cc @@ -37,7 +37,7 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { ConcatAttrs::RegisterReflection(); ExpandDimsAttrs::RegisterReflection(); LayoutTransformAttrs::RegisterReflection(); @@ -56,7 +56,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ScatterNDAttrs::RegisterReflection(); SliceScatterAttrs::RegisterReflection(); OneHotAttrs::RegisterReflection(); -}); +} /* relax.broadcast_to */ Expr broadcast_to(Expr x, Expr shape) { @@ -64,10 +64,10 @@ Expr broadcast_to(Expr x, Expr shape) { return Call(op, {std::move(x), std::move(shape)}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.broadcast_to", broadcast_to); -}); +} StructInfo InferStructInfoBroadcastTo(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 2) { @@ -149,10 +149,10 @@ Expr concat(Expr tensors, ffi::Optional axis) { return Call(op, {std::move(tensors)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.concat", concat); -}); +} ffi::Optional> CheckConcatOutputShape( const Call& call, const BlockBuilder& ctx, @@ -369,10 +369,10 @@ Expr expand_dims(Expr x, ffi::Array axis) { return Call(op, {std::move(x)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.expand_dims", expand_dims); -}); +} StructInfo InferStructInfoExpandDims(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -478,10 +478,10 @@ Expr flatten(Expr x) { return Call(op, {std::move(x)}, {}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.flatten", flatten); -}); +} StructInfo InferStructInfoFlatten(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -516,10 +516,10 @@ Expr index_tensor(Expr first, Expr tensors) { return Call(op, {std::move(first), std::move(tensors)}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.index_tensor", index_tensor); -}); +} StructInfo InferStructInfoIndexTensor(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 2) { @@ -673,10 +673,10 @@ Expr layout_transform(Expr x, tir::IndexMap index_map, ffi::Optional return Call(op, {std::move(x)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.layout_transform", layout_transform); -}); +} StructInfo InferStructInfoLayoutTransform(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -742,10 +742,10 @@ Expr permute_dims(Expr x, ffi::Optional> axes) { return Call(op, {std::move(x)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.permute_dims", permute_dims); -}); +} bool IsIdentityPermutation(const std::vector& permutation) { for (int i = 0; i < static_cast(permutation.size()); ++i) { @@ -954,10 +954,10 @@ Expr reshape(Expr x, ffi::Variant> shape) { return Call(op, {std::move(x), std::move(shape_in_expr)}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.reshape", reshape); -}); +} StructInfo InferStructInfoReshape(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 2) { @@ -1043,10 +1043,10 @@ Expr split(Expr x, ffi::Variant> indices_or_sections, return Call(op, {std::move(x)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.split", split); -}); +} StructInfo InferStructInfoSplit(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -1199,10 +1199,10 @@ Expr squeeze(Expr x, ffi::Optional> axis) { return Call(op, {std::move(x)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.squeeze", squeeze); -}); +} StructInfo InferStructInfoSqueeze(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -1403,10 +1403,10 @@ Expr stack(Expr tensors, ffi::Optional axis) { return Call(op, {std::move(tensors)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.stack", stack); -}); +} ffi::Optional> CheckStackOutputShape( const Call& call, const BlockBuilder& ctx, @@ -1612,10 +1612,10 @@ Expr collapse_sum_like(Expr data, Expr collapse_target) { return Call(op, {std::move(data), std::move(collapse_target)}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.collapse_sum_like", collapse_sum_like); -}); +} StructInfo InferStructInfoCollapseSumLike(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -1661,10 +1661,10 @@ Expr collapse_sum_to(Expr data, Expr shape) { return Call(op, {std::move(data), std::move(shape)}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.collapse_sum_to", collapse_sum_to); -}); +} StructInfo InferStructInfoCollapseSumTo(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 2) { @@ -1718,10 +1718,10 @@ Expr repeat(Expr data, int repeats, ffi::Optional axis) { return Call(op, {std::move(data)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.repeat", repeat); -}); +} StructInfo InferStructInfoRepeat(const Call& call, const BlockBuilder& ctx) { arith::Analyzer* analyzer = ctx->GetAnalyzer(); @@ -1785,10 +1785,10 @@ Expr tile(Expr data, ffi::Array repeats) { return Call(op, {std::move(data)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.tile", tile); -}); +} StructInfo InferStructInfoTile(const Call& call, const BlockBuilder& ctx) { arith::Analyzer* analyzer = ctx->GetAnalyzer(); @@ -1850,10 +1850,10 @@ Expr flip(Expr data, Integer axis) { return Call(op, {std::move(data)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.flip", flip); -}); +} StructInfo InferStructInfoFlip(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 1) { @@ -1889,10 +1889,10 @@ Expr gather_elements(Expr data, Expr indices, int axis) { return Call(op, {data, indices}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.gather_elements", gather_elements); -}); +} StructInfo InferStructInfoGatherElements(const Call& call, const BlockBuilder& ctx) { const auto* data_sinfo = GetStructInfoAs(call->args[0]); @@ -1960,10 +1960,10 @@ Expr gather_nd(Expr data, Expr indices, int batch_dims) { return Call(op, {data, indices}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.gather_nd", gather_nd); -}); +} StructInfo InferStructInfoGatherND(const Call& call, const BlockBuilder& ctx) { const auto* data_sinfo = GetStructInfoAs(call->args[0]); @@ -2056,10 +2056,10 @@ Expr index_put(Expr data, Expr indices, Expr values, bool accumulate) { return Call(op, {data, indices, values}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.index_put", index_put); -}); +} StructInfo InferStructInfoIndexPut(const Call& call, const BlockBuilder& ctx) { const auto* data_sinfo = GetStructInfoAs(call->args[0]); @@ -2181,10 +2181,10 @@ Expr meshgrid(Expr tensors, ffi::Optional indexing) { return Call(op, {std::move(tensors)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.meshgrid", meshgrid); -}); +} StructInfo InferStructInfoMeshgrid(const Call& call, const BlockBuilder& ctx) { if (call->args.size() != 1) { @@ -2287,10 +2287,10 @@ Expr scatter_elements(Expr data, Expr indices, Expr updates, int axis, ffi::Stri return Call(op, {data, indices, updates}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.scatter_elements", scatter_elements); -}); +} StructInfo InferStructInfoScatterElements(const Call& call, const BlockBuilder& ctx) { arith::Analyzer* analyzer = ctx->GetAnalyzer(); @@ -2403,10 +2403,10 @@ Expr scatter_nd(Expr data, Expr indices, Expr updates, ffi::String reduction) { return Call(op, {data, indices, updates}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.scatter_nd", scatter_nd); -}); +} StructInfo InferStructInfoScatterND(const Call& call, const BlockBuilder& ctx) { // `call->args` contains: [data, indices, updates] @@ -2540,10 +2540,10 @@ Expr slice_scatter(Expr input, Expr src, int axis, PrimValue start, PrimValue en return Call(op, {input, src, start, end, step}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.slice_scatter", slice_scatter); -}); +} StructInfo InferStructInfoSliceScatter(const Call& call, const BlockBuilder& ctx) { arith::Analyzer* analyzer = ctx->GetAnalyzer(); @@ -2707,10 +2707,10 @@ Expr one_hot(Expr indices, PrimValue on_value, PrimValue off_value, int depth, i return Call(op, {indices, on_value, off_value}, Attrs(attrs), {}); } // namespace relax -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.one_hot", one_hot); -}); +} StructInfo InferStructInfoOneHot(const Call& call, const BlockBuilder& ctx) { TensorStructInfo indices_sinfo = GetInputTensorStructInfo(call, 0, ctx); diff --git a/src/relax/op/tensor/qdq.cc b/src/relax/op/tensor/qdq.cc index 7d51020be806..406868ab4bfc 100644 --- a/src/relax/op/tensor/qdq.cc +++ b/src/relax/op/tensor/qdq.cc @@ -34,7 +34,7 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ QuantizeAttrs::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { QuantizeAttrs::RegisterReflection(); } /* relax.quantize */ @@ -46,10 +46,10 @@ Expr quantize(Expr data, Expr scale, Expr zero_point, int axis, DataType out_dty return Call(op, {std::move(data), std::move(scale), std::move(zero_point)}, Attrs(attrs)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.quantize", quantize); -}); +} StructInfo InferStructInfoQuantize(const Call& call, const BlockBuilder& ctx) { const auto* attrs = call->attrs.as(); @@ -132,10 +132,10 @@ Expr dequantize(Expr data, Expr scale, Expr zero_point, int axis, DataType out_d return Call(op, {std::move(data), std::move(scale), std::move(zero_point)}, Attrs(attrs)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.dequantize", dequantize); -}); +} StructInfo InferStructInfoDequantize(const Call& call, const BlockBuilder& ctx) { const auto* attrs = call->attrs.as(); diff --git a/src/relax/op/tensor/sampling.cc b/src/relax/op/tensor/sampling.cc index 7507ef4357c7..ca5635baa74b 100644 --- a/src/relax/op/tensor/sampling.cc +++ b/src/relax/op/tensor/sampling.cc @@ -32,7 +32,7 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ MultinomialFromUniformAttrs::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { MultinomialFromUniformAttrs::RegisterReflection(); } /* relax.multinomial_from_uniform */ @@ -45,10 +45,10 @@ Expr multinomial_from_uniform(Expr prob, Expr uniform_sample, Expr sample_indice Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.multinomial_from_uniform", multinomial_from_uniform); -}); +} StructInfo InferStructInfoMultinomialFromUniform(const Call& call, const BlockBuilder& ctx) { CheckNumArguments(call, ctx); diff --git a/src/relax/op/tensor/search.cc b/src/relax/op/tensor/search.cc index 3db995837a97..0cd221d53d1c 100644 --- a/src/relax/op/tensor/search.cc +++ b/src/relax/op/tensor/search.cc @@ -32,10 +32,10 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { ArgmaxArgminAttrs::RegisterReflection(); BucketizeAttrs::RegisterReflection(); -}); +} /* relax.bucketize */ @@ -47,10 +47,10 @@ Expr bucketize(Expr input_tensor, Expr boundaries, bool out_int32, bool right) { return Call(op, {std::move(input_tensor), std::move(boundaries)}, Attrs(attrs), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.bucketize", bucketize); -}); +} StructInfo InferStructInfoBucketize(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -93,10 +93,10 @@ Expr where(Expr condition, Expr x1, Expr x2) { return Call(op, {std::move(condition), std::move(x1), std::move(x2)}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.where", where); -}); +} StructInfo InferStructInfoWhere(const Call& call, const BlockBuilder& ctx) { ffi::Array input_sinfo = GetInputTensorStructInfo(call, ctx); @@ -255,8 +255,9 @@ StructInfo InferStructInfoArgmaxArgmin(const Call& call, const BlockBuilder& ctx static const Op& op = Op::Get("relax." #OpName); \ return Call(op, {std::move(x)}, Attrs(attrs)); \ } \ - TVM_FFI_STATIC_INIT_BLOCK( \ - { tvm::ffi::reflection::GlobalDef().def("relax.op." #OpName, OpName); }); \ + TVM_FFI_STATIC_INIT_BLOCK() { \ + tvm::ffi::reflection::GlobalDef().def("relax.op." #OpName, OpName); \ + } \ TVM_REGISTER_OP("relax." #OpName) \ .set_num_inputs(1) \ .add_argument("x", "Tensor", "The input data tensor") \ diff --git a/src/relax/op/tensor/set.cc b/src/relax/op/tensor/set.cc index eb03725f8587..d80c73b1317d 100644 --- a/src/relax/op/tensor/set.cc +++ b/src/relax/op/tensor/set.cc @@ -48,10 +48,10 @@ Expr unique(Expr x, PrimValue sorted, PrimValue return_index, PrimValue return_i return call; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.unique", unique); -}); +} StructInfo InferStructInfoUnique(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = Downcast(call->args[0]->struct_info_); @@ -149,10 +149,10 @@ Expr nonzero(Expr x) { return Call(op, {std::move(x)}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.nonzero", nonzero); -}); +} StructInfo InferStructInfoNonzero(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetInputTensorStructInfo(call, 0, ctx); diff --git a/src/relax/op/tensor/sorting.cc b/src/relax/op/tensor/sorting.cc index de28f981567f..db0bd8a8c700 100644 --- a/src/relax/op/tensor/sorting.cc +++ b/src/relax/op/tensor/sorting.cc @@ -31,11 +31,11 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { SortAttrs::RegisterReflection(); ArgsortAttrs::RegisterReflection(); TopKAttrs::RegisterReflection(); -}); +} /* relax.sort */ @@ -48,10 +48,10 @@ Expr sort(Expr data, int axis, bool descending) { return Call(op, {std::move(data)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.sort", sort); -}); +} StructInfo InferStructInfoSort(const Call& call, const BlockBuilder& ctx) { return GetUnaryInputTensorStructInfo(call, ctx); @@ -76,10 +76,10 @@ Expr argsort(Expr data, int axis, bool descending, DataType dtype) { return Call(op, {std::move(data)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.argsort", argsort); -}); +} StructInfo InferStructInfoArgsort(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -112,10 +112,10 @@ Expr topk(Expr data, int k, int axis, ffi::String ret_type, bool largest, DataTy return Call(op, {std::move(data)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.topk", topk); -}); +} StructInfo InferStructInfoTopK(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); diff --git a/src/relax/op/tensor/statistical.cc b/src/relax/op/tensor/statistical.cc index cb52a48ee848..621c23d36310 100644 --- a/src/relax/op/tensor/statistical.cc +++ b/src/relax/op/tensor/statistical.cc @@ -32,10 +32,10 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { StatisticalAttrs::RegisterReflection(); ScanopAttrs::RegisterReflection(); -}); +} StructInfo InferStructInfoStatistical(const Call& call, const BlockBuilder& ctx) { TensorStructInfo data_sinfo = GetUnaryInputTensorStructInfo(call, ctx); @@ -192,10 +192,10 @@ Expr cumprod(Expr data, ffi::Optional axis, ffi::Optional dty return Call(op, {std::move(data)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.cumprod", cumprod); -}); +} TVM_REGISTER_OP("relax.cumprod") .set_attrs_type() @@ -215,10 +215,10 @@ Expr cumsum(Expr data, ffi::Optional axis, ffi::Optional dtyp return Call(op, {std::move(data)}, Attrs{attrs}, {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.cumsum", cumsum); -}); +} TVM_REGISTER_OP("relax.cumsum") .set_attrs_type() diff --git a/src/relax/op/tensor/statistical.h b/src/relax/op/tensor/statistical.h index e100b544fb83..a80ef728683a 100644 --- a/src/relax/op/tensor/statistical.h +++ b/src/relax/op/tensor/statistical.h @@ -50,8 +50,9 @@ namespace relax { static const Op& op = Op::Get("relax." #OpName); \ return Call(op, {std::move(x)}, Attrs{attrs}, {}); \ } \ - TVM_FFI_STATIC_INIT_BLOCK( \ - { tvm::ffi::reflection::GlobalDef().def("relax.op." #OpName, OpName); }); \ + TVM_FFI_STATIC_INIT_BLOCK() { \ + tvm::ffi::reflection::GlobalDef().def("relax.op." #OpName, OpName); \ + } \ TVM_REGISTER_OP("relax." #OpName) \ .set_num_inputs(1) \ .add_argument("x", "Tensor", "The input data tensor") \ diff --git a/src/relax/op/tensor/ternary.cc b/src/relax/op/tensor/ternary.cc index db7eea4661bc..a38585cb507a 100644 --- a/src/relax/op/tensor/ternary.cc +++ b/src/relax/op/tensor/ternary.cc @@ -145,10 +145,10 @@ Expr ewise_fma(Expr x1, Expr x2, Expr x3) { return Call(op, {x1, x2, x3}, Attrs(), {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.ewise_fma", ewise_fma); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/op/tensor/unary.cc b/src/relax/op/tensor/unary.cc index ac7b995ff122..50f5ce2bf35f 100644 --- a/src/relax/op/tensor/unary.cc +++ b/src/relax/op/tensor/unary.cc @@ -87,10 +87,10 @@ Expr clip(Expr x, Expr min, Expr max) { return Call(op, {std::move(x), std::move(min), std::move(max)}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.op.clip", clip); -}); +} /***************** Check operators *****************/ diff --git a/src/relax/op/tensor/unary.h b/src/relax/op/tensor/unary.h index 6984ba6304eb..1847ba3c365a 100644 --- a/src/relax/op/tensor/unary.h +++ b/src/relax/op/tensor/unary.h @@ -38,7 +38,7 @@ namespace relax { * (Only for unary arith operators since all check operators don't require float dtype.) */ #define RELAX_REGISTER_UNARY_OP_AND_IMPL(OpName) \ - RELAX_UNARY_OP_INTERFACE(OpName, #OpName); \ + RELAX_UNARY_OP_INTERFACE(OpName, #OpName) \ RELAX_REGISTER_UNARY_OP(#OpName) #define RELAX_REGISTER_UNARY_ARITH_OP_AND_IMPL(OpName, RequireFloatDtype) \ diff --git a/src/relax/testing/transform.cc b/src/relax/testing/transform.cc index 67660f665178..c8d7078258a8 100644 --- a/src/relax/testing/transform.cc +++ b/src/relax/testing/transform.cc @@ -36,10 +36,10 @@ tvm::transform::Pass ApplyEmptyCppMutator() { "relax.testing.ApplyEmptyCppMutator", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.testing.transform.ApplyEmptyCppMutator", ApplyEmptyCppMutator); -}); +} } // namespace testing } // namespace relax diff --git a/src/relax/training/utils.cc b/src/relax/training/utils.cc index 2edb40cd2c80..26290775fe64 100644 --- a/src/relax/training/utils.cc +++ b/src/relax/training/utils.cc @@ -216,10 +216,10 @@ Pass AppendLoss(ffi::String func_name, Function loss_function, int num_backbone_ /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.training.AppendLoss", AppendLoss); -}); +} } // namespace transform diff --git a/src/relax/transform/adjust_matmul_order.cc b/src/relax/transform/adjust_matmul_order.cc index 7b8dad43b5da..98fe57e11c2a 100644 --- a/src/relax/transform/adjust_matmul_order.cc +++ b/src/relax/transform/adjust_matmul_order.cc @@ -214,10 +214,10 @@ Pass AdjustMatmulOrder() { return CreateFunctionPass(pass_func, 1, "AdjustMatmulOrder", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.AdjustMatmulOrder", AdjustMatmulOrder); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/allocate_workspace.cc b/src/relax/transform/allocate_workspace.cc index 3af7b486bae3..4e71e0c3eb43 100644 --- a/src/relax/transform/allocate_workspace.cc +++ b/src/relax/transform/allocate_workspace.cc @@ -202,10 +202,10 @@ Pass AllocateWorkspace() { return CreateModulePass(pass_func, 0, "AllocateWorkspace", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.AllocateWorkspace", AllocateWorkspace); -}); +} } // namespace transform } // namespace tvm diff --git a/src/relax/transform/alter_op_impl.cc b/src/relax/transform/alter_op_impl.cc index 492219f013a1..d6a2009bbdf7 100644 --- a/src/relax/transform/alter_op_impl.cc +++ b/src/relax/transform/alter_op_impl.cc @@ -447,10 +447,10 @@ Pass AlterOpImpl( /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.AlterOpImpl", AlterOpImpl); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/annotate_tir_op_pattern.cc b/src/relax/transform/annotate_tir_op_pattern.cc index 58f22eb47ad4..f5b1061b6708 100644 --- a/src/relax/transform/annotate_tir_op_pattern.cc +++ b/src/relax/transform/annotate_tir_op_pattern.cc @@ -48,10 +48,10 @@ Pass AnnotateTIROpPattern() { return tir::transform::CreatePrimFuncPass(pass_func, 0, "AnnotateTIROpPattern", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.AnnotateTIROpPattern", AnnotateTIROpPattern); -}); +} } // namespace transform diff --git a/src/relax/transform/attach_attr_layout_free_buffers.cc b/src/relax/transform/attach_attr_layout_free_buffers.cc index f2cc2fc842b8..064ff015eedf 100644 --- a/src/relax/transform/attach_attr_layout_free_buffers.cc +++ b/src/relax/transform/attach_attr_layout_free_buffers.cc @@ -106,10 +106,10 @@ Pass AttachAttrLayoutFreeBuffers() { return tvm::transform::Sequential({pass, DeadCodeElimination()}, "AttachAttrLayoutFreeBuffers"); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.AttachAttrLayoutFreeBuffers", AttachAttrLayoutFreeBuffers); -}); +} } // namespace transform } // namespace relax } // namespace tvm diff --git a/src/relax/transform/attach_global_symbol.cc b/src/relax/transform/attach_global_symbol.cc index 324789d3f490..0079b504989a 100644 --- a/src/relax/transform/attach_global_symbol.cc +++ b/src/relax/transform/attach_global_symbol.cc @@ -81,10 +81,10 @@ Pass AttachGlobalSymbol() { return CreateModulePass(pass_func, 0, "AttachGlobalSymbol", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.AttachGlobalSymbol", AttachGlobalSymbol); -}); +} } // namespace transform } // namespace relax } // namespace tvm diff --git a/src/relax/transform/bind_params.cc b/src/relax/transform/bind_params.cc index e2074ef085be..4ad9b3ab5051 100644 --- a/src/relax/transform/bind_params.cc +++ b/src/relax/transform/bind_params.cc @@ -197,10 +197,10 @@ IRModule BindParam(IRModule m, ffi::String func_name, ffi::Map b return ffi::GetRef(new_module); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.FunctionBindParams", FunctionBindParams); -}); +} namespace transform { @@ -211,10 +211,10 @@ Pass BindParams(ffi::String func_name, ffi::Map params) { return CreateModulePass(pass_func, 0, "BindParams", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.BindParams", BindParams); -}); +} } // namespace transform diff --git a/src/relax/transform/bind_symbolic_vars.cc b/src/relax/transform/bind_symbolic_vars.cc index b87597c118a2..04a4b0819cda 100644 --- a/src/relax/transform/bind_symbolic_vars.cc +++ b/src/relax/transform/bind_symbolic_vars.cc @@ -151,10 +151,10 @@ IRModule ModuleBindSymbolicVars( } } // namespace -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.FunctionBindSymbolicVars", FunctionBindSymbolicVars); -}); +} namespace transform { @@ -177,10 +177,10 @@ Pass BindSymbolicVars(ffi::Map, PrimExpr> bi return tvm::transform::CreateModulePass(pass_func, 1, "relax.BindSymbolicVars", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.BindSymbolicVars", BindSymbolicVars); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/bundle_model_params.cc b/src/relax/transform/bundle_model_params.cc index faf5e6838f17..877f3d7dea35 100644 --- a/src/relax/transform/bundle_model_params.cc +++ b/src/relax/transform/bundle_model_params.cc @@ -116,10 +116,10 @@ Pass BundleModelParams(ffi::Optional param_tuple_name) { return CreateModulePass(pass_func, 1, "BundleModelParams", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.BundleModelParams", BundleModelParams); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/call_tir_rewrite.cc b/src/relax/transform/call_tir_rewrite.cc index 10508382731f..d4763b44b713 100644 --- a/src/relax/transform/call_tir_rewrite.cc +++ b/src/relax/transform/call_tir_rewrite.cc @@ -184,10 +184,10 @@ Pass CallTIRRewrite() { /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.CallTIRRewrite", CallTIRRewrite); -}); +} } // namespace transform diff --git a/src/relax/transform/canonicalize_bindings.cc b/src/relax/transform/canonicalize_bindings.cc index 38dd80899fa7..decbecd3098b 100644 --- a/src/relax/transform/canonicalize_bindings.cc +++ b/src/relax/transform/canonicalize_bindings.cc @@ -592,10 +592,10 @@ Pass CanonicalizeBindings() { "CanonicalizeBindings"); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.CanonicalizeBindings", CanonicalizeBindings); -}); +} } // namespace transform diff --git a/src/relax/transform/combine_parallel_matmul.cc b/src/relax/transform/combine_parallel_matmul.cc index 34dfa1530c2f..c60864d671c5 100644 --- a/src/relax/transform/combine_parallel_matmul.cc +++ b/src/relax/transform/combine_parallel_matmul.cc @@ -388,10 +388,10 @@ Pass CombineParallelMatmul(FCheck check) { /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.CombineParallelMatmul", CombineParallelMatmul); -}); +} } // namespace transform diff --git a/src/relax/transform/compute_prim_value.cc b/src/relax/transform/compute_prim_value.cc index c2cffd2c4439..7129af2236c1 100644 --- a/src/relax/transform/compute_prim_value.cc +++ b/src/relax/transform/compute_prim_value.cc @@ -87,10 +87,10 @@ Pass ComputePrimValue() { return CreateModulePass(pass_func, 0, "ComputePrimValue", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.ComputePrimValue", ComputePrimValue); -}); +} } // namespace transform diff --git a/src/relax/transform/convert_dataflow.cc b/src/relax/transform/convert_dataflow.cc index ec768a852543..ac95acce63f2 100644 --- a/src/relax/transform/convert_dataflow.cc +++ b/src/relax/transform/convert_dataflow.cc @@ -160,10 +160,10 @@ Pass ConvertToDataflow(int min_size) { return tvm::transform::Sequential({pass, CanonicalizeBindings()}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.ConvertToDataflow", ConvertToDataflow); -}); +} } // namespace transform diff --git a/src/relax/transform/convert_layout.cc b/src/relax/transform/convert_layout.cc index 865b64dcf5e2..c543799e3b0d 100644 --- a/src/relax/transform/convert_layout.cc +++ b/src/relax/transform/convert_layout.cc @@ -353,10 +353,10 @@ Pass ConvertLayout(ffi::Map> desired_layout return CreateDataflowBlockPass(pass_func, 0, "ConvertLayout", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.ConvertLayout", ConvertLayout); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/dataflow_inplace.cc b/src/relax/transform/dataflow_inplace.cc index ef25fb8e5d8f..3b56d6ca1d81 100644 --- a/src/relax/transform/dataflow_inplace.cc +++ b/src/relax/transform/dataflow_inplace.cc @@ -534,7 +534,7 @@ class InplaceOpportunityNode : public Object { TVM_FFI_DECLARE_OBJECT_INFO("relax.transform.InplaceOpportunity", InplaceOpportunityNode, Object); }; -TVM_FFI_STATIC_INIT_BLOCK({ InplaceOpportunityNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { InplaceOpportunityNode::RegisterReflection(); } class InplaceOpportunity : public ObjectRef { public: @@ -1019,7 +1019,7 @@ ffi::Array> DataflowInplaceAnalysis(const Dataflo } // these are exposed only for testing -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.testing.transform.DataflowLivenessAnalysis", DataflowLivenessAnalysis) @@ -1032,13 +1032,13 @@ TVM_FFI_STATIC_INIT_BLOCK({ auto ret_call = transformer.CreateInplaceCall(call, inplace_indices); return ffi::Array{ret_call, transformer.CurrentMod()}; }); -}); +} // actually exposed -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.DataflowUseInplaceCalls", DataflowUseInplaceCalls); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/dead_code_elimination.cc b/src/relax/transform/dead_code_elimination.cc index 378239fad0f6..fbb077ddf941 100644 --- a/src/relax/transform/dead_code_elimination.cc +++ b/src/relax/transform/dead_code_elimination.cc @@ -142,10 +142,10 @@ Pass DeadCodeElimination(ffi::Array entry_functions) { return CreateModulePass(pass_func, 1, "DeadCodeElimination", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.DeadCodeElimination", DeadCodeElimination); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/decompose_ops.cc b/src/relax/transform/decompose_ops.cc index 5050ab487dd0..81d4d3881ede 100644 --- a/src/relax/transform/decompose_ops.cc +++ b/src/relax/transform/decompose_ops.cc @@ -251,12 +251,12 @@ Pass DecomposeOpsForTraining(ffi::Optional func_name) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.transform.DecomposeOpsForInference", DecomposeOpsForInference) .def("relax.transform.DecomposeOpsForTraining", DecomposeOpsForTraining); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/eliminate_common_subexpr.cc b/src/relax/transform/eliminate_common_subexpr.cc index c88a5bfccb74..e893b5151b52 100644 --- a/src/relax/transform/eliminate_common_subexpr.cc +++ b/src/relax/transform/eliminate_common_subexpr.cc @@ -222,10 +222,10 @@ Pass EliminateCommonSubexpr(bool call_only) { return CreateFunctionPass(pass_func, 1, "EliminateCommonSubexpr", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.EliminateCommonSubexpr", EliminateCommonSubexpr); -}); +} } // namespace transform diff --git a/src/relax/transform/expand_matmul_of_sum.cc b/src/relax/transform/expand_matmul_of_sum.cc index a871b007b4c4..5504c2a59942 100644 --- a/src/relax/transform/expand_matmul_of_sum.cc +++ b/src/relax/transform/expand_matmul_of_sum.cc @@ -105,10 +105,10 @@ Pass ExpandMatmulOfSum() { return CreateFunctionPass(pass_func, 1, "ExpandMatmulOfSum", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.ExpandMatmulOfSum", ExpandMatmulOfSum); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/expand_tuple_arguments.cc b/src/relax/transform/expand_tuple_arguments.cc index fbe16e9c1b35..0239652c791a 100644 --- a/src/relax/transform/expand_tuple_arguments.cc +++ b/src/relax/transform/expand_tuple_arguments.cc @@ -179,10 +179,10 @@ Pass ExpandTupleArguments() { "ExpandTupleArguments"); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.ExpandTupleArguments", ExpandTupleArguments); -}); +} } // namespace transform diff --git a/src/relax/transform/few_shot_tuning.cc b/src/relax/transform/few_shot_tuning.cc index 7deffaa9f58e..6c213a9504a8 100644 --- a/src/relax/transform/few_shot_tuning.cc +++ b/src/relax/transform/few_shot_tuning.cc @@ -174,10 +174,10 @@ Pass FewShotTuning(int valid_count, bool benchmark) { /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.FewShotTuning", FewShotTuning); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/fold_constant.cc b/src/relax/transform/fold_constant.cc index c2f2f48cafdc..0892adcc1a3a 100644 --- a/src/relax/transform/fold_constant.cc +++ b/src/relax/transform/fold_constant.cc @@ -330,10 +330,10 @@ Pass FoldConstant() { return CreateFunctionPass(pass_func, 0, "FoldConstant", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.FoldConstant", FoldConstant); -}); +} } // namespace transform diff --git a/src/relax/transform/fuse_ops.cc b/src/relax/transform/fuse_ops.cc index acd54d043e56..561695787de8 100644 --- a/src/relax/transform/fuse_ops.cc +++ b/src/relax/transform/fuse_ops.cc @@ -48,10 +48,10 @@ namespace tvm { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { transform::FusionPatternNode::RegisterReflection(); transform::PatternCheckContextNode::RegisterReflection(); -}); +} /* Note on Fusing algorithm: @@ -1410,7 +1410,7 @@ FusionPattern::FusionPattern(ffi::String name, DFPattern pattern, data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.transform.FusionPattern", @@ -1418,7 +1418,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ffi::Optional check, ffi::Optional attrs_getter) { return FusionPattern(name, pattern, annotation_patterns, check, attrs_getter); }); -}); +} PatternCheckContext::PatternCheckContext(Expr matched_expr, ffi::Map annotated_expr, @@ -1447,10 +1447,10 @@ Pass FuseOps(int fuse_opt_level) { /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.FuseOps", FuseOps); -}); +} Pass FuseOpsByPattern(const tvm::ffi::Array& patterns, bool bind_constants, bool annotate_codegen, const ffi::Array& entry_function_names) { @@ -1465,10 +1465,10 @@ Pass FuseOpsByPattern(const tvm::ffi::Array& patterns, bool bind_ /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.FuseOpsByPattern", FuseOpsByPattern); -}); +} } // namespace transform diff --git a/src/relax/transform/fuse_tir.cc b/src/relax/transform/fuse_tir.cc index 61b3a6024810..ba4515faf390 100644 --- a/src/relax/transform/fuse_tir.cc +++ b/src/relax/transform/fuse_tir.cc @@ -1270,10 +1270,10 @@ Pass FuseTIR() { "FuseTIR"); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.FuseTIR", FuseTIR); -}); +} } // namespace transform diff --git a/src/relax/transform/gradient.cc b/src/relax/transform/gradient.cc index e4af204d323f..15bf6a273a3f 100644 --- a/src/relax/transform/gradient.cc +++ b/src/relax/transform/gradient.cc @@ -790,10 +790,10 @@ Pass Gradient(ffi::String func_name, ffi::Optional> require_grad /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.Gradient", Gradient); -}); +} } // namespace transform diff --git a/src/relax/transform/infer_layout_utils.cc b/src/relax/transform/infer_layout_utils.cc index ea0bd2474913..bc572f8a5407 100644 --- a/src/relax/transform/infer_layout_utils.cc +++ b/src/relax/transform/infer_layout_utils.cc @@ -157,10 +157,10 @@ LayoutDecision FollowDecision(const LayoutDecision& src, int dst_ndim) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { LayoutDecisionNode::RegisterReflection(); InferLayoutOutputNode::RegisterReflection(); -}); +} } // namespace relax } // namespace tvm diff --git a/src/relax/transform/inline_functions.cc b/src/relax/transform/inline_functions.cc index e2ab8c1b663c..f3f21cc7843d 100644 --- a/src/relax/transform/inline_functions.cc +++ b/src/relax/transform/inline_functions.cc @@ -166,10 +166,10 @@ Function FunctionInlineFunctions( return Downcast(mutator(std::move(func))); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.FunctionInlineFunctions", FunctionInlineFunctions); -}); +} namespace transform { @@ -224,10 +224,10 @@ Pass InlinePrivateFunctions() { return tvm::transform::CreateModulePass(pass_func, 0, "InlinePrivateFunctions", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.InlinePrivateFunctions", InlinePrivateFunctions); -}); +} } // namespace transform diff --git a/src/relax/transform/kill_after_last_use.cc b/src/relax/transform/kill_after_last_use.cc index 7b6e8e502214..e1e8a5d87998 100644 --- a/src/relax/transform/kill_after_last_use.cc +++ b/src/relax/transform/kill_after_last_use.cc @@ -267,10 +267,10 @@ Pass KillAfterLastUse() { return CreateFunctionPass(pass_func, /*opt_level=*/0, "KillAfterLastUse", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.KillAfterLastUse", KillAfterLastUse); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/lambda_lift.cc b/src/relax/transform/lambda_lift.cc index fe8d28964dd5..e77b0a266038 100644 --- a/src/relax/transform/lambda_lift.cc +++ b/src/relax/transform/lambda_lift.cc @@ -500,10 +500,10 @@ Pass LambdaLift() { return tvm::transform::CreateModulePass(pass_func, 1, "LambdaLift", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.LambdaLift", LambdaLift); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/lazy_transform_params.cc b/src/relax/transform/lazy_transform_params.cc index 61e36fae69bc..bc6f4530db59 100644 --- a/src/relax/transform/lazy_transform_params.cc +++ b/src/relax/transform/lazy_transform_params.cc @@ -261,10 +261,10 @@ Pass LazyGetInput() { /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.LazyGetInput", LazyGetInput); -}); +} Pass LazySetOutput() { auto pass_func = [](Function func, IRModule, PassContext) -> Function { @@ -279,10 +279,10 @@ Pass LazySetOutput() { /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.LazySetOutput", LazySetOutput); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/legalize_ops.cc b/src/relax/transform/legalize_ops.cc index c3544314a774..64ac5e86fb48 100644 --- a/src/relax/transform/legalize_ops.cc +++ b/src/relax/transform/legalize_ops.cc @@ -406,10 +406,10 @@ Pass LegalizeOps(ffi::Optional> cmap, bool /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.LegalizeOps", LegalizeOps); -}); +} } // namespace transform diff --git a/src/relax/transform/lift_transform_params.cc b/src/relax/transform/lift_transform_params.cc index 16a50a19a3e3..f7c49d0da8df 100644 --- a/src/relax/transform/lift_transform_params.cc +++ b/src/relax/transform/lift_transform_params.cc @@ -868,10 +868,10 @@ Pass LiftTransformParams(ffi::Variant> shared_tran "LiftTransformParams"); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.LiftTransformParams", LiftTransformParams); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/lower_alloc_tensor.cc b/src/relax/transform/lower_alloc_tensor.cc index 00c7092c0220..d1e61b1c5748 100644 --- a/src/relax/transform/lower_alloc_tensor.cc +++ b/src/relax/transform/lower_alloc_tensor.cc @@ -100,10 +100,10 @@ Pass LowerAllocTensor() { return CreateFunctionPass(pass_func, /*opt_level=*/0, "LowerAllocTensor", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.LowerAllocTensor", LowerAllocTensor); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/merge_composite_functions.cc b/src/relax/transform/merge_composite_functions.cc index da9518394468..e8a9b74d94c4 100644 --- a/src/relax/transform/merge_composite_functions.cc +++ b/src/relax/transform/merge_composite_functions.cc @@ -422,10 +422,10 @@ Pass MergeCompositeFunctions() { /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.MergeCompositeFunctions", MergeCompositeFunctions); -}); +} } // namespace transform diff --git a/src/relax/transform/meta_schedule.cc b/src/relax/transform/meta_schedule.cc index 295937084d86..023e8cdab350 100644 --- a/src/relax/transform/meta_schedule.cc +++ b/src/relax/transform/meta_schedule.cc @@ -177,13 +177,13 @@ Pass MetaScheduleTuneTIR(ffi::String work_dir, Integer max_trials_global) { /*traceable*/ true); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("relax.transform.MetaScheduleApplyDatabase", MetaScheduleApplyDatabase) .def("relax.transform.MetaScheduleTuneIRMod", MetaScheduleTuneIRMod) .def("relax.transform.MetaScheduleTuneTIR", MetaScheduleTuneTIR); -}); +} } // namespace transform } // namespace relax } // namespace tvm diff --git a/src/relax/transform/normalize.cc b/src/relax/transform/normalize.cc index 0002de872aa8..e764e333f721 100644 --- a/src/relax/transform/normalize.cc +++ b/src/relax/transform/normalize.cc @@ -280,10 +280,10 @@ Pass Normalize() { return CreateFunctionPass(pass_func, 1, "Normalize", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.Normalize", Normalize); -}); +} Pass NormalizeGlobalVar() { auto pass_func = [=](IRModule mod, PassContext pc) { @@ -294,10 +294,10 @@ Pass NormalizeGlobalVar() { /*pass_name=*/"NormalizeGlobalVar", /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.NormalizeGlobalVar", NormalizeGlobalVar); -}); +} } // namespace transform diff --git a/src/relax/transform/realize_vdevice.cc b/src/relax/transform/realize_vdevice.cc index 087579fc309f..79c1bf36b549 100644 --- a/src/relax/transform/realize_vdevice.cc +++ b/src/relax/transform/realize_vdevice.cc @@ -416,10 +416,10 @@ Pass RealizeVDevice() { /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.RealizeVDevice", RealizeVDevice); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/remove_purity_checking.cc b/src/relax/transform/remove_purity_checking.cc index b6e038eac1bd..aaa38fcda7ce 100644 --- a/src/relax/transform/remove_purity_checking.cc +++ b/src/relax/transform/remove_purity_checking.cc @@ -89,10 +89,10 @@ Pass RemovePurityChecking() { return CreateFunctionPass(pass_func, 0, "RemovePurityChecking", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.RemovePurityChecking", RemovePurityChecking); -}); +} } // namespace transform diff --git a/src/relax/transform/remove_unused_outputs.cc b/src/relax/transform/remove_unused_outputs.cc index 140e6ae8333e..83170abd635b 100644 --- a/src/relax/transform/remove_unused_outputs.cc +++ b/src/relax/transform/remove_unused_outputs.cc @@ -337,10 +337,10 @@ Pass RemoveUnusedOutputs() { "RemoveUnusedOutputs"); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.RemoveUnusedOutputs", RemoveUnusedOutputs); -}); +} } // namespace transform diff --git a/src/relax/transform/remove_unused_parameters.cc b/src/relax/transform/remove_unused_parameters.cc index 4d203648ffea..5003dec8a8d2 100644 --- a/src/relax/transform/remove_unused_parameters.cc +++ b/src/relax/transform/remove_unused_parameters.cc @@ -251,10 +251,10 @@ Pass RemoveUnusedParameters() { return CreateModulePass(pass_func, 0, "RemoveUnusedParameters", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.RemoveUnusedParameters", RemoveUnusedParameters); -}); +} } // namespace transform diff --git a/src/relax/transform/reorder_permute_dims_after_concat.cc b/src/relax/transform/reorder_permute_dims_after_concat.cc index 5c73acb451bb..73bc1853816e 100644 --- a/src/relax/transform/reorder_permute_dims_after_concat.cc +++ b/src/relax/transform/reorder_permute_dims_after_concat.cc @@ -175,11 +175,11 @@ Pass ReorderPermuteDimsAfterConcat() { return CreateFunctionPass(pass_func, 1, "ReorderPermuteDimsAfterConcat", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.ReorderPermuteDimsAfterConcat", ReorderPermuteDimsAfterConcat); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/reorder_take_after_matmul.cc b/src/relax/transform/reorder_take_after_matmul.cc index 51744a43247d..25f245101b1b 100644 --- a/src/relax/transform/reorder_take_after_matmul.cc +++ b/src/relax/transform/reorder_take_after_matmul.cc @@ -157,10 +157,10 @@ Pass ReorderTakeAfterMatmul() { return CreateFunctionPass(pass_func, 1, "ReorderTakeAfterMatmul", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.ReorderTakeAfterMatmul", ReorderTakeAfterMatmul); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/rewrite_cuda_graph.cc b/src/relax/transform/rewrite_cuda_graph.cc index 955b858a0c7c..8ecfabd7c27a 100644 --- a/src/relax/transform/rewrite_cuda_graph.cc +++ b/src/relax/transform/rewrite_cuda_graph.cc @@ -900,10 +900,10 @@ Pass RewriteCUDAGraph() { return CreateModulePass(pass_func, 0, "RewriteCUDAGraph", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.RewriteCUDAGraph", RewriteCUDAGraph); -}); +} } // namespace transform diff --git a/src/relax/transform/rewrite_dataflow_reshape.cc b/src/relax/transform/rewrite_dataflow_reshape.cc index 1ce656a7fb66..fdaa2b927e2e 100644 --- a/src/relax/transform/rewrite_dataflow_reshape.cc +++ b/src/relax/transform/rewrite_dataflow_reshape.cc @@ -166,10 +166,10 @@ Pass RewriteDataflowReshape() { return CreateFunctionPass(pass_func, 0, "RewriteDataflowReshape", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.RewriteDataflowReshape", RewriteDataflowReshape); -}); +} } // namespace transform diff --git a/src/relax/transform/run_codegen.cc b/src/relax/transform/run_codegen.cc index 88389b416ca0..71d557d031cf 100644 --- a/src/relax/transform/run_codegen.cc +++ b/src/relax/transform/run_codegen.cc @@ -224,10 +224,10 @@ Pass RunCodegen( return CreateModulePass(pass_func, 0, "RunCodegen", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.RunCodegen", RunCodegen); -}); +} } // namespace transform } // namespace tvm diff --git a/src/relax/transform/split_call_tir_by_pattern.cc b/src/relax/transform/split_call_tir_by_pattern.cc index c0dce4db6122..00c6efb192a3 100644 --- a/src/relax/transform/split_call_tir_by_pattern.cc +++ b/src/relax/transform/split_call_tir_by_pattern.cc @@ -779,10 +779,10 @@ Pass SplitCallTIRByPattern(ffi::Array patterns, FCodegen fcodegen) { /*pass_name=*/"SplitCallTIRByPattern", // /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.SplitCallTIRByPattern", SplitCallTIRByPattern); -}); +} } // namespace transform diff --git a/src/relax/transform/split_layout_rewrite_preproc.cc b/src/relax/transform/split_layout_rewrite_preproc.cc index ccb723a0c163..1da49c1d7de3 100644 --- a/src/relax/transform/split_layout_rewrite_preproc.cc +++ b/src/relax/transform/split_layout_rewrite_preproc.cc @@ -341,9 +341,9 @@ Pass SplitLayoutRewritePreproc() { return tvm::transform::Sequential({pass, relax::transform::DeadCodeElimination()}, "SplitLayoutRewritePreproc"); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.SplitLayoutRewritePreproc", SplitLayoutRewritePreproc); -}); +} } // namespace transform } // namespace tvm diff --git a/src/relax/transform/static_plan_block_memory.cc b/src/relax/transform/static_plan_block_memory.cc index 76f37ace1239..85076206ae53 100644 --- a/src/relax/transform/static_plan_block_memory.cc +++ b/src/relax/transform/static_plan_block_memory.cc @@ -973,10 +973,10 @@ Pass StaticPlanBlockMemory() { return CreateModulePass(pass_func, /*opt_level=*/0, "StaticPlanBlockMemory", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.StaticPlanBlockMemory", StaticPlanBlockMemory); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/to_mixed_precision.cc b/src/relax/transform/to_mixed_precision.cc index 026e68c3ba6f..66a148e593ca 100644 --- a/src/relax/transform/to_mixed_precision.cc +++ b/src/relax/transform/to_mixed_precision.cc @@ -620,10 +620,10 @@ Pass ToMixedPrecision(const DataType& out_dtype, return CreateFunctionPass(pass_func, 0, "ToMixedPrecision", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.ToMixedPrecision", ToMixedPrecision); -}); +} } // namespace transform diff --git a/src/relax/transform/to_non_dataflow.cc b/src/relax/transform/to_non_dataflow.cc index 5f87c4a6be72..b9345744320c 100644 --- a/src/relax/transform/to_non_dataflow.cc +++ b/src/relax/transform/to_non_dataflow.cc @@ -62,10 +62,10 @@ Pass ToNonDataflow() { return CreateFunctionPass(pass_func, 0, "ToNonDataflow", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.ToNonDataflow", ToNonDataflow); -}); +} } // namespace transform diff --git a/src/relax/transform/topological_sort.cc b/src/relax/transform/topological_sort.cc index 7bf2141f75d5..114af668b980 100644 --- a/src/relax/transform/topological_sort.cc +++ b/src/relax/transform/topological_sort.cc @@ -343,7 +343,7 @@ Pass TopologicalSort(TraversalOrder order, StartingLocation starting_location) { return relax::transform::CreateFunctionPass(pass_func, 0, "TopologicalSort", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "relax.transform.TopologicalSort", @@ -374,7 +374,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return TopologicalSort(order, starting_location); }); -}); +} } // namespace transform diff --git a/src/relax/transform/update_param_struct_info.cc b/src/relax/transform/update_param_struct_info.cc index 0bf0c6ae6bb6..071e5bf4c991 100644 --- a/src/relax/transform/update_param_struct_info.cc +++ b/src/relax/transform/update_param_struct_info.cc @@ -105,10 +105,10 @@ Pass UpdateParamStructInfo(ffi::TypedFunction(Var)> si return tvm::transform::CreateModulePass(pass_func, 1, "UpdateParamStructInfo", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.UpdateParamStructInfo", UpdateParamStructInfo); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/transform/update_vdevice.cc b/src/relax/transform/update_vdevice.cc index 77d4f21ee6d3..a6cbb83b8c73 100644 --- a/src/relax/transform/update_vdevice.cc +++ b/src/relax/transform/update_vdevice.cc @@ -107,10 +107,10 @@ Pass UpdateVDevice(VDevice new_vdevice, int64_t index) { /*pass_name=*/"UpdateVDevice", /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.transform.UpdateVDevice", UpdateVDevice); -}); +} } // namespace transform } // namespace relax diff --git a/src/relax/utils.cc b/src/relax/utils.cc index d594ce90b499..37e53a614ff0 100644 --- a/src/relax/utils.cc +++ b/src/relax/utils.cc @@ -247,10 +247,10 @@ Expr GetBoundValue(const Binding& b) { */ Function CopyWithNewVars(Function func) { return FunctionCopier().Copy(func); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.CopyWithNewVars", CopyWithNewVars); -}); +} } // namespace relax } // namespace tvm diff --git a/src/runtime/const_loader_module.cc b/src/runtime/const_loader_module.cc index c4604348ba01..918d55107793 100644 --- a/src/runtime/const_loader_module.cc +++ b/src/runtime/const_loader_module.cc @@ -255,11 +255,11 @@ ffi::Module ConstLoaderModuleCreate( return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ffi.Module.load_from_bytes.const_loader", ConstLoaderModuleObj::LoadFromBytes); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/amx/amx_config.cc b/src/runtime/contrib/amx/amx_config.cc index a38072dec1cd..4be9d57811b3 100644 --- a/src/runtime/contrib/amx/amx_config.cc +++ b/src/runtime/contrib/amx/amx_config.cc @@ -76,7 +76,7 @@ void init_tile_config(__tilecfg_u* dst, uint16_t cols, uint8_t rows) { _tile_loadconfig(dst->a); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("runtime.amx_tileconfig", [](ffi::PackedArgs args, ffi::Any* rv) { int rows = args[0].cast(); @@ -89,10 +89,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ *rv = 1; return; }); -}); +} // register a global packed function in c++,to init the system for AMX config -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("runtime.amx_init", [](ffi::PackedArgs args, ffi::Any* rv) { // -----------Detect and request for AMX control---------------------- @@ -134,7 +134,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ *rv = 1; return; }); -}); +} #endif } // namespace runtime diff --git a/src/runtime/contrib/arm_compute_lib/acl_runtime.cc b/src/runtime/contrib/arm_compute_lib/acl_runtime.cc index 5cd6a1746647..b090f0ccfbda 100644 --- a/src/runtime/contrib/arm_compute_lib/acl_runtime.cc +++ b/src/runtime/contrib/arm_compute_lib/acl_runtime.cc @@ -594,13 +594,13 @@ ffi::Module ACLRuntimeCreate(const ffi::String& symbol_name, const ffi::String& return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.arm_compute_lib_runtime_create", ACLRuntimeCreate) .def("ffi.Module.load_from_bytes.arm_compute_lib", JSONRuntimeBase::LoadFromBytes); -}); +} } // namespace contrib } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/bnns/bnns_json_runtime.cc b/src/runtime/contrib/bnns/bnns_json_runtime.cc index 735a5eff7bd2..499330cd0b5b 100644 --- a/src/runtime/contrib/bnns/bnns_json_runtime.cc +++ b/src/runtime/contrib/bnns/bnns_json_runtime.cc @@ -563,12 +563,12 @@ ffi::Module BNNSJSONRuntimeCreate(ffi::String symbol_name, ffi::String graph_jso return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.BNNSJSONRuntimeCreate", BNNSJSONRuntimeCreate) .def("ffi.Module.load_from_bytes.bnns_json", JSONRuntimeBase::LoadFromBytes); -}); +} } // namespace contrib } // namespace runtime diff --git a/src/runtime/contrib/cblas/cblas.cc b/src/runtime/contrib/cblas/cblas.cc index 8d74ce855c31..85899b64f480 100644 --- a/src/runtime/contrib/cblas/cblas.cc +++ b/src/runtime/contrib/cblas/cblas.cc @@ -124,7 +124,7 @@ struct CblasDgemmBatchIterativeOp { }; // matrix multiplication for row major -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.contrib.cblas.matmul", @@ -157,6 +157,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ CallBatchGemm(args, ret, CblasDgemmBatchIterativeOp()); } }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/cblas/dnnl_blas.cc b/src/runtime/contrib/cblas/dnnl_blas.cc index 59400f19dd2f..9862a37301d3 100644 --- a/src/runtime/contrib/cblas/dnnl_blas.cc +++ b/src/runtime/contrib/cblas/dnnl_blas.cc @@ -47,13 +47,13 @@ struct DNNLSgemmOp { }; // matrix multiplication for row major -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvm.contrib.dnnl.matmul", [](ffi::PackedArgs args, ffi::Any* ret) { auto A = args[0].cast(); ICHECK(TypeMatch(A->dtype, kDLFloat, 32)); CallGemm(args, ret, DNNLSgemmOp()); }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/cblas/mkl.cc b/src/runtime/contrib/cblas/mkl.cc index 19ce6ceb9b07..be8db227e554 100644 --- a/src/runtime/contrib/cblas/mkl.cc +++ b/src/runtime/contrib/cblas/mkl.cc @@ -155,7 +155,7 @@ struct MKLDgemmBatchIterativeOp { }; // matrix multiplication for row major -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvm.contrib.mkl.matmul", [](ffi::PackedArgs args, ffi::Any* ret) { auto A = args[0].cast(); @@ -166,10 +166,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ else CallGemm(args, ret, MKLDgemmOp()); }); -}); +} // integer matrix multiplication for row major -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.contrib.mkl.matmul_u8s8s32", @@ -202,6 +202,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ CallBatchGemm(args, ret, MKLDgemmBatchIterativeOp()); } }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/clml/clml_runtime.cc b/src/runtime/contrib/clml/clml_runtime.cc index 62ba4846f6d1..c166d0fb4bed 100644 --- a/src/runtime/contrib/clml/clml_runtime.cc +++ b/src/runtime/contrib/clml/clml_runtime.cc @@ -1832,12 +1832,12 @@ ffi::Module CLMLRuntimeCreate(const ffi::String& symbol_name, const ffi::String& return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.clml_runtime_create", CLMLRuntimeCreate) .def("ffi.Module.load_from_bytes.clml", JSONRuntimeBase::LoadFromBytes); -}); +} } // namespace contrib } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/coreml/coreml_runtime.mm b/src/runtime/contrib/coreml/coreml_runtime.mm index e0c1653077a8..c3ac6185d98f 100644 --- a/src/runtime/contrib/coreml/coreml_runtime.mm +++ b/src/runtime/contrib/coreml/coreml_runtime.mm @@ -191,12 +191,12 @@ return ffi::Module(exec); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvm.coreml_runtime.create", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = CoreMLRuntimeCreate(args[0], args[1]); }); -}); +} ffi::Bytes CoreMLRuntime::SaveToBytes() const { std::string buffer; @@ -255,10 +255,10 @@ return ffi::Module(exec); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ffi.Module.load_from_bytes.coreml", CoreMLRuntimeLoadFromBytes); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/cublas/cublas.cc b/src/runtime/contrib/cublas/cublas.cc index 88a0dc128df2..715172ecd8f9 100644 --- a/src/runtime/contrib/cublas/cublas.cc +++ b/src/runtime/contrib/cublas/cublas.cc @@ -516,7 +516,7 @@ inline void CallBatchGemmEx(ffi::PackedArgs args, ffi::Any* ret, cublasHandle_t } // matrix multiplication for row major -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "tvm.contrib.cublas.matmul", [](ffi::PackedArgs args, ffi::Any* ret) { @@ -541,10 +541,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ CallGemmEx(args, ret, entry_ptr->handle); } }); -}); +} #if CUDART_VERSION >= 10010 -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "tvm.contrib.cublaslt.matmul", [](ffi::PackedArgs args, ffi::Any* ret) { @@ -562,10 +562,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ CallLtIgemm(args, ret, ltHandle, stream); CHECK_CUBLAS_ERROR(cublasLtDestroy(ltHandle)); }); -}); +} #endif // CUDART_VERSION >= 10010 -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "tvm.contrib.cublas.batch_matmul", [](ffi::PackedArgs args, ffi::Any* ret) { @@ -589,7 +589,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ CallBatchGemmEx(args, ret, entry_ptr->handle); } }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/cublas/cublas_json_runtime.cc b/src/runtime/contrib/cublas/cublas_json_runtime.cc index 33bdaaf0f7c0..70521c1d7399 100644 --- a/src/runtime/contrib/cublas/cublas_json_runtime.cc +++ b/src/runtime/contrib/cublas/cublas_json_runtime.cc @@ -159,13 +159,13 @@ ffi::Module CublasJSONRuntimeCreate(ffi::String symbol_name, ffi::String graph_j return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.CublasJSONRuntimeCreate", CublasJSONRuntimeCreate) .def("ffi.Module.load_from_bytes.cublas_json", JSONRuntimeBase::LoadFromBytes); -}); +} } // namespace contrib } // namespace runtime diff --git a/src/runtime/contrib/cudnn/conv_backward.cc b/src/runtime/contrib/cudnn/conv_backward.cc index 515263ef364e..d26f82645eaf 100644 --- a/src/runtime/contrib/cudnn/conv_backward.cc +++ b/src/runtime/contrib/cudnn/conv_backward.cc @@ -190,7 +190,7 @@ void BackwardFilterFindAlgo(int format, int dims, int groups, const int pad[], c ret[0] = static_cast(best_algo); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.contrib.cudnn.conv2d.backward_data", @@ -269,7 +269,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ BackwardFilterFindAlgo(format, dims, groups, pad, stride, dilation, dy_dim, x_dim, dw_dim, data_dtype, conv_dtype, verbose, ret); }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/cudnn/conv_forward.cc b/src/runtime/contrib/cudnn/conv_forward.cc index 7a93e194ce3c..6a5737c183b0 100644 --- a/src/runtime/contrib/cudnn/conv_forward.cc +++ b/src/runtime/contrib/cudnn/conv_forward.cc @@ -156,7 +156,7 @@ void FindAlgo(int format, int dims, int groups, const int pad[], const int strid ret[0] = static_cast(best_algo); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.contrib.cudnn.conv2d.forward", @@ -240,7 +240,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ FindAlgo(format, dims, groups, pad, stride, dilation, x_dim, w_dim, y_dim, data_dtype, conv_dtype, verbose, ret); }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/cudnn/cudnn_json_runtime.cc b/src/runtime/contrib/cudnn/cudnn_json_runtime.cc index 48560f4306a6..cefa2957b601 100644 --- a/src/runtime/contrib/cudnn/cudnn_json_runtime.cc +++ b/src/runtime/contrib/cudnn/cudnn_json_runtime.cc @@ -243,13 +243,13 @@ ffi::Module cuDNNJSONRuntimeCreate(ffi::String symbol_name, ffi::String graph_js return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.cuDNNJSONRuntimeCreate", cuDNNJSONRuntimeCreate) .def("ffi.Module.load_from_bytes.cudnn_json", JSONRuntimeBase::LoadFromBytes); -}); +} } // namespace contrib } // namespace runtime diff --git a/src/runtime/contrib/cudnn/cudnn_utils.cc b/src/runtime/contrib/cudnn/cudnn_utils.cc index f36a50a80a35..b0e3af9efb59 100644 --- a/src/runtime/contrib/cudnn/cudnn_utils.cc +++ b/src/runtime/contrib/cudnn/cudnn_utils.cc @@ -267,14 +267,14 @@ SoftmaxEntry::SoftmaxEntry() { CUDNN_CALL(cudnnCreateTensorDescriptor(&shape_des SoftmaxEntry::~SoftmaxEntry() { CUDNN_CALL(cudnnDestroyTensorDescriptor(shape_desc)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tvm.contrib.cudnn.exists", []() -> bool { int device_id; CUDA_CALL(cudaGetDevice(&device_id)); return CuDNNThreadEntry::ThreadLocal(DLDevice{kDLCUDA, device_id}, false)->exists(); }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/cudnn/softmax.cc b/src/runtime/contrib/cudnn/softmax.cc index eb2fceb3d2db..10df70670c70 100644 --- a/src/runtime/contrib/cudnn/softmax.cc +++ b/src/runtime/contrib/cudnn/softmax.cc @@ -79,7 +79,7 @@ void softmax_impl(cudnnSoftmaxAlgorithm_t alg, ffi::PackedArgs args, ffi::Any* r entry_ptr->softmax_entry.shape_desc, y->data)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.contrib.cudnn.softmax.forward", @@ -89,7 +89,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_packed("tvm.contrib.cudnn.log_softmax.forward", [](ffi::PackedArgs args, ffi::Any* ret) { softmax_impl(CUDNN_SOFTMAX_LOG, args, ret); }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/curand/curand.cc b/src/runtime/contrib/curand/curand.cc index 7a9f2d598827..2a43d309e7dc 100644 --- a/src/runtime/contrib/curand/curand.cc +++ b/src/runtime/contrib/curand/curand.cc @@ -113,10 +113,10 @@ void RandomFill(DLTensor* tensor) { TVMSynchronize(tensor->device.device_type, tensor->device.device_type, nullptr); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("runtime.contrib.curand.RandomFill", RandomFill); -}); +} } // namespace curand } // namespace runtime diff --git a/src/runtime/contrib/cutlass/fp16_group_gemm_sm100.cu b/src/runtime/contrib/cutlass/fp16_group_gemm_sm100.cu index ef72c0008034..0c9fe0fff14d 100644 --- a/src/runtime/contrib/cutlass/fp16_group_gemm_sm100.cu +++ b/src/runtime/contrib/cutlass/fp16_group_gemm_sm100.cu @@ -47,10 +47,10 @@ void tvm_cutlass_group_gemm_sm100(Tensor x, Tensor weight, Tensor indptr, Tensor tvm_cutlass_group_gemm_impl<100>(x, weight, indptr, workspace, out); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("cutlass.group_gemm", tvm_cutlass_group_gemm_sm100); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/cutlass/fp16_group_gemm_sm90.cu b/src/runtime/contrib/cutlass/fp16_group_gemm_sm90.cu index 508bc77f9205..e78fb06322e2 100644 --- a/src/runtime/contrib/cutlass/fp16_group_gemm_sm90.cu +++ b/src/runtime/contrib/cutlass/fp16_group_gemm_sm90.cu @@ -46,10 +46,10 @@ void tvm_cutlass_group_gemm_sm90(Tensor x, Tensor weight, Tensor indptr, Tensor tvm_cutlass_group_gemm_impl<90>(x, weight, indptr, workspace, out); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("cutlass.group_gemm", tvm_cutlass_group_gemm_sm90); -}); +} #endif // CUTLASS_ARCH_MMA_MODIFIABLE_TMA_SM90_SUPPORTED diff --git a/src/runtime/contrib/cutlass/fp8_gemm.cu b/src/runtime/contrib/cutlass/fp8_gemm.cu index 5c73c0cb74bd..d41064efbaf0 100644 --- a/src/runtime/contrib/cutlass/fp8_gemm.cu +++ b/src/runtime/contrib/cutlass/fp8_gemm.cu @@ -76,7 +76,7 @@ void tvm_cutlass_fp8_gemm(Tensor x, Tensor weight, Tensor workspace, Tensor alph } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("cutlass.gemm_e5m2_e5m2_fp16", @@ -85,7 +85,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ tvm_cutlass_fp8_gemm) .def("cutlass.gemm_e4m3_e4m3_fp16", tvm_cutlass_fp8_gemm); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/cutlass/fp8_group_gemm_sm90.cu b/src/runtime/contrib/cutlass/fp8_group_gemm_sm90.cu index 97f3e80e5bf0..b2e08b7570ab 100644 --- a/src/runtime/contrib/cutlass/fp8_group_gemm_sm90.cu +++ b/src/runtime/contrib/cutlass/fp8_group_gemm_sm90.cu @@ -67,7 +67,7 @@ void tvm_cutlass_fp8_group_gemm(Tensor x, Tensor weight, Tensor indptr, Tensor w static_cast(out->data), stream); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def( @@ -79,7 +79,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("cutlass.group_gemm_e4m3_e4m3_fp16", tvm_cutlass_fp8_group_gemm); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/cutlass/fp8_groupwise_scaled_gemm_sm100.cu b/src/runtime/contrib/cutlass/fp8_groupwise_scaled_gemm_sm100.cu index bd2d2aa04fb4..e8035c172a3c 100644 --- a/src/runtime/contrib/cutlass/fp8_groupwise_scaled_gemm_sm100.cu +++ b/src/runtime/contrib/cutlass/fp8_groupwise_scaled_gemm_sm100.cu @@ -67,14 +67,14 @@ void tvm_cutlass_fp8_groupwise_scaled_bmm_sm100(Tensor a, Tensor b, Tensor scale a, b, scales_a, scales_b, workspace, block_size_0, block_size_1, out); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("cutlass.groupwise_scaled_gemm_e4m3fn_e4m3fn", tvm_cutlass_fp8_groupwise_scaled_gemm_sm100) .def("cutlass.groupwise_scaled_bmm_e4m3fn_e4m3fn", tvm_cutlass_fp8_groupwise_scaled_bmm_sm100); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/cutlass/fp8_groupwise_scaled_gemm_sm90.cu b/src/runtime/contrib/cutlass/fp8_groupwise_scaled_gemm_sm90.cu index dc067038c7a9..3c326e314386 100644 --- a/src/runtime/contrib/cutlass/fp8_groupwise_scaled_gemm_sm90.cu +++ b/src/runtime/contrib/cutlass/fp8_groupwise_scaled_gemm_sm90.cu @@ -66,13 +66,13 @@ void tvm_cutlass_fp8_groupwise_scaled_bmm_sm90(Tensor a, Tensor b, Tensor scales a, b, scales_a, scales_b, workspace, block_size_0, block_size_1, out); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("cutlass.groupwise_scaled_gemm_e4m3fn_e4m3fn", tvm_cutlass_fp8_groupwise_scaled_gemm_sm90) .def("cutlass.groupwise_scaled_bmm_e4m3fn_e4m3fn", tvm_cutlass_fp8_groupwise_scaled_bmm_sm90); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/cutlass/fp8_groupwise_scaled_group_gemm_sm100.cu b/src/runtime/contrib/cutlass/fp8_groupwise_scaled_group_gemm_sm100.cu index 8ac0e0452d57..4f5dd1e1c706 100644 --- a/src/runtime/contrib/cutlass/fp8_groupwise_scaled_group_gemm_sm100.cu +++ b/src/runtime/contrib/cutlass/fp8_groupwise_scaled_group_gemm_sm100.cu @@ -85,11 +85,11 @@ void tvm_fp8_groupwise_scaled_group_gemm_sm100(Tensor a, Tensor b, Tensor scales } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("cutlass.groupwise_scaled_group_gemm_e4m3fn_e4m3fn", tvm_fp8_groupwise_scaled_group_gemm_sm100); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/cutlass/weight_preprocess.cc b/src/runtime/contrib/cutlass/weight_preprocess.cc index 32c30450cf48..56e2b39b8094 100644 --- a/src/runtime/contrib/cutlass/weight_preprocess.cc +++ b/src/runtime/contrib/cutlass/weight_preprocess.cc @@ -35,7 +35,7 @@ namespace runtime { // black box. // // The preprocessing functions are defined in C++, so we need to copy the input weight to CPU. -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("cutlass.ft_preprocess_weight", [](Tensor packed_weight, int sm, bool is_int4) { @@ -58,7 +58,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ out.CopyFromBytes(output_cpu.data(), output_cpu.size()); return out; }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/dnnl/dnnl.cc b/src/runtime/contrib/dnnl/dnnl.cc index 3ae84a782e47..972c61e9436e 100644 --- a/src/runtime/contrib/dnnl/dnnl.cc +++ b/src/runtime/contrib/dnnl/dnnl.cc @@ -349,7 +349,7 @@ extern "C" void dnnl_binary_op(float* data, float* weight, float* out, int algo_ } // DNNL Conv2d single OP -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvm.contrib.dnnl.conv2d", [](ffi::PackedArgs args, ffi::Any* ret) { auto input = args[0].cast(); @@ -383,7 +383,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ p_W_, p_O_, p_G_, p_Ph0_, p_Pw0_, p_Ph1_, p_Pw1_, p_Kh_, p_Kw_, p_Sh_, p_Sw_, attr, channel_last, pre_cast, post_cast); }); -}); +} } // namespace contrib } // namespace runtime diff --git a/src/runtime/contrib/dnnl/dnnl_json_runtime.cc b/src/runtime/contrib/dnnl/dnnl_json_runtime.cc index 3b9304f11c61..f0c47e5639d2 100644 --- a/src/runtime/contrib/dnnl/dnnl_json_runtime.cc +++ b/src/runtime/contrib/dnnl/dnnl_json_runtime.cc @@ -929,12 +929,12 @@ ffi::Module DNNLJSONRuntimeCreate(ffi::String symbol_name, ffi::String graph_jso return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.DNNLJSONRuntimeCreate", DNNLJSONRuntimeCreate) .def("ffi.Module.load_from_bytes.dnnl_json", JSONRuntimeBase::LoadFromBytes); -}); +} } // namespace contrib } // namespace runtime diff --git a/src/runtime/contrib/edgetpu/edgetpu_runtime.cc b/src/runtime/contrib/edgetpu/edgetpu_runtime.cc index 34d335c0e900..4e62659dd30e 100644 --- a/src/runtime/contrib/edgetpu/edgetpu_runtime.cc +++ b/src/runtime/contrib/edgetpu/edgetpu_runtime.cc @@ -69,11 +69,11 @@ ffi::Module EdgeTPURuntimeCreate(const std::string& tflite_model_bytes, Device d return ffi::Module(exec); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "tvm.edgetpu_runtime.create", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = EdgeTPURuntimeCreate(args[0], args[1]); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/hipblas/hipblas.cc b/src/runtime/contrib/hipblas/hipblas.cc index 628ffb5bdf8a..b1b264dea72a 100644 --- a/src/runtime/contrib/hipblas/hipblas.cc +++ b/src/runtime/contrib/hipblas/hipblas.cc @@ -408,7 +408,7 @@ inline void CallBatchGemmEx(ffi::PackedArgs args, ffi::Any* ret, hipblasHandle_t } // matrix multiplication for row major -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.contrib.hipblas.matmul", @@ -455,7 +455,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ CallBatchGemmEx(args, ret, entry_ptr->handle); } }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/hipblas/hipblas_json_runtime.cc b/src/runtime/contrib/hipblas/hipblas_json_runtime.cc index f53f8f7c6a51..45bfabc277cc 100644 --- a/src/runtime/contrib/hipblas/hipblas_json_runtime.cc +++ b/src/runtime/contrib/hipblas/hipblas_json_runtime.cc @@ -146,13 +146,13 @@ ffi::Module HipblasJSONRuntimeCreate(ffi::String symbol_name, ffi::String graph_ return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.HipblasJSONRuntimeCreate", HipblasJSONRuntimeCreate) .def("ffi.Module.load_from_bytes.hipblas_json", JSONRuntimeBase::LoadFromBytes); -}); +} } // namespace contrib } // namespace runtime diff --git a/src/runtime/contrib/miopen/conv_forward.cc b/src/runtime/contrib/miopen/conv_forward.cc index 2c8a70aa6b34..620706250967 100644 --- a/src/runtime/contrib/miopen/conv_forward.cc +++ b/src/runtime/contrib/miopen/conv_forward.cc @@ -35,7 +35,7 @@ namespace miopen { using namespace runtime; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed( @@ -226,7 +226,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ entry_ptr->conv_entry.fwd_algo, &beta, entry_ptr->conv_entry.output_desc, y->data, entry_ptr->conv_entry.workspace, entry_ptr->conv_entry.workspace_size)); }); -}); +} } // namespace miopen } // namespace contrib diff --git a/src/runtime/contrib/miopen/softmax.cc b/src/runtime/contrib/miopen/softmax.cc index 5853cb2a7b11..c5e467626ee8 100644 --- a/src/runtime/contrib/miopen/softmax.cc +++ b/src/runtime/contrib/miopen/softmax.cc @@ -80,7 +80,7 @@ void softmax_impl(ffi::PackedArgs args, ffi::Any* ret, miopenSoftmaxAlgorithm_t entry_ptr->softmax_entry.shape_desc, y->data, alg, mode)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.contrib.miopen.softmax.forward", @@ -90,7 +90,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_packed( "tvm.contrib.miopen.log_softmax.forward", [](ffi::PackedArgs args, ffi::Any* ret) { softmax_impl(args, ret, MIOPEN_SOFTMAX_LOG); }); -}); +} } // namespace miopen } // namespace contrib diff --git a/src/runtime/contrib/mps/conv.mm b/src/runtime/contrib/mps/conv.mm index 2bf38796fd66..92da557160cb 100644 --- a/src/runtime/contrib/mps/conv.mm +++ b/src/runtime/contrib/mps/conv.mm @@ -25,7 +25,7 @@ using namespace runtime; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.contrib.mps.buffer2img", @@ -161,7 +161,7 @@ (*f_img2buf)(&tmp_out, output); }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/mps/gemm.mm b/src/runtime/contrib/mps/gemm.mm index 7f386172f642..b78d8f7d6e51 100644 --- a/src/runtime/contrib/mps/gemm.mm +++ b/src/runtime/contrib/mps/gemm.mm @@ -25,7 +25,7 @@ using namespace runtime; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvm.contrib.mps.matmul", [](ffi::PackedArgs args, ffi::Any* ret) { auto A = args[0].cast(); @@ -95,7 +95,7 @@ [sgemm encodeToCommandBuffer:cb leftMatrix:matrixA rightMatrix:matrixB resultMatrix:matrixC]; [cb commit]; }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/mrvl/mrvl_hw_runtime.cc b/src/runtime/contrib/mrvl/mrvl_hw_runtime.cc index 336367131fc7..bfa2e1889b2e 100644 --- a/src/runtime/contrib/mrvl/mrvl_hw_runtime.cc +++ b/src/runtime/contrib/mrvl/mrvl_hw_runtime.cc @@ -485,12 +485,12 @@ bool MarvellHardwareModuleNode::use_dpdk_cb = false; ml_tvmc_cb MarvellHardwareModuleNode::tvmc_cb_ = {}; ml_dpdk_cb MarvellHardwareModuleNode::dpdk_cb_ = {}; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.mrvl_hw_runtime_create", MarvellHardwareModuleRuntimeCreate) .def("ffi.Module.load_from_bytes.mrvl_hw", MarvellHardwareModuleNode::LoadFromBytes); -}); +} } // namespace contrib } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/mrvl/mrvl_runtime.cc b/src/runtime/contrib/mrvl/mrvl_runtime.cc index 8c1ed354d6f5..1a9ad8c47851 100644 --- a/src/runtime/contrib/mrvl/mrvl_runtime.cc +++ b/src/runtime/contrib/mrvl/mrvl_runtime.cc @@ -157,12 +157,12 @@ ffi::Module MarvellSimulatorModuleRuntimeCreate(const ffi::String& symbol_name, return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.mrvl_runtime_create", MarvellSimulatorModuleRuntimeCreate) .def("ffi.Module.load_from_bytes.mrvl_sim", MarvellSimulatorModuleNode::LoadFromBytes); -}); +} } // namespace contrib } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/msc/tensorrt_runtime.cc b/src/runtime/contrib/msc/tensorrt_runtime.cc index 07b190a2c0be..91e291ce30c1 100644 --- a/src/runtime/contrib/msc/tensorrt_runtime.cc +++ b/src/runtime/contrib/msc/tensorrt_runtime.cc @@ -351,13 +351,13 @@ ffi::Module MSCTensorRTRuntimeCreate(const ffi::String& symbol_name, const ffi:: return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.msc_tensorrt_runtime_create", MSCTensorRTRuntimeCreate) .def("ffi.Module.load_from_bytes.msc_tensorrt", JSONRuntimeBase::LoadFromBytes); -}); +} } // namespace contrib } // namespace runtime diff --git a/src/runtime/contrib/nnapi/nnapi_runtime.cc b/src/runtime/contrib/nnapi/nnapi_runtime.cc index db0f19897bbc..6d3c55513889 100644 --- a/src/runtime/contrib/nnapi/nnapi_runtime.cc +++ b/src/runtime/contrib/nnapi/nnapi_runtime.cc @@ -241,12 +241,12 @@ ffi::Module NNAPIRuntimeCreate(const ffi::String& symbol_name, const ffi::String return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.nnapi_runtime_create", NNAPIRuntimeCreate) .def("ffi.Module.load_from_bytes.nnapi", JSONRuntimeBase::LoadFromBytes); -}); +} } // namespace contrib } // namespace runtime diff --git a/src/runtime/contrib/nvshmem/init.cc b/src/runtime/contrib/nvshmem/init.cc index 9082f43b3966..3471902bc311 100644 --- a/src/runtime/contrib/nvshmem/init.cc +++ b/src/runtime/contrib/nvshmem/init.cc @@ -121,14 +121,14 @@ void NVSHMEMXCumoduleInit(void* cuModule) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.disco.nvshmem.init_nvshmem_uid", InitNVSHMEMUID) .def("runtime.disco.nvshmem.init_nvshmem", InitNVSHMEM) .def("runtime.disco.nvshmem.init_nvshmem_wrapper", InitNVSHMEMWrapper) .def("runtime.nvshmem.cumodule_init", NVSHMEMXCumoduleInit); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/nvshmem/kv_transfer.cu b/src/runtime/contrib/nvshmem/kv_transfer.cu index e225b1a346da..34916a614ae4 100644 --- a/src/runtime/contrib/nvshmem/kv_transfer.cu +++ b/src/runtime/contrib/nvshmem/kv_transfer.cu @@ -330,9 +330,9 @@ int _KVTransferPageToPage(DLTensor* remote_pages, DLTensor* local_pages, return 0; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("nvshmem.KVTransfer", _KVTransfer) .def("nvshmem.KVTransferPageToPage", _KVTransferPageToPage); -}); +} diff --git a/src/runtime/contrib/nvshmem/memory_allocator.cc b/src/runtime/contrib/nvshmem/memory_allocator.cc index 4e742a0792e7..5893d04ac33a 100644 --- a/src/runtime/contrib/nvshmem/memory_allocator.cc +++ b/src/runtime/contrib/nvshmem/memory_allocator.cc @@ -90,20 +90,20 @@ Tensor NVSHMEMEmpty(ffi::Shape shape, DataType dtype, Device device) { return NVSHMEMAllocator::Global()->Empty(shape, dtype, UseDefaultDeviceIfNone(device)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("runtime.disco.nvshmem.empty", NVSHMEMEmpty); -}); +} void NVSHMEMFinalize() { NVSHMEMAllocator::Global()->Clear(); nvshmem_finalize(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("runtime.disco.nvshmem.finalize_nvshmem", NVSHMEMFinalize); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/papi/papi.cc b/src/runtime/contrib/papi/papi.cc index 2a27c7f35b41..91af80de3794 100644 --- a/src/runtime/contrib/papi/papi.cc +++ b/src/runtime/contrib/papi/papi.cc @@ -286,13 +286,13 @@ MetricCollector CreatePAPIMetricCollector( return PAPIMetricCollector(metrics); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("runtime.profiling.PAPIMetricCollector", [](ffi::Map> metrics) { return PAPIMetricCollector(metrics); }); -}); +} } // namespace profiling } // namespace runtime diff --git a/src/runtime/contrib/random/random.cc b/src/runtime/contrib/random/random.cc index b7ca1f8fd705..f444ab07409e 100644 --- a/src/runtime/contrib/random/random.cc +++ b/src/runtime/contrib/random/random.cc @@ -70,7 +70,7 @@ RandomThreadLocalEntry* RandomThreadLocalEntry::ThreadLocal() { return RandomThreadLocalStore::Get(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.contrib.random.randint", @@ -142,7 +142,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ RandomThreadLocalEntry* entry = RandomThreadLocalEntry::ThreadLocal(); entry->random_engine.RandomFillForMeasure(out); }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/rocblas/rocblas.cc b/src/runtime/contrib/rocblas/rocblas.cc index be3c49e12196..73ec8c1b0f95 100644 --- a/src/runtime/contrib/rocblas/rocblas.cc +++ b/src/runtime/contrib/rocblas/rocblas.cc @@ -66,7 +66,7 @@ struct RocBlasThreadEntry { typedef dmlc::ThreadLocalStore RocBlasThreadStore; // matrix multiplication for row major -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed( @@ -145,6 +145,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ RocBlasThreadStore::Get()->handle, roc_trans_B, roc_trans_A, N, M, K, &alpha, B_ptr, ldb, K * N, A_ptr, lda, M * K, &beta, C_ptr, ldc, M * N, batch_size)); }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/sort/sort.cc b/src/runtime/contrib/sort/sort.cc index de67555b0a72..afbac3a84701 100644 --- a/src/runtime/contrib/sort/sort.cc +++ b/src/runtime/contrib/sort/sort.cc @@ -576,12 +576,12 @@ void RegisterTopk() { }); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { RegisterArgsortNMS(); RegisterArgsort(); RegisterSort(); RegisterTopk(); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/tensorrt/tensorrt_runtime.cc b/src/runtime/contrib/tensorrt/tensorrt_runtime.cc index 8620988f8465..f89f0abe2acb 100644 --- a/src/runtime/contrib/tensorrt/tensorrt_runtime.cc +++ b/src/runtime/contrib/tensorrt/tensorrt_runtime.cc @@ -525,12 +525,12 @@ ffi::Module TensorRTRuntimeCreate(const ffi::String& symbol_name, const ffi::Str return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.tensorrt_runtime_create", TensorRTRuntimeCreate) .def("ffi.Module.load_from_bytes.tensorrt", JSONRuntimeBase::LoadFromBytes); -}); +} } // namespace contrib } // namespace runtime diff --git a/src/runtime/contrib/tflite/tflite_runtime.cc b/src/runtime/contrib/tflite/tflite_runtime.cc index 8ddaafbd6cb0..9029a62f8da0 100644 --- a/src/runtime/contrib/tflite/tflite_runtime.cc +++ b/src/runtime/contrib/tflite/tflite_runtime.cc @@ -185,7 +185,7 @@ ffi::Module TFLiteRuntimeCreate(const std::string& tflite_model_bytes, Device de return ffi::Module(exec); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.tflite_runtime.create", @@ -193,6 +193,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ *rv = TFLiteRuntimeCreate(args[0].cast(), args[1].cast()); }) .def("target.runtime.tflite", TFLiteRuntimeCreate); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/thrust/thrust.cu b/src/runtime/contrib/thrust/thrust.cu index 7eede1b65485..bf0a176862c1 100644 --- a/src/runtime/contrib/thrust/thrust.cu +++ b/src/runtime/contrib/thrust/thrust.cu @@ -238,7 +238,7 @@ void thrust_sort_common(DLTensor* input, DLTensor* values_out, DLTensor* indices } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvm.contrib.thrust.sort", [](ffi::PackedArgs args, ffi::Any* ret) { ICHECK_GE(args.size(), 4); @@ -258,7 +258,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ thrust_sort_common(input, values_out, indices_out, is_ascend, n_values, data_dtype, out_dtype, workspace); }); -}); +} template void thrust_stable_sort_by_key(DLTensor* keys_in, DLTensor* values_in, DLTensor* keys_out, @@ -287,7 +287,7 @@ void thrust_stable_sort_by_key(DLTensor* keys_in, DLTensor* values_in, DLTensor* thrust::stable_sort_by_key(policy, keys_out_ptr, keys_out_ptr + size, values_out_ptr); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "tvm.contrib.thrust.stable_sort_by_key", [](ffi::PackedArgs args, ffi::Any* ret) { @@ -348,7 +348,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ LOG(FATAL) << "Unsupported key dtype: " << key_dtype; } }); -}); +} template void thrust_scan(DLTensor* data, DLTensor* output, bool exclusive, DLTensor* workspace) { @@ -405,7 +405,7 @@ void thrust_scan(DLTensor* data, DLTensor* output, bool exclusive, DLTensor* wor } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "tvm.contrib.thrust.sum_scan", [](ffi::PackedArgs args, ffi::Any* ret) { @@ -484,7 +484,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ << ". Supported input dtypes are bool, int32, int64, float32, and float64"; } }); -}); +} } // namespace contrib } // namespace tvm diff --git a/src/runtime/contrib/vllm/attention_kernels.cu b/src/runtime/contrib/vllm/attention_kernels.cu index ce3205383215..1472cd73cbb9 100644 --- a/src/runtime/contrib/vllm/attention_kernels.cu +++ b/src/runtime/contrib/vllm/attention_kernels.cu @@ -735,7 +735,7 @@ void single_query_cached_kv_attention_v2( } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tvm.contrib.vllm.single_query_cached_kv_attention", @@ -760,17 +760,17 @@ TVM_FFI_STATIC_INIT_BLOCK({ exp_sums, max_logits, tmp_out, out); } }); -}); +} // Expose for testing -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tvm.contrib.vllm.single_query_cached_kv_attention_v1", single_query_cached_kv_attention_v1) .def("tvm.contrib.vllm.single_query_cached_kv_attention_v2", single_query_cached_kv_attention_v2); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/contrib/vllm/cache_alloc.cc b/src/runtime/contrib/vllm/cache_alloc.cc index e5814df8afd5..266138406cb9 100644 --- a/src/runtime/contrib/vllm/cache_alloc.cc +++ b/src/runtime/contrib/vllm/cache_alloc.cc @@ -49,10 +49,10 @@ ffi::Array AllocateKVCache(int head_size, int num_layers, int num_heads, return cache; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tvm.contrib.vllm.allocate_kv_cache", AllocateKVCache); -}); +} } // namespace vllm } // namespace runtime diff --git a/src/runtime/contrib/vllm/cache_kernels.cu b/src/runtime/contrib/vllm/cache_kernels.cu index d97c9f8a7aa1..5ddf18e48208 100644 --- a/src/runtime/contrib/vllm/cache_kernels.cu +++ b/src/runtime/contrib/vllm/cache_kernels.cu @@ -130,7 +130,7 @@ __global__ void copy_blocks_kernel(int64_t* key_cache_ptrs, int64_t* value_cache namespace tvm { namespace runtime { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tvm.contrib.vllm.reshape_and_cache", @@ -229,7 +229,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ static_cast(value_cache_ptrs_gpu->data), static_cast(block_mapping_gpu->data), numel_per_block); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/cpu_device_api.cc b/src/runtime/cpu_device_api.cc index e9b16d003e3a..d9299832ddb3 100644 --- a/src/runtime/cpu_device_api.cc +++ b/src/runtime/cpu_device_api.cc @@ -151,12 +151,12 @@ void CPUDeviceAPI::FreeWorkspace(Device dev, void* data) { dmlc::ThreadLocalStore::Get()->FreeWorkspace(dev, data); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("device_api.cpu", [](ffi::PackedArgs args, ffi::Any* rv) { DeviceAPI* ptr = CPUDeviceAPI::Global(); *rv = static_cast(ptr); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/cuda/cuda_device_api.cc b/src/runtime/cuda/cuda_device_api.cc index f8ec539cc0dc..bfd5f7cca98a 100644 --- a/src/runtime/cuda/cuda_device_api.cc +++ b/src/runtime/cuda/cuda_device_api.cc @@ -280,7 +280,7 @@ CUDAThreadEntry::CUDAThreadEntry() : pool(kDLCUDA, CUDADeviceAPI::Global()) {} CUDAThreadEntry* CUDAThreadEntry::ThreadLocal() { return CUDAThreadStore::Get(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("device_api.cuda", @@ -292,7 +292,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ DeviceAPI* ptr = CUDADeviceAPI::Global(); *rv = static_cast(ptr); }); -}); +} class CUDATimerNode : public TimerNode { public: @@ -331,11 +331,11 @@ class CUDATimerNode : public TimerNode { TVMStreamHandle stream_; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("profiling.timer.cuda", [](Device dev) { return Timer(ffi::make_object()); }); -}); +} TVM_DLL ffi::String GetCudaFreeMemory() { size_t free_mem, total_mem; @@ -346,7 +346,7 @@ TVM_DLL ffi::String GetCudaFreeMemory() { return ss.str(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.GetCudaFreeMemory", GetCudaFreeMemory) @@ -357,7 +357,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ CUDA_CALL(cudaGetDevice(&device_id)); return static_cast(TVMFFIEnvGetStream(kDLCUDA, device_id)); }); -}); +} TVM_DLL int GetCudaDeviceCount() { int count; @@ -365,10 +365,10 @@ TVM_DLL int GetCudaDeviceCount() { return count; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("runtime.GetCudaDeviceCount", GetCudaDeviceCount); -}); +} #if (CUDA_VERSION >= 12000) /** @@ -394,7 +394,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ * \param l2_promotion_kind (int): An integer corresponding to the CUtensorMapL2promotion enum. * \param oob_fill_kind (int): An integer corresponding to the CUtensorMapFloatOOBfill enum. */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("runtime.cuTensorMapEncodeTiled", [](ffi::PackedArgs args, ffi::Any* rv) { @@ -578,7 +578,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ CHECK_EQ(res, CUDA_SUCCESS) << "Error in cuTensorMapEncodeTiled: " << errstr; } }); -}); +} #endif // CUDA_VERSION >= 12000 } // namespace runtime diff --git a/src/runtime/cuda/cuda_module.cc b/src/runtime/cuda/cuda_module.cc index 9673dfa169fd..3fee6b55f2e5 100644 --- a/src/runtime/cuda/cuda_module.cc +++ b/src/runtime/cuda/cuda_module.cc @@ -305,12 +305,12 @@ ffi::Module CUDAModuleLoadFromBytes(const ffi::Bytes& bytes) { return CUDAModuleCreate(data, fmt, fmap, std::string()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ffi.Module.load_from_file.cuda", CUDAModuleLoadFile) .def("ffi.Module.load_from_file.ptx", CUDAModuleLoadFile) .def("ffi.Module.load_from_bytes.cuda", CUDAModuleLoadFromBytes); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/cuda/l2_cache_flush.cc b/src/runtime/cuda/l2_cache_flush.cc index d02f4efdb900..b69ecc71882c 100644 --- a/src/runtime/cuda/l2_cache_flush.cc +++ b/src/runtime/cuda/l2_cache_flush.cc @@ -34,7 +34,7 @@ typedef dmlc::ThreadLocalStore L2FlushStore; L2Flush* L2Flush::ThreadLocal() { return L2FlushStore::Get(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("l2_cache_flush_cuda", [](ffi::PackedArgs args, ffi::Any* rv) { ICHECK(L2Flush::ThreadLocal() != nullptr) << "L2Flush::ThreadLocal do not exist."; @@ -43,7 +43,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ cudaStream_t stream = static_cast(TVMFFIEnvGetStream(kDLCUDA, device_id)); L2Flush::ThreadLocal()->Flush(stream); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/device_api.cc b/src/runtime/device_api.cc index 96d370dfe2e5..f8910f6e8800 100644 --- a/src/runtime/device_api.cc +++ b/src/runtime/device_api.cc @@ -175,7 +175,7 @@ TVMStreamHandle DeviceAPI::GetCurrentStream(Device dev) { void DeviceAPI::SyncStreamFromTo(Device dev, TVMStreamHandle event_src, TVMStreamHandle event_dst) { } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.Device_StreamCreate", @@ -198,10 +198,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ DeviceAPIManager::Get(dev)->SyncStreamFromTo(dev, reinterpret_cast(src), reinterpret_cast(dst)); }); -}); +} // set device api -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed(tvm::runtime::symbol::tvm_set_device, @@ -235,7 +235,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ dev.device_id = device_id; DeviceAPIManager::Get(dev)->SetStream(dev, stream); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/disco/builtin.cc b/src/runtime/disco/builtin.cc index b88c9a36ad5f..8584d15c5e04 100644 --- a/src/runtime/disco/builtin.cc +++ b/src/runtime/disco/builtin.cc @@ -125,7 +125,7 @@ void SyncWorker() { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.disco.load_vm_module", LoadVMModule) @@ -169,7 +169,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ "tvm.runtime.threading.set_current_thread_affinity"); f_set_thread_affinity(ffi::Shape{cpu_ids[worker_id]}); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/disco/cuda_ipc/cuda_ipc_memory.cc b/src/runtime/disco/cuda_ipc/cuda_ipc_memory.cc index a02ab2a84c3f..7dc55c0b4b7c 100644 --- a/src/runtime/disco/cuda_ipc/cuda_ipc_memory.cc +++ b/src/runtime/disco/cuda_ipc/cuda_ipc_memory.cc @@ -213,13 +213,13 @@ memory::Storage IPCAllocStorage(ffi::Shape buffer_shape, DLDataType dtype_hint) return storage; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.disco.cuda_ipc.alloc_storage", IPCAllocStorage) .def("runtime.disco.cuda_ipc.cuda_ipc_memory_allocator_clear", []() { CUDAIPCMemoryAllocator::Global()->Clear(); }); -}); +} /******************** CUDAIPCMemoryObj ********************/ diff --git a/src/runtime/disco/cuda_ipc/custom_allreduce.cc b/src/runtime/disco/cuda_ipc/custom_allreduce.cc index f1293d4a4606..060a098a9d63 100644 --- a/src/runtime/disco/cuda_ipc/custom_allreduce.cc +++ b/src/runtime/disco/cuda_ipc/custom_allreduce.cc @@ -113,10 +113,10 @@ void CustomAllReduce(DLTensor* send, int strategy, DLTensor* recv) { ctx->GetDefaultStream()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("runtime.disco.cuda_ipc.custom_allreduce", CustomAllReduce); -}); +} } // namespace cuda_ipc } // namespace nccl diff --git a/src/runtime/disco/distributed/socket_session.cc b/src/runtime/disco/distributed/socket_session.cc index a2a8697385dc..b1845bdcfede 100644 --- a/src/runtime/disco/distributed/socket_session.cc +++ b/src/runtime/disco/distributed/socket_session.cc @@ -293,10 +293,10 @@ void RemoteSocketSessionEntryPoint(const ffi::String& server_host, int server_po proxy.MainLoop(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("runtime.disco.RemoteSocketSession", RemoteSocketSessionEntryPoint); -}); +} Session SocketSession(int num_nodes, int num_workers_per_node, int num_groups, const ffi::String& host, int port) { @@ -305,7 +305,7 @@ Session SocketSession(int num_nodes, int num_workers_per_node, int num_groups, return Session(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.disco.SocketSession", SocketSession) @@ -319,7 +319,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ worker->worker_id = worker->worker_id + node_id * num_workers_per_node; worker->num_workers = num_nodes * num_workers_per_node; }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/disco/loader.cc b/src/runtime/disco/loader.cc index 352b71c5a4d0..35fbf8abbb6f 100644 --- a/src/runtime/disco/loader.cc +++ b/src/runtime/disco/loader.cc @@ -402,7 +402,7 @@ ffi::Array ShardLoaderObj::LoadAllPresharded() const { return params; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.disco.ShardLoader", ShardLoaderObj::Create) @@ -441,7 +441,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ << "TypeError: Expected ShardLoaderObj, but gets: " << loader_obj->GetTypeKey(); return loader->LoadParamOnWorker0(param_index); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/disco/nccl/nccl.cc b/src/runtime/disco/nccl/nccl.cc index c9207d92d2d0..2eb0c3348bd5 100644 --- a/src/runtime/disco/nccl/nccl.cc +++ b/src/runtime/disco/nccl/nccl.cc @@ -327,7 +327,7 @@ void SyncWorker() { StreamSynchronize(stream); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.disco.compiled_ccl", []() -> ffi::String { return TVM_DISCO_CCL_NAME; }) @@ -372,7 +372,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ tvm::runtime::nccl::RecvFromWorker(buffer, 2); } }); -}); +} } // namespace nccl } // namespace runtime diff --git a/src/runtime/disco/process_session.cc b/src/runtime/disco/process_session.cc index 4a86055ac274..aca1fef90c94 100644 --- a/src/runtime/disco/process_session.cc +++ b/src/runtime/disco/process_session.cc @@ -192,12 +192,12 @@ void WorkerProcess(int worker_id, int num_workers, int num_group, int64_t read_f worker.MainLoop(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.disco.SessionProcess", Session::ProcessSession) .def("runtime.disco.WorkerProcess", WorkerProcess); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/disco/session.cc b/src/runtime/disco/session.cc index 4f2ffb3d3f65..ab8505d169db 100644 --- a/src/runtime/disco/session.cc +++ b/src/runtime/disco/session.cc @@ -30,7 +30,7 @@ struct SessionObj::FFI { } }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.disco.SessionThreaded", Session::ThreadedSession) @@ -48,7 +48,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ *rv = SessionObj::FFI::CallWithPacked(self, args.Slice(1)); }) .def_method("runtime.disco.SessionShutdown", &SessionObj::Shutdown); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/file_utils.cc b/src/runtime/file_utils.cc index 63e02049bd82..b3733ee6fdff 100644 --- a/src/runtime/file_utils.cc +++ b/src/runtime/file_utils.cc @@ -251,7 +251,7 @@ std::string SaveParams(const ffi::Map& params) { return bytes; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.SaveParams", @@ -269,7 +269,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ tvm::runtime::SimpleBinaryFileStream strm(path, "rb"); return LoadParams(&strm); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/hexagon/hexagon_common.cc b/src/runtime/hexagon/hexagon_common.cc index 05306c24010b..61c7e4972ba0 100644 --- a/src/runtime/hexagon/hexagon_common.cc +++ b/src/runtime/hexagon/hexagon_common.cc @@ -53,11 +53,11 @@ class HexagonTimerNode : public TimerNode { uint64_t start, end; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("profiling.timer.hexagon", [](Device dev) { return Timer(ffi::make_object()); }); -}); +} } // namespace hexagon namespace { @@ -88,14 +88,14 @@ void LogMessageImpl(const std::string& file, int lineno, int level, const std::s } } // namespace detail -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "ffi.Module.load_from_file.hexagon", [](ffi::PackedArgs args, ffi::Any* rv) { auto floader = tvm::ffi::Function::GetGlobalRequired("ffi.Module.load_from_file.so"); *rv = floader(args[0].cast(), "so"); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/hexagon/hexagon_device_api.cc b/src/runtime/hexagon/hexagon_device_api.cc index cd6d55b3b66b..15ee1ed52a8b 100644 --- a/src/runtime/hexagon/hexagon_device_api.cc +++ b/src/runtime/hexagon/hexagon_device_api.cc @@ -191,7 +191,7 @@ void HexagonDeviceAPI::CopyDataFromTo(const void* from, size_t from_offset, void memcpy(static_cast(to) + to_offset, static_cast(from) + from_offset, size); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("device_api.hexagon.dma_copy_dltensor", @@ -309,7 +309,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ DeviceAPI* ptr = HexagonDeviceAPI::Global(); *rv = static_cast(ptr); }); -}); +} } // namespace hexagon } // namespace runtime diff --git a/src/runtime/hexagon/rpc/android/session.cc b/src/runtime/hexagon/rpc/android/session.cc index 31fed010a3de..55eee5df27f0 100644 --- a/src/runtime/hexagon/rpc/android/session.cc +++ b/src/runtime/hexagon/rpc/android/session.cc @@ -110,7 +110,7 @@ class HexagonTransportChannel : public RPCChannel { remote_handle64 _handle = AEE_EUNKNOWN; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "tvm.contrib.hexagon.create_hexagon_session", [](ffi::PackedArgs args, ffi::Any* rv) { @@ -128,7 +128,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ auto sess = CreateClientSession(ep); *rv = CreateRPCSessionModule(sess); }); -}); +} } // namespace hexagon } // namespace runtime diff --git a/src/runtime/hexagon/rpc/hexagon/rpc_server.cc b/src/runtime/hexagon/rpc/hexagon/rpc_server.cc index 96c45bfdf0d1..d9c2e647aea2 100644 --- a/src/runtime/hexagon/rpc/hexagon/rpc_server.cc +++ b/src/runtime/hexagon/rpc/hexagon/rpc_server.cc @@ -328,7 +328,7 @@ __attribute__((weak)) void _Get_eh_data() {} __attribute__((weak)) void _Parse_fde_instr() {} } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.hexagon.load_module", @@ -349,7 +349,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ *rv = false; } }); -}); +} void SaveBinaryToFile(const std::string& file_name, const std::string& data) { std::ofstream fs(file_name, std::ios::out | std::ios::binary); @@ -357,7 +357,7 @@ void SaveBinaryToFile(const std::string& file_name, const std::string& data) { fs.write(&data[0], data.length()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvm.rpc.server.upload", [](tvm::ffi::PackedArgs args, tvm::ffi::Any* rv) { @@ -365,4 +365,4 @@ TVM_FFI_STATIC_INIT_BLOCK({ auto data = args[1].cast(); SaveBinaryToFile(file_name, data); }); -}); +} diff --git a/src/runtime/hexagon/rpc/simulator/rpc_server.cc b/src/runtime/hexagon/rpc/simulator/rpc_server.cc index d511b0038f21..c3cec3039221 100644 --- a/src/runtime/hexagon/rpc/simulator/rpc_server.cc +++ b/src/runtime/hexagon/rpc/simulator/rpc_server.cc @@ -332,7 +332,7 @@ __attribute__((weak)) void _Get_eh_data() {} __attribute__((weak)) void _Parse_fde_instr() {} } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.hexagon.load_module", @@ -353,7 +353,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ *rv = false; } }); -}); +} void SaveBinaryToFile(const std::string& file_name, const std::string& data) { std::ofstream fs(file_name, std::ios::out | std::ios::binary); @@ -361,7 +361,7 @@ void SaveBinaryToFile(const std::string& file_name, const std::string& data) { fs.write(&data[0], data.length()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvm.rpc.server.upload", [](tvm::ffi::PackedArgs args, tvm::ffi::Any* rv) { @@ -369,4 +369,4 @@ TVM_FFI_STATIC_INIT_BLOCK({ auto data = args[1].cast(); SaveBinaryToFile(file_name, data); }); -}); +} diff --git a/src/runtime/hexagon/rpc/simulator/session.cc b/src/runtime/hexagon/rpc/simulator/session.cc index 687ff6e79a16..d7a9ade7234a 100644 --- a/src/runtime/hexagon/rpc/simulator/session.cc +++ b/src/runtime/hexagon/rpc/simulator/session.cc @@ -1370,7 +1370,7 @@ std::optional SimulatorRPCChannel::to_nullptr(const detail::Mayb .Default(std::nullopt); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "tvm.contrib.hexagon.create_hexagon_session", [](ffi::PackedArgs args, ffi::Any* rv) { @@ -1385,7 +1385,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ std::shared_ptr session = CreateClientSession(endpoint); *rv = CreateRPCSessionModule(session); }); -}); +} } // namespace hexagon } // namespace runtime diff --git a/src/runtime/memory/memory_manager.cc b/src/runtime/memory/memory_manager.cc index 239d9e131ea6..db4d33be3789 100644 --- a/src/runtime/memory/memory_manager.cc +++ b/src/runtime/memory/memory_manager.cc @@ -265,10 +265,10 @@ void Allocator::Clear() { // Pooled allocator will override this method. } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.memory_manager.clear", MemoryManager::Clear); -}); +} } // namespace memory } // namespace runtime diff --git a/src/runtime/metal/metal_device_api.mm b/src/runtime/metal/metal_device_api.mm index 2fccb3bb8d81..2a3cd558f2a5 100644 --- a/src/runtime/metal/metal_device_api.mm +++ b/src/runtime/metal/metal_device_api.mm @@ -352,7 +352,7 @@ int GetWarpSize(id dev) { MetalThreadEntry* MetalThreadEntry::ThreadLocal() { return MetalThreadStore::Get(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("device_api.metal", @@ -362,7 +362,7 @@ int GetWarpSize(id dev) { }) .def("metal.ResetGlobalState", []() { MetalWorkspace::Global()->ReinitializeDefaultStreams(); }); -}); +} class MetalTimerNode : public TimerNode { public: @@ -392,11 +392,11 @@ virtual void Stop() { MTLTimestamp stop_gpu_time_; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("profiling.timer.metal", [](Device dev) { return Timer(ffi::make_object(dev)); }); -}); +} } // namespace metal } // namespace runtime diff --git a/src/runtime/metal/metal_module.mm b/src/runtime/metal/metal_module.mm index e037717bcc57..9c0aa96257d4 100644 --- a/src/runtime/metal/metal_module.mm +++ b/src/runtime/metal/metal_module.mm @@ -290,7 +290,7 @@ void operator()(ffi::PackedArgs args, ffi::Any* rv, const ArgUnion64* pack_args) return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("runtime.module.create_metal_module", [](ffi::Map smap, std::string fmap_json, @@ -304,7 +304,7 @@ void operator()(ffi::PackedArgs args, ffi::Any* rv, const ArgUnion64* pack_args) smap.begin(), smap.end()), fmap, fmt, source); }); -}); +} ffi::Module MetalModuleLoadFromBytes(const ffi::Bytes& bytes) { dmlc::MemoryFixedSizeStream ms(const_cast(bytes.data()), bytes.size()); @@ -324,9 +324,9 @@ void operator()(ffi::PackedArgs args, ffi::Any* rv, const ArgUnion64* pack_args) return MetalModuleCreate(smap, fmap, fmt, ""); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ffi.Module.load_from_bytes.metal", MetalModuleLoadFromBytes); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/module.cc b/src/runtime/module.cc index 97238ec56b79..c782cb96c09f 100644 --- a/src/runtime/module.cc +++ b/src/runtime/module.cc @@ -72,7 +72,7 @@ bool RuntimeEnabled(const ffi::String& target_str) { TVM_FFI_CHECK_SAFE_CALL( \ TVMFFIEnvModRegisterContextSymbol("__" #FuncName, reinterpret_cast(FuncName))) -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; // Initialize the functions @@ -85,7 +85,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ TVM_INIT_CONTEXT_FUNC(TVMBackendParallelBarrier); refl::GlobalDef().def("runtime.RuntimeEnabled", RuntimeEnabled); -}); +} #undef TVM_INIT_CONTEXT_FUNC diff --git a/src/runtime/opencl/opencl_device_api.cc b/src/runtime/opencl/opencl_device_api.cc index 32ca168d314b..8b6fba24988e 100644 --- a/src/runtime/opencl/opencl_device_api.cc +++ b/src/runtime/opencl/opencl_device_api.cc @@ -761,7 +761,7 @@ void OpenCLWorkspace::Init(const std::string& type_key, const std::string& devic initialized_ = true; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("device_api.opencl.alloc_nd", @@ -809,13 +809,13 @@ TVM_FFI_STATIC_INIT_BLOCK({ DeviceAPI* ptr = OpenCLWorkspace::Global(); *rv = static_cast(ptr); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("profiling.timer.opencl", [](Device dev) { return Timer(ffi::make_object(dev)); }); -}); +} class OpenCLPooledAllocator final : public memory::PooledAllocator { public: @@ -897,13 +897,13 @@ class OpenCLPooledAllocator final : public memory::PooledAllocator { } }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("DeviceAllocator.opencl", [](ffi::PackedArgs args, ffi::Any* rv) { Allocator* alloc = new OpenCLPooledAllocator(); *rv = static_cast(alloc); }); -}); +} } // namespace cl size_t OpenCLTimerNode::count_timer_execs = 0; diff --git a/src/runtime/opencl/opencl_module.cc b/src/runtime/opencl/opencl_module.cc index 169f9408c38b..3f9dadbb3af1 100644 --- a/src/runtime/opencl/opencl_module.cc +++ b/src/runtime/opencl/opencl_module.cc @@ -395,12 +395,12 @@ ffi::Module OpenCLModuleLoadFromBytes(const ffi::Bytes& bytes) { return OpenCLModuleCreate(data, fmt, fmap, std::string()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ffi.Module.load_from_file.cl", OpenCLModuleLoadFile) .def("ffi.Module.load_from_file.clbin", OpenCLModuleLoadFile) .def("ffi.Module.load_from_bytes.opencl", OpenCLModuleLoadFromBytes); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/profiling.cc b/src/runtime/profiling.cc index 733673132044..6e25fb5d34cd 100644 --- a/src/runtime/profiling.cc +++ b/src/runtime/profiling.cc @@ -78,11 +78,11 @@ class CPUTimerNode : public TimerNode { std::chrono::duration duration_; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("profiling.timer.cpu", [](Device dev) { return Timer(ffi::make_object()); }); -}); +} // keep track of which timers are not defined but we have already warned about std::set seen_devices; @@ -111,10 +111,10 @@ Timer Timer::Start(Device dev) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("profiling.start_timer", Timer::Start); -}); +} namespace profiling { @@ -782,7 +782,7 @@ Report Report::FromJSON(ffi::String json) { return Report(calls, device_metrics, configuration); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("runtime.profiling.AsTable", &ReportNode::AsTable) @@ -790,7 +790,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("runtime.profiling.AsJSON", [](Report n) { return n->AsJSON(); }) .def("runtime.profiling.FromJSON", Report::FromJSON) .def("runtime.profiling.DeviceWrapper", [](Device dev) { return DeviceWrapper(dev); }); -}); +} ffi::Function ProfileFunction(ffi::Module mod, std::string func_name, int device_type, int device_id, int warmup_iters, @@ -840,7 +840,7 @@ ffi::Function ProfileFunction(ffi::Module mod, std::string func_name, int device }); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "runtime.profiling.ProfileFunction", @@ -855,7 +855,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return ProfileFunction(mod, func_name, device_type, device_id, warmup_iters, collectors); } }); -}); +} ffi::Function WrapTimeEvaluator(ffi::Function pf, Device dev, int number, int repeat, int min_repeat_ms, int limit_zero_time_iterations, @@ -922,7 +922,7 @@ ffi::Function WrapTimeEvaluator(ffi::Function pf, Device dev, int number, int re return ffi::Function::FromPacked(ftimer); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.profiling.Report", @@ -939,7 +939,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ [](double duration) { return ObjectRef(ffi::make_object(duration)); }) .def("runtime.profiling.Ratio", [](double ratio) { return ObjectRef(ffi::make_object(ratio)); }); -}); +} } // namespace profiling } // namespace runtime diff --git a/src/runtime/rocm/rocm_device_api.cc b/src/runtime/rocm/rocm_device_api.cc index 2ea9727b8b53..016169653552 100644 --- a/src/runtime/rocm/rocm_device_api.cc +++ b/src/runtime/rocm/rocm_device_api.cc @@ -245,7 +245,7 @@ ROCMThreadEntry::ROCMThreadEntry() : pool(kDLROCM, ROCMDeviceAPI::Global()) {} ROCMThreadEntry* ROCMThreadEntry::ThreadLocal() { return ROCMThreadStore::Get(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("device_api.rocm", @@ -257,7 +257,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ DeviceAPI* ptr = ROCMDeviceAPI::Global(); *rv = static_cast(ptr); }); -}); +} class ROCMTimerNode : public TimerNode { public: @@ -294,7 +294,7 @@ class ROCMTimerNode : public TimerNode { TVMStreamHandle stream_; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("profiling.timer.rocm", @@ -304,7 +304,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ROCM_CALL(hipGetDevice(&device_id)); return static_cast(TVMFFIEnvGetStream(kDLROCM, device_id)); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/rocm/rocm_module.cc b/src/runtime/rocm/rocm_module.cc index f8f7ed673f07..ca1a47400bc1 100644 --- a/src/runtime/rocm/rocm_module.cc +++ b/src/runtime/rocm/rocm_module.cc @@ -238,13 +238,13 @@ ffi::Module ROCMModuleLoadFromBytes(const ffi::Bytes& bytes) { return ROCMModuleCreate(data, fmt, fmap, std::string(), std::string()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ffi.Module.load_from_bytes.hsaco", ROCMModuleLoadFromBytes) .def("ffi.Module.load_from_bytes.hip", ROCMModuleLoadFromBytes) .def("ffi.Module.load_from_file.hsaco", ROCMModuleLoadFile) .def("ffi.Module.load_from_file.hip", ROCMModuleLoadFile); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/rpc/rpc_device_api.cc b/src/runtime/rpc/rpc_device_api.cc index 2bddaff1a504..88e01255d82a 100644 --- a/src/runtime/rpc/rpc_device_api.cc +++ b/src/runtime/rpc/rpc_device_api.cc @@ -151,13 +151,13 @@ class RPCDeviceAPI final : public DeviceAPI { } }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("device_api.rpc", [](ffi::PackedArgs args, ffi::Any* rv) { static RPCDeviceAPI inst; DeviceAPI* ptr = &inst; *rv = static_cast(ptr); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/rpc/rpc_event_impl.cc b/src/runtime/rpc/rpc_event_impl.cc index abf635020afe..4eefb2b2b978 100644 --- a/src/runtime/rpc/rpc_event_impl.cc +++ b/src/runtime/rpc/rpc_event_impl.cc @@ -45,9 +45,9 @@ ffi::Function CreateEventDrivenServer(ffi::Function fsend, std::string name, }); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("rpc.CreateEventDrivenServer", CreateEventDrivenServer); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/rpc/rpc_local_session.cc b/src/runtime/rpc/rpc_local_session.cc index b000e3c01956..2cfeacfcd71f 100644 --- a/src/runtime/rpc/rpc_local_session.cc +++ b/src/runtime/rpc/rpc_local_session.cc @@ -149,11 +149,11 @@ DeviceAPI* LocalSession::GetDeviceAPI(Device dev, bool allow_missing) { return DeviceAPI::Get(dev, allow_missing); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("rpc.LocalSession", []() { return CreateRPCSessionModule(std::make_shared()); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/rpc/rpc_module.cc b/src/runtime/rpc/rpc_module.cc index 441c73989526..a90c69c63c8b 100644 --- a/src/runtime/rpc/rpc_module.cc +++ b/src/runtime/rpc/rpc_module.cc @@ -393,7 +393,7 @@ inline void CPUCacheFlush(int begin_index, const ffi::PackedArgs& args) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.RPCTimeEvaluator", @@ -443,10 +443,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ }) .def_packed("cache_flush_cpu_non_first_arg", [](ffi::PackedArgs args, ffi::Any* rv) { CPUCacheFlush(1, args); }); -}); +} // server function registration. -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tvm.rpc.server.ImportModule", @@ -455,10 +455,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ [](ffi::Module parent, std::string name, bool query_imports) { return parent->GetFunction(name, query_imports); }); -}); +} // functions to access an RPC module. -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("rpc.LoadRemoteModule", @@ -486,7 +486,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return TensorFromRemoteOpaqueHandle(RPCModuleGetSession(mod), remote_array, template_tensor, dev, tensor_handle); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/rpc/rpc_pipe_impl.cc b/src/runtime/rpc/rpc_pipe_impl.cc index 22619289d053..0bc608ccc253 100644 --- a/src/runtime/rpc/rpc_pipe_impl.cc +++ b/src/runtime/rpc/rpc_pipe_impl.cc @@ -113,7 +113,7 @@ ffi::Module CreatePipeClient(std::vector cmd) { return CreateRPCSessionModule(CreateClientSession(endpt)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("rpc.CreatePipeClient", [](ffi::PackedArgs args, ffi::Any* rv) { std::vector cmd; @@ -122,7 +122,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } *rv = CreatePipeClient(cmd); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/rpc/rpc_server_env.cc b/src/runtime/rpc/rpc_server_env.cc index 52d04a72631f..c8e7a4ee81c9 100644 --- a/src/runtime/rpc/rpc_server_env.cc +++ b/src/runtime/rpc/rpc_server_env.cc @@ -36,7 +36,7 @@ std::string RPCGetPath(const std::string& name) { return (*f)(name).cast(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvm.rpc.server.upload", @@ -57,7 +57,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ std::string file_name = RPCGetPath(args[0].cast()); RemoveFile(file_name); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/rpc/rpc_socket_impl.cc b/src/runtime/rpc/rpc_socket_impl.cc index 91b3c01b6222..c19b91801e77 100644 --- a/src/runtime/rpc/rpc_socket_impl.cc +++ b/src/runtime/rpc/rpc_socket_impl.cc @@ -122,7 +122,7 @@ void RPCServerLoop(ffi::Function fsend, ffi::Function frecv) { ->ServerLoop(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("rpc.Connect", @@ -140,7 +140,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ RPCServerLoop(args[0].cast(), args[1].cast()); } }); -}); +} class SimpleSockHandler : public dmlc::Stream { // Things that will interface with user directly. @@ -167,14 +167,14 @@ class SimpleSockHandler : public dmlc::Stream { support::TCPSocket sock_; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("rpc.ReturnException", [](int sockfd, ffi::String msg) { auto handler = SimpleSockHandler(sockfd); RPCReference::ReturnException(msg.c_str(), &handler); return; }); -}); +} } // namespace runtime } // namespace tvm diff --git a/src/runtime/static_library.cc b/src/runtime/static_library.cc index 790915b37b91..2cf7d3394599 100644 --- a/src/runtime/static_library.cc +++ b/src/runtime/static_library.cc @@ -132,12 +132,12 @@ ffi::Module LoadStaticLibrary(const std::string& filename, ffi::Array int32_t { return threading::NumThreads(); }); -}); +} namespace threading { diff --git a/src/runtime/threading_backend.cc b/src/runtime/threading_backend.cc index cb56ed181243..c4f6b3e17777 100644 --- a/src/runtime/threading_backend.cc +++ b/src/runtime/threading_backend.cc @@ -438,14 +438,14 @@ int MaxConcurrency() { // This global function can be used by disco runtime to bind processes // to CPUs. -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tvm.runtime.threading.set_current_thread_affinity", [](ffi::Shape cpu_ids) { SetThreadAffinity(CURRENT_THREAD_HANDLE, std::vector{cpu_ids.begin(), cpu_ids.end()}); }); -}); +} } // namespace threading } // namespace runtime diff --git a/src/runtime/vm/builtin.cc b/src/runtime/vm/builtin.cc index 1a0da132f522..362a7e4c89aa 100644 --- a/src/runtime/vm/builtin.cc +++ b/src/runtime/vm/builtin.cc @@ -64,10 +64,10 @@ Tensor AllocShapeHeap(void* ctx_ptr, int64_t size) { return alloc->Empty({size}, DLDataType{kDLInt, 64, 1}, vm->devices[host_device_index]); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.alloc_shape_heap", AllocShapeHeap); -}); +} /*! * \brief Builtin match R.Prim function. @@ -107,10 +107,10 @@ void MatchPrimValue(int64_t input_value, DLTensor* heap, int code_value, int64_t } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.match_prim_value", MatchPrimValue); -}); +} /*! * \brief Builtin match shape function. @@ -161,10 +161,10 @@ void MatchShape(ffi::PackedArgs args, ffi::Any* rv) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("vm.builtin.match_shape", MatchShape); -}); +} /*! * \brief Builtin make prim value function. @@ -188,10 +188,10 @@ int64_t MakePrimValue(DLTensor* heap, int shape_code, int64_t reg) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.make_prim_value", MakePrimValue); -}); +} /*! * \brief Builtin make shape function. @@ -222,10 +222,10 @@ void MakeShape(ffi::PackedArgs args, ffi::Any* rv) { *rv = ffi::Shape(std::move(shape)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("vm.builtin.make_shape", MakeShape); -}); +} /*! * \brief Builtin function to check if arg is Tensor(dtype, ndim) @@ -265,10 +265,10 @@ void CheckTensorInfo(ffi::PackedArgs args, ffi::Any* rv) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("vm.builtin.check_tensor_info", CheckTensorInfo); -}); +} /*! * \brief Builtin function to check if arg is Shape(ndim) @@ -288,10 +288,10 @@ void CheckShapeInfo(ObjectRef arg, int ndim, ffi::Optional err_ctx) } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.check_shape_info", CheckShapeInfo); -}); +} /*! * \brief Builtin function to check if arg is PrimValue(dtype) @@ -318,10 +318,10 @@ void CheckPrimValueInfo(ffi::AnyView arg, DataType dtype, ffi::Optional err_ << " but get a Tuple with " << ptr->size() << " elements."; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.check_tuple_info", CheckTupleInfo); -}); +} /*! * \brief Builtin function to check if arg is a callable function. @@ -356,10 +356,10 @@ void CheckFuncInfo(ObjectRef arg, ffi::Optional err_ctx) { << arg->GetTypeKey(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.check_func_info", CheckFuncInfo); -}); +} //------------------------------------------------- // Storage management. @@ -384,17 +384,17 @@ Storage VMAllocStorage(void* ctx_ptr, ffi::Shape buffer_shape, Index device_inde return Storage(buffer, alloc); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("vm.builtin.alloc_storage", VMAllocStorage) .def_method("vm.builtin.alloc_tensor", &StorageObj::AllocTensor); -}); +} //------------------------------------------------- // Closure function handling, calling convention //------------------------------------------------- -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("vm.builtin.make_closure", @@ -428,12 +428,12 @@ TVM_FFI_STATIC_INIT_BLOCK({ } func.CallPacked(ffi::PackedArgs(packed_args.data(), packed_args.size()), rv); }); -}); +} //------------------------------------- // Builtin runtime operators. //------------------------------------- -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("vm.builtin.shape_of", &Tensor::Shape) @@ -446,7 +446,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ Device dst_device = {(DLDeviceType)dev_type, dev_id}; return data.CopyTo(dst_device); }); -}); +} /*! * \brief Load the scalar value in cond and return the result value. @@ -491,16 +491,16 @@ bool ReadIfCond(ffi::AnyView cond) { return result != 0; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.read_if_cond", ReadIfCond); -}); +} //------------------------------------- // Debugging API //------------------------------------- -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "vm.builtin.invoke_debug_func", [](ffi::PackedArgs args, ffi::Any* rv) -> void { @@ -524,12 +524,12 @@ TVM_FFI_STATIC_INIT_BLOCK({ debug_func->CallPacked(ffi::PackedArgs(call_args.data(), call_args.size()), rv); *rv = io_effect; }); -}); +} //------------------------------------- // Data structure API //------------------------------------- -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("vm.builtin.tuple_getitem", @@ -598,7 +598,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return new_array; } }); -}); +} } // namespace vm } // namespace runtime diff --git a/src/runtime/vm/cuda/cuda_graph_builtin.cc b/src/runtime/vm/cuda/cuda_graph_builtin.cc index 0e8cc2090784..9523fd3f4b30 100644 --- a/src/runtime/vm/cuda/cuda_graph_builtin.cc +++ b/src/runtime/vm/cuda/cuda_graph_builtin.cc @@ -248,7 +248,7 @@ class CUDAGraphExtension : public VMExtension { } }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("vm.builtin.cuda_graph.run_or_capture", @@ -274,7 +274,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ int64_t entry_index = args[2].cast(); *rv = extension->GetCachedAllocation(vm, alloc_func, entry_index); }); -}); +} } // namespace vm } // namespace runtime diff --git a/src/runtime/vm/executable.cc b/src/runtime/vm/executable.cc index 3d72afc42148..40edbc14c433 100644 --- a/src/runtime/vm/executable.cc +++ b/src/runtime/vm/executable.cc @@ -212,12 +212,12 @@ ffi::Module VMExecutable::LoadFromFile(const ffi::String& file_name) { return VMExecutable::LoadFromBytes(ffi::Bytes(data)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ffi.Module.load_from_file.relax.VMExecutable", VMExecutable::LoadFromFile) .def("ffi.Module.load_from_bytes.relax.VMExecutable", VMExecutable::LoadFromBytes); -}); +} void VMFuncInfo::Save(dmlc::Stream* strm) const { int32_t temp_kind = static_cast(kind); @@ -552,10 +552,10 @@ ffi::String VMExecutable::AsPython() const { return ffi::String(os.str()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("relax.ExecutableLoadFromFile", VMExecutable::LoadFromFile); -}); +} } // namespace vm } // namespace runtime diff --git a/src/runtime/vm/hexagon/builtin.cc b/src/runtime/vm/hexagon/builtin.cc index ee18de4bf9b3..72929dd3d8f2 100644 --- a/src/runtime/vm/hexagon/builtin.cc +++ b/src/runtime/vm/hexagon/builtin.cc @@ -33,7 +33,7 @@ namespace runtime { namespace vm { // clang-format off -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("vm.builtin.hexagon.dma_copy", @@ -70,7 +70,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ QURT_MEM_DCACHE); } }); -}); +} // clang-format on } // namespace vm diff --git a/src/runtime/vm/kv_state.cc b/src/runtime/vm/kv_state.cc index 9958b01deb3d..5d04139a32c8 100644 --- a/src/runtime/vm/kv_state.cc +++ b/src/runtime/vm/kv_state.cc @@ -30,7 +30,7 @@ namespace vm { // Register Object Type // KV State base methods -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("vm.builtin.kv_state_clear", &KVStateObj::Clear) @@ -52,10 +52,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ kv_state->BeginForward(seq_ids, append_lengths, token_tree_parent_ptr); }) .def_method("vm.builtin.kv_state_end_forward", &KVStateObj::EndForward); -}); +} // Attention KV Cache methods -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("vm.builtin.kv_cache_disagg_prepare_recv", @@ -106,10 +106,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ std::move(o_self_attn), std::move(lse_self_attn), std::move(o_cross_attn), std::move(lse_cross_attn)); }); -}); +} // RNN State methods -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("vm.builtin.rnn_state_get", &RNNStateObj::Get) @@ -119,7 +119,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return state; }) .def_method("vm.builtin.rnn_state_debug_get", &RNNStateObj::DebugGet); -}); +} } // namespace vm } // namespace runtime diff --git a/src/runtime/vm/lm_support.cc b/src/runtime/vm/lm_support.cc index a578a2849ff8..e4bdb7e86607 100644 --- a/src/runtime/vm/lm_support.cc +++ b/src/runtime/vm/lm_support.cc @@ -259,30 +259,30 @@ class AttentionKVCacheLegacy : public ObjectRef { //------------------------------------------------- // Register runtime functions //------------------------------------------------- -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.attention_kv_cache_create", AttentionKVCacheLegacy::Create); -}); +} AttentionKVCacheLegacy AttentionKVCacheUpdate(AttentionKVCacheLegacy cache, Tensor value) { cache->Update(value); return cache; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.attention_kv_cache_update", AttentionKVCacheUpdate); -}); +} AttentionKVCacheLegacy AttentionKVCacheAppend(AttentionKVCacheLegacy cache, Tensor value) { cache->Append(value); return cache; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.attention_kv_cache_append", AttentionKVCacheAppend); -}); +} AttentionKVCacheLegacy AttentionKVCacheWindowOverride(AttentionKVCacheLegacy cache, Tensor value, int64_t max_cache_size) { @@ -290,11 +290,11 @@ AttentionKVCacheLegacy AttentionKVCacheWindowOverride(AttentionKVCacheLegacy cac return cache; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.attention_kv_cache_window_override", AttentionKVCacheWindowOverride); -}); +} AttentionKVCacheLegacy AttentionKVCacheWindowOverrideWithSinks(AttentionKVCacheLegacy cache, Tensor value, int64_t max_cache_size, @@ -303,17 +303,17 @@ AttentionKVCacheLegacy AttentionKVCacheWindowOverrideWithSinks(AttentionKVCacheL return cache; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.attention_kv_cache_window_override_with_sinks", AttentionKVCacheWindowOverrideWithSinks); -}); +} Tensor AttentionKVCacheView(AttentionKVCacheLegacy cache, ffi::Shape shape) { return cache->View(shape); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "vm.builtin.attention_kv_cache_view", [](ffi::PackedArgs args, ffi::Any* rv) { @@ -333,7 +333,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ *rv = cache->View(ffi::Shape(shape)); } }); -}); +} void AttentionKVCacheArrayPopN(ffi::Array caches, int64_t n) { for (AttentionKVCacheLegacy cache : caches) { @@ -341,10 +341,10 @@ void AttentionKVCacheArrayPopN(ffi::Array caches, int64_ } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.attention_kv_cache_array_popn", AttentionKVCacheArrayPopN); -}); +} void AttentionKVCacheArrayClear(ffi::Array caches) { for (AttentionKVCacheLegacy cache : caches) { @@ -352,10 +352,10 @@ void AttentionKVCacheArrayClear(ffi::Array caches) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.attention_kv_cache_array_clear", AttentionKVCacheArrayClear); -}); +} // NOTE this is a built-in highly related to LM so we put it here. int SampleTopPFromLogits(Tensor logits, double temperature, double top_p, double uniform_sample) { @@ -419,10 +419,10 @@ int SampleTopPFromLogits(Tensor logits, double temperature, double top_p, double return data[0].second; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.sample_top_p_from_logits", SampleTopPFromLogits); -}); +} int SampleTopPFromProb(Tensor prob, double top_p, double uniform_sample) { ICHECK(prob.IsContiguous()); @@ -517,10 +517,10 @@ int SampleTopPFromProb(Tensor prob, double top_p, double uniform_sample) { return sampled_index; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.sample_top_p_from_prob", SampleTopPFromProb); -}); +} Tensor MultinomialFromUniform(Tensor prob, Tensor uniform_sample) { ICHECK(prob.IsContiguous()); @@ -557,10 +557,10 @@ Tensor MultinomialFromUniform(Tensor prob, Tensor uniform_sample) { return new_array; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.multinomial_from_uniform", MultinomialFromUniform); -}); +} // This is an inplace operation. void ApplyRepetitionPenalty(Tensor logits, Tensor token_ids, double penalty) { @@ -583,10 +583,10 @@ void ApplyRepetitionPenalty(Tensor logits, Tensor token_ids, double penalty) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.apply_repetition_penalty", ApplyRepetitionPenalty); -}); +} /*! * \brief Apply presence and frequency penalty. This is an inplace operation. @@ -621,11 +621,11 @@ void ApplyPresenceAndFrequencyPenalty(Tensor logits, Tensor token_ids, Tensor to } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.apply_presence_and_frequency_penalty", ApplyPresenceAndFrequencyPenalty); -}); +} // This is an inplace operation. void ApplySoftmaxWithTemperature(Tensor logits, double temperature) { @@ -649,10 +649,10 @@ void ApplySoftmaxWithTemperature(Tensor logits, double temperature) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.apply_softmax_with_temperature", ApplySoftmaxWithTemperature); -}); +} } // namespace vm } // namespace runtime diff --git a/src/runtime/vm/paged_kv_cache.cc b/src/runtime/vm/paged_kv_cache.cc index c2605bfb1efb..0f3f56866134 100644 --- a/src/runtime/vm/paged_kv_cache.cc +++ b/src/runtime/vm/paged_kv_cache.cc @@ -2433,7 +2433,7 @@ class PagedAttentionKVCacheObj : public AttentionKVCacheObj { // Register runtime functions //------------------------------------------------- -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "vm.builtin.paged_attention_kv_cache_create", [](ffi::PackedArgs args, ffi::Any* rv) { @@ -2537,7 +2537,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ std::move(f_copy_single_page), std::move(f_debug_get_kv)); *rv = AttentionKVCache(std::move(n)); }); -}); +} } // namespace vm } // namespace runtime diff --git a/src/runtime/vm/rnn_state.cc b/src/runtime/vm/rnn_state.cc index 2f7cde2737fc..61194b5dade2 100644 --- a/src/runtime/vm/rnn_state.cc +++ b/src/runtime/vm/rnn_state.cc @@ -465,7 +465,7 @@ class RNNStateImpObj : public RNNStateObj { // Register runtime functions //------------------------------------------------- -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("vm.builtin.rnn_state_create", [](int64_t num_layers, // int64_t reserved_num_seqs, // @@ -495,7 +495,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ std::move(f_gets), std::move(f_sets), init_layer_value); return RNNState(std::move(n)); }); -}); +} } // namespace vm } // namespace runtime diff --git a/src/runtime/vm/tensor_cache_support.cc b/src/runtime/vm/tensor_cache_support.cc index 2cc53c6d400f..1f727241cd25 100644 --- a/src/runtime/vm/tensor_cache_support.cc +++ b/src/runtime/vm/tensor_cache_support.cc @@ -267,7 +267,7 @@ class TensorCache { ffi::Map pool_; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("vm.builtin.tensor_cache.get", TensorCache::Get) @@ -298,7 +298,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("vm.builtin.tensor_cache.remove", TensorCache::Remove) .def("vm.builtin.tensor_cache.clear", TensorCache::Clear) .def("vm.builtin.tensor_cache.load", TensorCache::Load); -}); +} // This param module node can be useful to get param dict in RPC mode // when the remote already have loaded parameters from file. @@ -359,7 +359,7 @@ class ParamModuleNode : public ffi::ModuleObj { ffi::Array params_; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("vm.builtin.param_module_from_cache", ParamModuleNode::Create) @@ -379,7 +379,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } *rv = ParamModuleNode::GetParamByName(names); }); -}); +} } // namespace vm } // namespace runtime diff --git a/src/runtime/vulkan/vulkan_device_api.cc b/src/runtime/vulkan/vulkan_device_api.cc index 023d34e68bda..a2ff8bb7ce0e 100644 --- a/src/runtime/vulkan/vulkan_device_api.cc +++ b/src/runtime/vulkan/vulkan_device_api.cc @@ -451,7 +451,7 @@ VulkanDevice& VulkanDeviceAPI::device(size_t device_id) { return const_cast(const_cast(this)->device(device_id)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("device_api.vulkan", @@ -464,7 +464,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ VulkanDeviceAPI::Global()->GetTargetProperty(dev, property, &rv); return rv; }); -}); +} } // namespace vulkan } // namespace runtime diff --git a/src/runtime/vulkan/vulkan_module.cc b/src/runtime/vulkan/vulkan_module.cc index 7c25985b6f07..dbf2d9fff76c 100644 --- a/src/runtime/vulkan/vulkan_module.cc +++ b/src/runtime/vulkan/vulkan_module.cc @@ -67,12 +67,12 @@ ffi::Module VulkanModuleLoadFromBytes(const ffi::Bytes& bytes) { return VulkanModuleCreate(smap, fmap, ""); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ffi.Module.load_from_file.vulkan", VulkanModuleLoadFile) .def("ffi.Module.load_from_bytes.vulkan", VulkanModuleLoadFromBytes); -}); +} } // namespace vulkan } // namespace runtime diff --git a/src/script/ir_builder/base.cc b/src/script/ir_builder/base.cc index 003157572c36..658e76be466c 100644 --- a/src/script/ir_builder/base.cc +++ b/src/script/ir_builder/base.cc @@ -25,10 +25,10 @@ namespace tvm { namespace script { namespace ir_builder { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { IRBuilderFrameNode::RegisterReflection(); IRBuilderNode::RegisterReflection(); -}); +} void IRBuilderFrameNode::EnterWithScope() { IRBuilder::Current()->frames.push_back(ffi::GetRef(this)); @@ -105,7 +105,7 @@ void Namer::Name(ObjectRef node, ffi::String name) { } // namespace details -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("script.ir_builder.IRBuilderFrameEnter", &IRBuilderFrameNode::EnterWithScope) @@ -118,7 +118,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("script.ir_builder.IRBuilderIsInScope", IRBuilder::IsInScope) .def_method("script.ir_builder.IRBuilderGet", &IRBuilderNode::Get) .def("script.ir_builder.IRBuilderName", IRBuilder::Name); -}); +} } // namespace ir_builder } // namespace script diff --git a/src/script/ir_builder/ir/frame.cc b/src/script/ir_builder/ir/frame.cc index d2bb5231a867..fae4ba41bfda 100644 --- a/src/script/ir_builder/ir/frame.cc +++ b/src/script/ir_builder/ir/frame.cc @@ -25,7 +25,7 @@ namespace script { namespace ir_builder { namespace ir { -TVM_FFI_STATIC_INIT_BLOCK({ IRModuleFrameNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { IRModuleFrameNode::RegisterReflection(); } void IRModuleFrameNode::ExitWithScope() { ffi::Map func_map; diff --git a/src/script/ir_builder/ir/ir.cc b/src/script/ir_builder/ir/ir.cc index b0c56e779a71..e609f1b8efd2 100644 --- a/src/script/ir_builder/ir/ir.cc +++ b/src/script/ir_builder/ir/ir.cc @@ -161,7 +161,7 @@ VDevice LookupVDevice(ffi::String target_kind, int device_index) { return VDevice(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.ir.IRModule", IRModule) @@ -172,7 +172,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("script.ir_builder.ir.ModuleSetAttr", ModuleSetAttr) .def("script.ir_builder.ir.ModuleGlobalInfos", ModuleGlobalInfos) .def("script.ir_builder.ir.LookupVDevice", LookupVDevice); -}); +} } // namespace ir } // namespace ir_builder diff --git a/src/script/ir_builder/relax/distributed.cc b/src/script/ir_builder/relax/distributed.cc index bab14f3b3fd2..3efb38d44bf5 100644 --- a/src/script/ir_builder/relax/distributed.cc +++ b/src/script/ir_builder/relax/distributed.cc @@ -56,10 +56,10 @@ Expr MakeCallTIRDist(Expr func, Tuple args, return call; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.ir_builder.relax.distributed.call_tir_dist", MakeCallTIRDist); -}); +} } // namespace relax } // namespace tvm diff --git a/src/script/ir_builder/relax/frame.cc b/src/script/ir_builder/relax/frame.cc index d69547383a80..acd1784c88f0 100644 --- a/src/script/ir_builder/relax/frame.cc +++ b/src/script/ir_builder/relax/frame.cc @@ -30,7 +30,7 @@ namespace script { namespace ir_builder { namespace relax { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { RelaxFrameNode::RegisterReflection(); SeqExprFrameNode::RegisterReflection(); FunctionFrameNode::RegisterReflection(); @@ -38,7 +38,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ IfFrameNode::RegisterReflection(); ThenFrameNode::RegisterReflection(); ElseFrameNode::RegisterReflection(); -}); +} void SeqExprFrameNode::ExitWithScope() { // At this moment, there should be at most one BlockFrame which hasn't ended. In this case, call diff --git a/src/script/ir_builder/relax/ir.cc b/src/script/ir_builder/relax/ir.cc index 8cab805a0433..db77d4db5b26 100644 --- a/src/script/ir_builder/relax/ir.cc +++ b/src/script/ir_builder/relax/ir.cc @@ -146,7 +146,7 @@ void FuncRetValue(const tvm::relax::Expr& value) { frame->output = std::move(normalized_value); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.relax.Function", Function) @@ -155,7 +155,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("script.ir_builder.relax.FuncAttrs", FuncAttrs) .def("script.ir_builder.relax.FuncRetStructInfo", FuncRetStructInfo) .def("script.ir_builder.relax.FuncRetValue", FuncRetValue); -}); +} ///////////////////////////// BindingBlock ////////////////////////////// @@ -197,13 +197,13 @@ void DataflowBlockOutput(const ffi::Array& vars) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.relax.Dataflow", Dataflow) .def("script.ir_builder.relax.BindingBlock", BindingBlock) .def("script.ir_builder.relax.DataflowBlockOutput", DataflowBlockOutput); -}); +} /////////////////////////////// Bindings /////////////////////////////// @@ -245,13 +245,13 @@ tvm::relax::Var EmitVarBinding(const tvm::relax::VarBinding& binding) { return binding->var; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.relax.Emit", Emit) .def("script.ir_builder.relax.EmitMatchCast", EmitMatchCast) .def("script.ir_builder.relax.EmitVarBinding", EmitVarBinding); -}); +} /////////////////////////////// SeqExpr /////////////////////////////// @@ -260,10 +260,10 @@ SeqExprFrame SeqExpr() { return SeqExprFrame(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.ir_builder.relax.SeqExpr", SeqExpr); -}); +} ///////////////////////////// If Then Else ///////////////////////////// @@ -285,13 +285,13 @@ ElseFrame Else() { return ElseFrame(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.relax.If", If) .def("script.ir_builder.relax.Then", Then) .def("script.ir_builder.relax.Else", Else); -}); +} } // namespace relax } // namespace ir_builder diff --git a/src/script/ir_builder/tir/frame.cc b/src/script/ir_builder/tir/frame.cc index 2bfb9266eada..94eef40f59be 100644 --- a/src/script/ir_builder/tir/frame.cc +++ b/src/script/ir_builder/tir/frame.cc @@ -28,7 +28,7 @@ namespace script { namespace ir_builder { namespace tir { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { TIRFrameNode::RegisterReflection(); PrimFuncFrameNode::RegisterReflection(); BlockFrameNode::RegisterReflection(); @@ -46,7 +46,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ThenFrameNode::RegisterReflection(); ElseFrameNode::RegisterReflection(); DeclBufferFrameNode::RegisterReflection(); -}); +} void PrimFuncFrameNode::ExitWithScope() { TIRFrameNode::ExitWithScope(); diff --git a/src/script/ir_builder/tir/ir.cc b/src/script/ir_builder/tir/ir.cc index e934f5d562dc..b981b90bd81b 100644 --- a/src/script/ir_builder/tir/ir.cc +++ b/src/script/ir_builder/tir/ir.cc @@ -694,7 +694,7 @@ TVM_STATIC_IR_FUNCTOR(Namer, vtable) Namer::Name(var->var, name); }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Buffer", BufferDecl) @@ -761,7 +761,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("script.ir_builder.tir.BufferStore", BufferStore) .def("script.ir_builder.tir.Evaluate", Evaluate) .def("script.ir_builder.tir.Ptr", Ptr); -}); +} #define TVM_TMP_STR(x) #x @@ -784,7 +784,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .TVM_FFI_REFL_DEF_GLOBAL_LANES(Prefix TVM_TMP_STR(32), DType##32) \ .TVM_FFI_REFL_DEF_GLOBAL_LANES(Prefix TVM_TMP_STR(64), DType##64) -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.BFloat16", BFloat16) @@ -795,89 +795,89 @@ TVM_FFI_STATIC_INIT_BLOCK({ .TVM_FFI_REFL_DEF_GLOBAL_SIZES_LANES("script.ir_builder.tir.UInt", UInt) .TVM_FFI_REFL_DEF_GLOBAL_SIZES_LANES("script.ir_builder.tir.Int", Int) .TVM_FFI_REFL_DEF_GLOBAL_LANES("script.ir_builder.tir.BFloat16", BFloat16); -}); +} // Float8 variants -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Float8E3M4", Float8E3M4) .TVM_FFI_REFL_DEF_GLOBAL_LANES("script.ir_builder.tir.Float8E3M4", Float8E3M4); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Float8E4M3", Float8E4M3) .TVM_FFI_REFL_DEF_GLOBAL_LANES("script.ir_builder.tir.Float8E4M3", Float8E4M3); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Float8E4M3B11FNUZ", Float8E4M3B11FNUZ) .TVM_FFI_REFL_DEF_GLOBAL_LANES("script.ir_builder.tir.Float8E4M3B11FNUZ", Float8E4M3B11FNUZ); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Float8E4M3FN", Float8E4M3FN) .TVM_FFI_REFL_DEF_GLOBAL_LANES("script.ir_builder.tir.Float8E4M3FN", Float8E4M3FN); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Float8E4M3FNUZ", Float8E4M3FNUZ) .TVM_FFI_REFL_DEF_GLOBAL_LANES("script.ir_builder.tir.Float8E4M3FNUZ", Float8E4M3FNUZ); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Float8E5M2", Float8E5M2) .TVM_FFI_REFL_DEF_GLOBAL_LANES("script.ir_builder.tir.Float8E5M2", Float8E5M2); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Float8E5M2FNUZ", Float8E5M2FNUZ) .TVM_FFI_REFL_DEF_GLOBAL_LANES("script.ir_builder.tir.Float8E5M2FNUZ", Float8E5M2FNUZ); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Float8E8M0FNU", Float8E8M0FNU) .TVM_FFI_REFL_DEF_GLOBAL_LANES("script.ir_builder.tir.Float8E8M0FNU", Float8E8M0FNU); -}); +} // Float6 variants -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Float6E2M3FN", Float6E2M3FN) .TVM_FFI_REFL_DEF_GLOBAL_LANES("script.ir_builder.tir.Float6E2M3FN", Float6E2M3FN); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Float6E3M2FN", Float6E3M2FN) .TVM_FFI_REFL_DEF_GLOBAL_LANES("script.ir_builder.tir.Float6E3M2FN", Float6E3M2FN); -}); +} // Float4 variant -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Float4E2M1FN", Float4E2M1FN) .TVM_FFI_REFL_DEF_GLOBAL_LANES("script.ir_builder.tir.Float4E2M1FN", Float4E2M1FN); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.ir_builder.tir.Boolean", Boolean) @@ -888,7 +888,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ [](PrimExpr a, PrimExpr b) -> PrimExpr { return tvm::min(a, b); }) .def("script.ir_builder.tir.max", [](PrimExpr a, PrimExpr b) -> PrimExpr { return tvm::max(a, b); }); -}); +} } // namespace tir } // namespace ir_builder } // namespace script diff --git a/src/script/printer/doc.cc b/src/script/printer/doc.cc index 6f0d548bafca..e5d72c002da0 100644 --- a/src/script/printer/doc.cc +++ b/src/script/printer/doc.cc @@ -26,7 +26,7 @@ namespace tvm { namespace script { namespace printer { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { DocNode::RegisterReflection(); ExprDocNode::RegisterReflection(); StmtDocNode::RegisterReflection(); @@ -54,7 +54,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ClassDocNode::RegisterReflection(); CommentDocNode::RegisterReflection(); DocStringDocNode::RegisterReflection(); -}); +} ExprDoc ExprDocNode::Attr(ffi::String attr) const { return AttrAccessDoc(ffi::GetRef(this), attr); @@ -268,14 +268,14 @@ DocStringDoc::DocStringDoc(ffi::String docs) { this->data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "script.printer.DocSetSourcePaths", [](Doc doc, ffi::Array source_paths) { doc->source_paths = source_paths; }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("script.printer.ExprDocAttr", &ExprDocNode::Attr) @@ -285,22 +285,22 @@ TVM_FFI_STATIC_INIT_BLOCK({ ffi::Array kwargs_values) { return doc->Call(args, kwargs_keys, kwargs_values); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "script.printer.StmtDocSetComment", [](StmtDoc doc, ffi::Optional comment) { doc->comment = comment; }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.StmtBlockDoc", [](ffi::Array stmts) { return StmtBlockDoc(stmts); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("script.printer.LiteralDocNone", LiteralDoc::None) @@ -308,27 +308,27 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("script.printer.LiteralDocBoolean", LiteralDoc::Boolean) .def("script.printer.LiteralDocFloat", LiteralDoc::Float) .def("script.printer.LiteralDocStr", LiteralDoc::Str); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.IdDoc", [](ffi::String name) { return IdDoc(name); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.AttrAccessDoc", [](ExprDoc value, ffi::String attr) { return AttrAccessDoc(value, attr); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.IndexDoc", [](ExprDoc value, ffi::Array indices) { return IndexDoc(value, indices); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.CallDoc", [](ExprDoc callee, // ffi::Array args, // @@ -336,133 +336,133 @@ TVM_FFI_STATIC_INIT_BLOCK({ ffi::Array kwargs_values) { return CallDoc(callee, args, kwargs_keys, kwargs_values); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.OperationDoc", [](int32_t kind, ffi::Array operands) { return OperationDoc(OperationDocNode::Kind(kind), operands); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.LambdaDoc", [](ffi::Array args, ExprDoc body) { return LambdaDoc(args, body); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.TupleDoc", [](ffi::Array elements) { return TupleDoc(elements); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.ListDoc", [](ffi::Array elements) { return ListDoc(elements); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "script.printer.DictDoc", [](ffi::Array keys, ffi::Array values) { return DictDoc(keys, values); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.SliceDoc", [](ffi::Optional start, ffi::Optional stop, ffi::Optional step) { return SliceDoc(start, stop, step); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.AssignDoc", [](ExprDoc lhs, ffi::Optional rhs, ffi::Optional annotation) { return AssignDoc(lhs, rhs, annotation); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "script.printer.IfDoc", [](ExprDoc predicate, ffi::Array then_branch, ffi::Array else_branch) { return IfDoc(predicate, then_branch, else_branch); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.WhileDoc", [](ExprDoc predicate, ffi::Array body) { return WhileDoc(predicate, body); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "script.printer.ForDoc", [](ExprDoc lhs, ExprDoc rhs, ffi::Array body) { return ForDoc(lhs, rhs, body); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.ScopeDoc", [](ffi::Optional lhs, ExprDoc rhs, ffi::Array body) { return ScopeDoc(lhs, rhs, body); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.ExprStmtDoc", [](ExprDoc expr) { return ExprStmtDoc(expr); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "script.printer.AssertDoc", [](ExprDoc test, ffi::Optional msg = std::nullopt) { return AssertDoc(test, msg); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.ReturnDoc", [](ExprDoc value) { return ReturnDoc(value); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.FunctionDoc", [](IdDoc name, ffi::Array args, ffi::Array decorators, ffi::Optional return_type, ffi::Array body) { return FunctionDoc(name, args, decorators, return_type, body); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.ClassDoc", [](IdDoc name, ffi::Array decorators, ffi::Array body) { return ClassDoc(name, decorators, body); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.CommentDoc", [](ffi::String comment) { return CommentDoc(comment); }); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.DocStringDoc", [](ffi::String docs) { return DocStringDoc(docs); }); -}); +} } // namespace printer } // namespace script diff --git a/src/script/printer/doc_printer/python_doc_printer.cc b/src/script/printer/doc_printer/python_doc_printer.cc index e576c5acb1bf..1a79806d1621 100644 --- a/src/script/printer/doc_printer/python_doc_printer.cc +++ b/src/script/printer/doc_printer/python_doc_printer.cc @@ -728,10 +728,10 @@ ffi::String DocToPythonScript(Doc doc, const PrinterConfig& cfg) { return result.substr(0, last_space); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.DocToPythonScript", DocToPythonScript); -}); +} } // namespace printer } // namespace script diff --git a/src/script/printer/ir/ir.cc b/src/script/printer/ir/ir.cc index 0bca40948e3c..aac5656f9146 100644 --- a/src/script/printer/ir/ir.cc +++ b/src/script/printer/ir/ir.cc @@ -24,7 +24,7 @@ namespace tvm { namespace script { namespace printer { -TVM_FFI_STATIC_INIT_BLOCK({ IRFrameNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { IRFrameNode::RegisterReflection(); } struct SortableFunction { int priority; diff --git a/src/script/printer/ir_docsifier.cc b/src/script/printer/ir_docsifier.cc index 94d2a281e2fe..8ebbedfef78d 100644 --- a/src/script/printer/ir_docsifier.cc +++ b/src/script/printer/ir_docsifier.cc @@ -30,10 +30,10 @@ namespace tvm { namespace script { namespace printer { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { FrameNode::RegisterReflection(); IRDocsifierNode::RegisterReflection(); -}); +} IdDoc IRDocsifierNode::Define(const ObjectRef& obj, const Frame& frame, const ffi::String& name_hint) { diff --git a/src/script/printer/relax/function.cc b/src/script/printer/relax/function.cc index 1a1bf006995d..978c4a8243da 100644 --- a/src/script/printer/relax/function.cc +++ b/src/script/printer/relax/function.cc @@ -37,7 +37,7 @@ bool AtTopLevelFunction(const IRDocsifier& d) { return d->frames.size() == 3; } -TVM_FFI_STATIC_INIT_BLOCK({ RelaxFrameNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { RelaxFrameNode::RegisterReflection(); } TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable) .set_dispatch("", [](relax::Function n, AccessPath n_p, IRDocsifier d) -> Doc { diff --git a/src/script/printer/relax/type.cc b/src/script/printer/relax/type.cc index 893f4304342e..032205244347 100644 --- a/src/script/printer/relax/type.cc +++ b/src/script/printer/relax/type.cc @@ -84,10 +84,10 @@ TVM_SCRIPT_REPR(relax::ShapeTypeNode, ReprPrintRelax); TVM_SCRIPT_REPR(relax::ObjectTypeNode, ReprPrintRelax); TVM_SCRIPT_REPR(relax::TensorTypeNode, ReprPrintRelax); TVM_SCRIPT_REPR(relax::PackedFuncTypeNode, ReprPrintRelax); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.printer.ReprPrintRelax", ReprPrintRelax); -}); +} } // namespace printer } // namespace script diff --git a/src/script/printer/tir/ir.cc b/src/script/printer/tir/ir.cc index 797c726c7c1a..431dc7dcc3e5 100644 --- a/src/script/printer/tir/ir.cc +++ b/src/script/printer/tir/ir.cc @@ -24,7 +24,7 @@ namespace tvm { namespace script { namespace printer { -TVM_FFI_STATIC_INIT_BLOCK({ TIRFrameNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { TIRFrameNode::RegisterReflection(); } TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable) .set_dispatch("", [](IntImm imm, AccessPath imm_p, IRDocsifier d) -> Doc { diff --git a/src/support/ffi_testing.cc b/src/support/ffi_testing.cc index 703cc5bf9a66..8875046874e4 100644 --- a/src/support/ffi_testing.cc +++ b/src/support/ffi_testing.cc @@ -54,9 +54,9 @@ struct TestAttrs : public AttrsNodeReflAdapter { TVM_FFI_DECLARE_OBJECT_INFO_FINAL("attrs.TestAttrs", TestAttrs, BaseAttrsNode); }; -TVM_FFI_STATIC_INIT_BLOCK({ TestAttrs::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { TestAttrs::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("testing.GetShapeSize", @@ -104,7 +104,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ "if the python module is properly loaded"; *ret = (*identity_func)(args[0]); }); -}); +} // in src/api_test.cc void ErrorTest(int x, int y) { @@ -116,10 +116,10 @@ void ErrorTest(int x, int y) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("testing.ErrorTest", ErrorTest); -}); +} class FrontendTestModuleNode : public ffi::ModuleObj { public: @@ -159,7 +159,7 @@ ffi::Module NewFrontendTestModule() { return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("testing.FrontendTestModule", NewFrontendTestModule) @@ -216,7 +216,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } return map; }); -}); +} /** * Simple event logger that can be used for testing purposes @@ -257,7 +257,7 @@ class TestingEventLogger { std::vector entries_; }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("testing.record_event", @@ -272,5 +272,5 @@ TVM_FFI_STATIC_INIT_BLOCK({ "testing.reset_events", [](ffi::PackedArgs args, ffi::Any* rv) { TestingEventLogger::ThreadLocal()->Reset(); }) .def("testing.dump_events", []() { TestingEventLogger::ThreadLocal()->Dump(); }); -}); +} } // namespace tvm diff --git a/src/support/libinfo.cc b/src/support/libinfo.cc index 63b930e6a1c5..d0646ee8b06f 100644 --- a/src/support/libinfo.cc +++ b/src/support/libinfo.cc @@ -366,9 +366,9 @@ TVM_DLL ffi::Map GetLibInfo() { return result; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("support.GetLibInfo", GetLibInfo); -}); +} } // namespace tvm diff --git a/src/target/codegen.cc b/src/target/codegen.cc index b452c26ca96d..30238318ffed 100644 --- a/src/target/codegen.cc +++ b/src/target/codegen.cc @@ -341,13 +341,13 @@ ffi::Module PackImportsToLLVM(const ffi::Module& mod, bool system_lib, .cast(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("target.Build", Build); -}); +} // Export a few auxiliary function to the runtime namespace. -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.ModuleImportsBlobName", @@ -369,7 +369,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ }) .def("runtime.ModulePackImportsToC", PackImportsToC) .def("runtime.ModulePackImportsToLLVM", PackImportsToLLVM); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/datatype/registry.cc b/src/target/datatype/registry.cc index 4a0d5777252e..9f534e8d69b4 100644 --- a/src/target/datatype/registry.cc +++ b/src/target/datatype/registry.cc @@ -28,7 +28,7 @@ namespace datatype { using ffi::Any; using ffi::PackedArgs; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("dtype.register_custom_type", @@ -47,7 +47,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_packed("runtime._datatype_get_type_registered", [](ffi::PackedArgs args, ffi::Any* ret) { *ret = Registry::Global()->GetTypeRegistered(args[0].cast()); }); -}); +} Registry* Registry::Global() { static Registry inst; diff --git a/src/target/llvm/codegen_aarch64.cc b/src/target/llvm/codegen_aarch64.cc index 545e90697c58..adac65914469 100644 --- a/src/target/llvm/codegen_aarch64.cc +++ b/src/target/llvm/codegen_aarch64.cc @@ -107,13 +107,13 @@ void CodeGenAArch64::VisitStmt_(const AttrStmtNode* op) { this->VisitStmt(op->body); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvm.codegen.llvm.target_aarch64", [](const ffi::PackedArgs& targs, ffi::Any* rv) { *rv = static_cast(new CodeGenAArch64()); }); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/llvm/codegen_amdgpu.cc b/src/target/llvm/codegen_amdgpu.cc index 8fd9dc210561..034b982f64b3 100644 --- a/src/target/llvm/codegen_amdgpu.cc +++ b/src/target/llvm/codegen_amdgpu.cc @@ -361,14 +361,14 @@ ffi::Module BuildAMDGPU(IRModule mod, Target target) { return ROCMModuleCreate(hsaco, "hsaco", ExtractFuncInfo(mod), ll, assembly); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("target.build.rocm", BuildAMDGPU) .def_packed("tvm.codegen.llvm.target_rocm", [](const ffi::PackedArgs& targs, ffi::Any* rv) { *rv = static_cast(new CodeGenAMDGPU()); }); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/llvm/codegen_arm.cc b/src/target/llvm/codegen_arm.cc index c686e5fc38d4..b1888a4928ab 100644 --- a/src/target/llvm/codegen_arm.cc +++ b/src/target/llvm/codegen_arm.cc @@ -128,13 +128,13 @@ PrimExpr CodeGenARM::ARMPopcount(const CallNode* call) { return tir::Call(call->dtype, builtin_call_llvm_pure_intrin_, vcnt64_args); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvm.codegen.llvm.target_arm", [](const ffi::PackedArgs& targs, ffi::Any* rv) { *rv = static_cast(new CodeGenARM()); }); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/llvm/codegen_cpu.cc b/src/target/llvm/codegen_cpu.cc index e9dbdeb0c23e..895cdae23107 100644 --- a/src/target/llvm/codegen_cpu.cc +++ b/src/target/llvm/codegen_cpu.cc @@ -1186,13 +1186,13 @@ void CodeGenCPU::VisitStmt_(const ForNode* op) { } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvm.codegen.llvm.target_cpu", [](const ffi::PackedArgs& targs, ffi::Any* rv) { *rv = static_cast(new CodeGenCPU()); }); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/llvm/codegen_hexagon.cc b/src/target/llvm/codegen_hexagon.cc index 55abd565ff99..773e2a2e1d91 100644 --- a/src/target/llvm/codegen_hexagon.cc +++ b/src/target/llvm/codegen_hexagon.cc @@ -592,7 +592,7 @@ ffi::Module BuildHexagon(IRModule mod, Target target) { return HexagonModuleCreate(so_name, "so", ExtractFuncInfo(mod), asm_str, obj_str, ir_str, bc_str); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("target.build.hexagon", BuildHexagon) @@ -600,7 +600,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ [](const ffi::PackedArgs& targs, ffi::Any* rv) { *rv = static_cast(new CodeGenHexagon()); }); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index ecbdf437608d..48d576f12efa 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -2384,7 +2384,7 @@ static void CodegenLLVMRegisterReflection() { }); } -TVM_FFI_STATIC_INIT_BLOCK({ CodegenLLVMRegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { CodegenLLVMRegisterReflection(); } } // namespace codegen } // namespace tvm diff --git a/src/target/llvm/codegen_nvptx.cc b/src/target/llvm/codegen_nvptx.cc index 054cfedb4b7c..17a90477d2fc 100644 --- a/src/target/llvm/codegen_nvptx.cc +++ b/src/target/llvm/codegen_nvptx.cc @@ -377,14 +377,14 @@ ffi::Module BuildNVPTX(IRModule mod, Target target) { return CUDAModuleCreate(ptx, "ptx", ExtractFuncInfo(mod), ll); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("target.build.nvptx", BuildNVPTX) .def_packed("tvm.codegen.llvm.target_nvptx", [](const ffi::PackedArgs& targs, ffi::Any* rv) { *rv = static_cast(new CodeGenNVPTX()); }); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/llvm/codegen_x86_64.cc b/src/target/llvm/codegen_x86_64.cc index b4c7cf190136..2666a3dc1c40 100644 --- a/src/target/llvm/codegen_x86_64.cc +++ b/src/target/llvm/codegen_x86_64.cc @@ -133,13 +133,13 @@ llvm::Value* CodeGenX86_64::CallVectorIntrin(llvm::Intrinsic::ID id, size_t intr return CreateVecSlice(CreateVecConcat(split_results), 0, num_elems); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvm.codegen.llvm.target_x86-64", [](const ffi::PackedArgs& targs, ffi::Any* rv) { *rv = static_cast(new CodeGenX86_64()); }); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/llvm/llvm_module.cc b/src/target/llvm/llvm_module.cc index c31e1f1a7811..5f7494558eaa 100644 --- a/src/target/llvm/llvm_module.cc +++ b/src/target/llvm/llvm_module.cc @@ -814,7 +814,7 @@ static void LLVMReflectionRegister() { }); } -TVM_FFI_STATIC_INIT_BLOCK({ LLVMReflectionRegister(); }); +TVM_FFI_STATIC_INIT_BLOCK() { LLVMReflectionRegister(); } } // namespace codegen } // namespace tvm diff --git a/src/target/opt/build_cuda_on.cc b/src/target/opt/build_cuda_on.cc index 7b1356118d16..8d2589aaec13 100644 --- a/src/target/opt/build_cuda_on.cc +++ b/src/target/opt/build_cuda_on.cc @@ -173,10 +173,10 @@ ffi::Module BuildCUDA(IRModule mod, Target target) { return CUDAModuleCreate(ptx, fmt, ExtractFuncInfo(mod), code); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("target.build.cuda", BuildCUDA); -}); +} TVM_REGISTER_PASS_CONFIG_OPTION("cuda.kernels_output_dir", ffi::String); } // namespace codegen } // namespace tvm diff --git a/src/target/source/codegen_c_host.cc b/src/target/source/codegen_c_host.cc index 6a27036d6e6c..12a8d66bba9b 100644 --- a/src/target/source/codegen_c_host.cc +++ b/src/target/source/codegen_c_host.cc @@ -409,9 +409,9 @@ ffi::Module BuildCHost(IRModule mod, Target target) { return CSourceModuleCreate(code, "c", cg.GetFunctionNames()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("target.build.c", BuildCHost); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/source/codegen_metal.cc b/src/target/source/codegen_metal.cc index eab7646ee53d..01042776c971 100644 --- a/src/target/source/codegen_metal.cc +++ b/src/target/source/codegen_metal.cc @@ -468,9 +468,9 @@ ffi::Module BuildMetal(IRModule mod, Target target) { return MetalModuleCreate(smap, ExtractFuncInfo(mod), fmt, source_maker.str()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("target.build.metal", BuildMetal); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/source/codegen_opencl.cc b/src/target/source/codegen_opencl.cc index 4f4f763a74ae..769401c4bcf5 100644 --- a/src/target/source/codegen_opencl.cc +++ b/src/target/source/codegen_opencl.cc @@ -674,10 +674,10 @@ ffi::Module BuildOpenCL(IRModule mod, Target target) { return OpenCLModuleCreate(code.str(), "cl", ExtractFuncInfo(mod), code.str()); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("target.build.opencl", BuildOpenCL); -}); +} ffi::String DeviceScopeCompatibilityFromTarget(Target target, ffi::String memory_scope) { auto prototype_keys = target->GetKeys(); @@ -689,10 +689,10 @@ ffi::String DeviceScopeCompatibilityFromTarget(Target target, ffi::String memory return memory_scope; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("DeviceScopeCompatibility.opencl", DeviceScopeCompatibilityFromTarget); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/source/codegen_webgpu.cc b/src/target/source/codegen_webgpu.cc index 374402742271..330a54563fce 100644 --- a/src/target/source/codegen_webgpu.cc +++ b/src/target/source/codegen_webgpu.cc @@ -784,11 +784,11 @@ ffi::Module BuildWebGPU(IRModule mod, Target target) { return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("target.build.webgpu", [](IRModule mod, Target target) { return BuildWebGPU(mod, target); }); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/source/source_module.cc b/src/target/source/source_module.cc index a0ae36691fa8..0112ad961de4 100644 --- a/src/target/source/source_module.cc +++ b/src/target/source/source_module.cc @@ -183,10 +183,10 @@ ffi::Module CSourceModuleCreate(const ffi::String& code, const ffi::String& fmt, return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("ffi.Module.load_from_bytes.c", CSourceModuleNode::LoadFromBytes); -}); +} /*! * \brief A concrete class to get access to base methods of CodegenSourceBase. @@ -263,7 +263,7 @@ ffi::Module DeviceSourceModuleCreate(std::string data, std::string fmt, return ffi::Module(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("runtime.SourceModuleCreate", SourceModuleCreate) @@ -272,7 +272,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ffi::Optional> const_vars) { return CSourceModuleCreate(code, fmt, func_names.value_or({}), const_vars.value_or({})); }); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/spirv/build_vulkan.cc b/src/target/spirv/build_vulkan.cc index bd44607a98eb..f71b7ef8d6fa 100644 --- a/src/target/spirv/build_vulkan.cc +++ b/src/target/spirv/build_vulkan.cc @@ -37,11 +37,11 @@ ffi::Module BuildSPIRV(IRModule mod, Target target) { return runtime::VulkanModuleCreate(smap, ExtractFuncInfo(mod), spirv_text); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("target.build.vulkan", [](IRModule mod, Target target) { return BuildSPIRV(mod, target); }); -}); +} } // namespace codegen } // namespace tvm diff --git a/src/target/tag.cc b/src/target/tag.cc index 8835ea64c9a3..dfe179f7ac16 100644 --- a/src/target/tag.cc +++ b/src/target/tag.cc @@ -32,14 +32,14 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ TargetTagNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { TargetTagNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("target.TargetTagListTags", TargetTag::ListTags) .def("target.TargetTagAddTag", TargetTag::AddTag); -}); +} /********** Registry-related code **********/ diff --git a/src/target/target.cc b/src/target/target.cc index e2013aba7218..c23b8bd7570f 100644 --- a/src/target/target.cc +++ b/src/target/target.cc @@ -43,7 +43,7 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ TargetNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { TargetNode::RegisterReflection(); } class TargetInternal { public: @@ -999,7 +999,7 @@ std::unordered_map TargetInternal::QueryDevice(int device /********** Registry **********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("target.Target", TargetInternal::ConstructorDispatcher) @@ -1018,7 +1018,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return Any(); } }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& obj, ReprPrinter* p) { diff --git a/src/target/target_info.cc b/src/target/target_info.cc index 578276162678..1966024dd4b7 100644 --- a/src/target/target_info.cc +++ b/src/target/target_info.cc @@ -26,7 +26,7 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ MemoryInfoNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { MemoryInfoNode::RegisterReflection(); } TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { diff --git a/src/target/target_kind.cc b/src/target/target_kind.cc index 0c835fdca266..d44173a2ae3c 100644 --- a/src/target/target_kind.cc +++ b/src/target/target_kind.cc @@ -36,7 +36,7 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; TargetKindNode::RegisterReflection(); refl::TypeAttrDef() @@ -50,7 +50,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ICHECK(kind.has_value()) << "Cannot find target kind \'" << name << '\''; return kind.value(); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& obj, ReprPrinter* p) { @@ -446,7 +446,7 @@ TVM_REGISTER_TARGET_KIND("test", kDLCPU) // line break /********** Registry **********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("target.TargetKindGetAttr", @@ -464,6 +464,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ TargetKind kind = TargetKind::Get(target_kind_name).value(); return TargetKindRegEntry::ListTargetKindOptions(kind); }); -}); +} } // namespace tvm diff --git a/src/target/virtual_device.cc b/src/target/virtual_device.cc index dd1925aa3118..54529acb409c 100644 --- a/src/target/virtual_device.cc +++ b/src/target/virtual_device.cc @@ -28,7 +28,7 @@ namespace tvm { -TVM_FFI_STATIC_INIT_BLOCK({ VirtualDeviceNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { VirtualDeviceNode::RegisterReflection(); } TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { @@ -192,10 +192,10 @@ VirtualDevice VirtualDeviceCache::Unique(const VirtualDevice& virtual_device) { virtual_device->target, virtual_device->memory_scope); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("target.VirtualDevice_ForDeviceTargetAndMemoryScope", VirtualDevice::ForDeviceTargetAndMemoryScope); -}); +} } // namespace tvm diff --git a/src/te/operation/compute_op.cc b/src/te/operation/compute_op.cc index 2b81e82da8b5..fa7424a7cda0 100644 --- a/src/te/operation/compute_op.cc +++ b/src/te/operation/compute_op.cc @@ -39,11 +39,11 @@ namespace tvm { namespace te { using namespace tir; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { OperationNode::RegisterReflection(); BaseComputeOpNode::RegisterReflection(); ComputeOpNode::RegisterReflection(); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { @@ -153,14 +153,14 @@ ComputeOp::ComputeOp(std::string name, std::string tag, ffi::Map> attrs, ffi::Array axis, ffi::Array body) { return ComputeOp(name, tag, attrs.value_or({}), axis, body); }); -}); +} // The schedule related logics ffi::Array ComputeOpNode::InputTensors() const { diff --git a/src/te/operation/create_primfunc.cc b/src/te/operation/create_primfunc.cc index 2a46579a1aed..24c16ab2683e 100644 --- a/src/te/operation/create_primfunc.cc +++ b/src/te/operation/create_primfunc.cc @@ -786,7 +786,7 @@ PrimFunc CreatePrimFunc(const ffi::Array& arg_list, return CreatePrimFuncWithConstants(arg_list, {}, index_dtype_override); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("te.CreatePrimFunc", [](ffi::PackedArgs args, ffi::Any* ret) { ffi::Array arg_list = args[0].cast>(); @@ -797,7 +797,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } *ret = CreatePrimFunc(arg_list, index_dtype_override); }); -}); +} // Relax version impl PrimFunc GenerateAndCompletePrimFunc(const ffi::Array& arg_tir_var_list, diff --git a/src/te/operation/extern_op.cc b/src/te/operation/extern_op.cc index ef18f26165ab..def64595412d 100644 --- a/src/te/operation/extern_op.cc +++ b/src/te/operation/extern_op.cc @@ -31,7 +31,7 @@ namespace tvm { namespace te { using namespace tir; -TVM_FFI_STATIC_INIT_BLOCK({ ExternOpNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ExternOpNode::RegisterReflection(); } // ExternOpNode TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) @@ -74,7 +74,7 @@ ExternOp::ExternOp(std::string name, std::string tag, ffi::Map ExternOpNode::InputTensors() const { return inputs; } diff --git a/src/te/operation/graph.cc b/src/te/operation/graph.cc index 561ad6e6c43b..bddea5f7f2d4 100644 --- a/src/te/operation/graph.cc +++ b/src/te/operation/graph.cc @@ -81,14 +81,14 @@ ffi::Array PostDFSOrder(const ffi::Array& roots, const Rea return post_order; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("schedule.CreateReadGraph", CreateReadGraph) .def("schedule.PostDFSOrder", [](const ffi::Array& roots, const ReadGraph& g) { return PostDFSOrder(roots, g); }); -}); +} } // namespace te } // namespace tvm diff --git a/src/te/operation/placeholder_op.cc b/src/te/operation/placeholder_op.cc index d7acfb32ef23..6c7d60841c0f 100644 --- a/src/te/operation/placeholder_op.cc +++ b/src/te/operation/placeholder_op.cc @@ -29,7 +29,7 @@ namespace tvm { namespace te { -TVM_FFI_STATIC_INIT_BLOCK({ PlaceholderOpNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { PlaceholderOpNode::RegisterReflection(); } // PlaceholderOpNode TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) @@ -62,7 +62,7 @@ Tensor placeholder(ffi::Array shape, DataType dtype, std::string name) return PlaceholderOp(name, shape, dtype).output(0); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("te.Placeholder", [](ffi::Variant> shape_arg, DataType dtype, std::string name) { @@ -77,7 +77,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ }(); return placeholder(shape, dtype, name); }); -}); +} ffi::Array PlaceholderOpNode::InputTensors() const { return {}; } diff --git a/src/te/operation/scan_op.cc b/src/te/operation/scan_op.cc index dfddaa3d9b38..fbc65e8a61fb 100644 --- a/src/te/operation/scan_op.cc +++ b/src/te/operation/scan_op.cc @@ -30,7 +30,7 @@ namespace tvm { namespace te { using namespace tir; -TVM_FFI_STATIC_INIT_BLOCK({ ScanOpNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ScanOpNode::RegisterReflection(); } TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { @@ -100,7 +100,7 @@ ScanOp::ScanOp(std::string name, std::string tag, data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "te.ScanOp", @@ -109,7 +109,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ffi::Array state_placeholder, ffi::Array inputs) { return ScanOp(name, tag, attrs, axis, init, update, state_placeholder, inputs); }); -}); +} ffi::Array scan(ffi::Array init, ffi::Array update, ffi::Array state_placeholder, ffi::Array inputs, diff --git a/src/te/tensor.cc b/src/te/tensor.cc index 027607e504ec..8035564b27f4 100644 --- a/src/te/tensor.cc +++ b/src/te/tensor.cc @@ -37,7 +37,7 @@ void TensorNode::RegisterReflection() { .def_ro("value_index", &TensorNode::value_index); } -TVM_FFI_STATIC_INIT_BLOCK({ TensorNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { TensorNode::RegisterReflection(); } IterVar thread_axis(Range dom, std::string tag) { return IterVar(dom, Var(tag, dom.defined() ? dom->extent.dtype() : DataType::Int(32)), @@ -113,13 +113,13 @@ Tensor::Tensor(ffi::Array shape, DataType dtype, Operation op, int val data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "te.Tensor", [](ffi::Array shape, DataType dtype, Operation op, int value_index) { return Tensor(shape, dtype, op, value_index); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& node, ReprPrinter* p) { @@ -128,7 +128,7 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) }); // Other tensor ops. -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("te.TensorEqual", &Tensor::operator==) @@ -140,7 +140,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ [](Operation op, int64_t output) { return op.output(static_cast(output)); }) .def_method("te.OpNumOutputs", &OperationNode::num_outputs) .def_method("te.OpInputTensors", &OperationNode::InputTensors); -}); +} } // namespace te } // namespace tvm diff --git a/src/tir/analysis/block_access_region_detector.cc b/src/tir/analysis/block_access_region_detector.cc index d0fd976a4fcb..aca06ad595bc 100644 --- a/src/tir/analysis/block_access_region_detector.cc +++ b/src/tir/analysis/block_access_region_detector.cc @@ -411,12 +411,12 @@ ffi::Array> GetBlockReadWriteRegion( return {reads, writes}; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.analysis.GetBlockAccessRegion", GetBlockAccessRegion) .def("tir.analysis.GetBlockReadWriteRegion", GetBlockReadWriteRegion); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/analysis/buffer_access_lca_detector.cc b/src/tir/analysis/buffer_access_lca_detector.cc index 07da2240a6da..67e8bda6f670 100644 --- a/src/tir/analysis/buffer_access_lca_detector.cc +++ b/src/tir/analysis/buffer_access_lca_detector.cc @@ -347,9 +347,9 @@ ffi::Map> DetectBufferAccessLCA(const PrimFunc& func return LCADetector::Detect(func); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.analysis.detect_buffer_access_lca", DetectBufferAccessLCA); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/analysis/calculate_allocated_memory.cc b/src/tir/analysis/calculate_allocated_memory.cc index 3a944273664c..557f42c5ba10 100644 --- a/src/tir/analysis/calculate_allocated_memory.cc +++ b/src/tir/analysis/calculate_allocated_memory.cc @@ -99,7 +99,7 @@ tvm::ffi::Map > CalculateAlloca return results; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tir.analysis.calculate_allocated_bytes", @@ -114,7 +114,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ throw; } }); -}); +} bool VerifyVTCMLimit(const IRModule& mod, Integer limit) { auto all_sizes = CalculateAllocatedBytes(mod); @@ -162,11 +162,11 @@ ffi::Array GetVTCMCompactionPasses() { return pass_list; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.analysis.get_vtcm_compaction_passes", []() { return GetVTCMCompactionPasses(); }); -}); +} namespace transform { @@ -200,10 +200,10 @@ Pass VerifyVTCMLimit(ffi::Optional default_target) { return tvm::transform::CreateModulePass(pass_func, 0, "tir.calculate_allocated_bytes", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.VerifyVTCMLimit", VerifyVTCMLimit); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/analysis/deep_equal.cc b/src/tir/analysis/deep_equal.cc index 9c2ea0f8442c..60a3e0d448d2 100644 --- a/src/tir/analysis/deep_equal.cc +++ b/src/tir/analysis/deep_equal.cc @@ -196,12 +196,12 @@ bool ExprDeepEqual::operator()(const PrimExpr& lhs, const PrimExpr& rhs) const { return ExprDeepEqualChecker::Check(lhs, rhs); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tir.analysis.expr_deep_equal", [](const PrimExpr& lhs, const PrimExpr& rhs) { return ExprDeepEqual()(lhs, rhs); }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/analysis/estimate_flops.cc b/src/tir/analysis/estimate_flops.cc index 300e3afcd6b1..3dca26749b11 100644 --- a/src/tir/analysis/estimate_flops.cc +++ b/src/tir/analysis/estimate_flops.cc @@ -247,7 +247,7 @@ double EstimateTIRFlops(const IRModule& mod) { return PostprocessResults(result) + cached_result; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.analysis.EstimateTIRFlops", [](ObjectRef obj) -> double { if (auto mod = obj.as()) { @@ -260,7 +260,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ throw; } }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/analysis/identify_memcpy.cc b/src/tir/analysis/identify_memcpy.cc index 76fbd75ba488..71f92900d892 100644 --- a/src/tir/analysis/identify_memcpy.cc +++ b/src/tir/analysis/identify_memcpy.cc @@ -283,7 +283,7 @@ std::optional IdentifyMemCpy(const For& loop, arith::Analyzer* an } // Expose the IdentifyMemCpy functionality to Python API for purpose of unit testing. -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.analysis._identify_memcpy", [](const Stmt& stmt) { ffi::Array output; @@ -314,7 +314,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return output; }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/analysis/is_pure_function.cc b/src/tir/analysis/is_pure_function.cc index f5c47a7cae00..a6a3fc4bc7f3 100644 --- a/src/tir/analysis/is_pure_function.cc +++ b/src/tir/analysis/is_pure_function.cc @@ -94,10 +94,10 @@ bool IsPureFunction(const PrimFunc& func, bool assert_on_error) { return PurityChecker::Check(func, assert_on_error); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.analysis.is_pure_function", IsPureFunction); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/analysis/oob_checker.cc b/src/tir/analysis/oob_checker.cc index fd08786efa5f..06deb7934ad0 100644 --- a/src/tir/analysis/oob_checker.cc +++ b/src/tir/analysis/oob_checker.cc @@ -124,10 +124,10 @@ transform::Pass OOBChecker() { return transform::CreatePrimFuncPass(pass_func, 0, "tir.analysis.OOBChecker", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.analysis.OOBChecker", OOBChecker); -}); +} } // namespace transform } // namespace tir } // namespace tvm diff --git a/src/tir/analysis/stmt_finding.cc b/src/tir/analysis/stmt_finding.cc index 779c96ccb1b8..9f6f4da7eaf3 100644 --- a/src/tir/analysis/stmt_finding.cc +++ b/src/tir/analysis/stmt_finding.cc @@ -140,7 +140,7 @@ const BlockNode* FindAnchorBlock(const IRModule& mod) { return nullptr; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.analysis.find_anchor_block", [](const IRModule& mod) { auto ret = FindAnchorBlock(mod); @@ -149,7 +149,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } return ffi::Optional(std::nullopt); }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/analysis/var_use_def_analysis.cc b/src/tir/analysis/var_use_def_analysis.cc index 0ce0402a8dff..becae607fb39 100644 --- a/src/tir/analysis/var_use_def_analysis.cc +++ b/src/tir/analysis/var_use_def_analysis.cc @@ -201,7 +201,7 @@ ffi::Array UndefinedVars(const PrimExpr& expr, const ffi::Array& args) return m.undefined_; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "tir.analysis.UndefinedVars", [](ffi::PackedArgs args, ffi::Any* rv) { @@ -213,6 +213,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ LOG(FATAL) << "either UndefinedVars(stmt, args) or UndefinedVars(expr, args) is expected"; } }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/analysis/verify_gpu_code.cc b/src/tir/analysis/verify_gpu_code.cc index 3b7ca0b080b5..e0273069cc46 100644 --- a/src/tir/analysis/verify_gpu_code.cc +++ b/src/tir/analysis/verify_gpu_code.cc @@ -324,10 +324,10 @@ bool VerifyGPUCode(const PrimFunc& func, ffi::Map constra return errs.size() == 0; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.analysis.verify_gpu_code", VerifyGPUCode); -}); +} namespace transform { @@ -352,10 +352,10 @@ Pass VerifyGPUCode(ffi::Map constraints) { return tvm::transform::CreateModulePass(pass_func, 0, "tir.VerifyGPUCode", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.VerifyGPUCode", VerifyGPUCode); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/analysis/verify_memory.cc b/src/tir/analysis/verify_memory.cc index 68b5e5c4e92d..a82de34716c8 100644 --- a/src/tir/analysis/verify_memory.cc +++ b/src/tir/analysis/verify_memory.cc @@ -187,10 +187,10 @@ std::vector VerifyMemory_(const PrimFunc& func) { bool VerifyMemory(const PrimFunc& func) { return VerifyMemory_(func).size() == 0; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.analysis.verify_memory", VerifyMemory); -}); +} namespace transform { @@ -215,10 +215,10 @@ Pass VerifyMemory() { return tvm::transform::CreateModulePass(pass_func, 0, "tir.VerifyMemory", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.VerifyMemory", VerifyMemory); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/analysis/verify_ssa.cc b/src/tir/analysis/verify_ssa.cc index 85d5ed057279..eafe28bd63a9 100644 --- a/src/tir/analysis/verify_ssa.cc +++ b/src/tir/analysis/verify_ssa.cc @@ -140,10 +140,10 @@ bool VerifySSA(const PrimFunc& func) { return visitor.is_ssa_; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.analysis.verify_ssa", VerifySSA); -}); +} namespace transform { @@ -159,10 +159,10 @@ Pass VerifySSA() { return tvm::transform::CreateModulePass(pass_func, 0, "tir.VerifySSA", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.VerifySSA", VerifySSA); -}); +} } // namespace transform diff --git a/src/tir/analysis/verify_well_formed.cc b/src/tir/analysis/verify_well_formed.cc index d9fd0831904c..2c8740f4f0ee 100644 --- a/src/tir/analysis/verify_well_formed.cc +++ b/src/tir/analysis/verify_well_formed.cc @@ -371,7 +371,7 @@ bool VerifyWellFormed(const IRModule& mod, bool assert_mode) { return true; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.analysis.VerifyWellFormed", [](const ObjectRef& obj, bool assert_mode) { @@ -384,7 +384,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ << obj->GetTypeKey(); } }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/ir/block_dependence_info.cc b/src/tir/ir/block_dependence_info.cc index 7626a1dcc496..3cda278d0a71 100644 --- a/src/tir/ir/block_dependence_info.cc +++ b/src/tir/ir/block_dependence_info.cc @@ -24,7 +24,7 @@ namespace tvm { namespace tir { -TVM_FFI_STATIC_INIT_BLOCK({ BlockDependenceInfoNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { BlockDependenceInfoNode::RegisterReflection(); } /** * @brief A helper class to collect and build Block Dependences using BlockScope class @@ -87,7 +87,7 @@ BlockDependenceInfo::BlockDependenceInfo(IRModule mod) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.BlockDependenceInfo", @@ -98,7 +98,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ auto it = self->stmt2ref.find(stmt.get()); return it != self->stmt2ref.end() ? it->second : ffi::Optional(std::nullopt); }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/ir/block_scope.cc b/src/tir/ir/block_scope.cc index 8caec68b49d0..676f162076ce 100644 --- a/src/tir/ir/block_scope.cc +++ b/src/tir/ir/block_scope.cc @@ -23,11 +23,11 @@ namespace tvm { namespace tir { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { StmtSRefNode::RegisterReflection(); DependencyNode::RegisterReflection(); BlockScopeNode::RegisterReflection(); -}); +} /******** Utility functions ********/ @@ -193,7 +193,7 @@ void SRefTreeCreator::VisitStmt_(const SeqStmtNode* seq_stmt) { /******** FFI ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.StmtSRefStmt", @@ -208,7 +208,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("tir.StmtSRefInlineMark", StmtSRef::InlineMark) .def_method("tir.BlockScopeGetDepsBySrc", &BlockScopeNode::GetDepsBySrc) .def_method("tir.BlockScopeGetDepsByDst", &BlockScopeNode::GetDepsByDst); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/ir/buffer.cc b/src/tir/ir/buffer.cc index 7376ff1f1249..87b9a2628cc7 100644 --- a/src/tir/ir/buffer.cc +++ b/src/tir/ir/buffer.cc @@ -38,7 +38,7 @@ namespace tvm { namespace tir { -TVM_FFI_STATIC_INIT_BLOCK({ BufferNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { BufferNode::RegisterReflection(); } using IndexMod = tir::FloorModNode; using IndexDiv = tir::FloorDivNode; @@ -644,7 +644,7 @@ tir::Buffer BufferWithOffsetAlignment(ffi::Array shape, DataType dtype offset_factor, buffer_type); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tir.Buffer", @@ -671,7 +671,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_method("tir.BufferVLoad", &Buffer::vload) .def_method("tir.BufferVStore", &Buffer::vstore) .def_method("tir.BufferStorageScope", &Buffer::scope); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/ir/data_layout.cc b/src/tir/ir/data_layout.cc index 18fea3c45c12..75f9bb50d15e 100644 --- a/src/tir/ir/data_layout.cc +++ b/src/tir/ir/data_layout.cc @@ -35,10 +35,10 @@ using tir::IterVar; using tir::IterVarNode; using tir::Var; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { LayoutNode::RegisterReflection(); BijectiveLayoutNode::RegisterReflection(); -}); +} const LayoutAxis LayoutAxis::UPPER_CASE[] = { LayoutAxis('A'), LayoutAxis('B'), LayoutAxis('C'), LayoutAxis('D'), LayoutAxis('E'), @@ -430,7 +430,7 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) << ")"; }); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.Layout", [](std::string name, DataType dtype) { return Layout(name, dtype); }) @@ -456,6 +456,6 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_method("tir.BijectiveLayoutBackwardIndex", &BijectiveLayout::BackwardIndex) .def_method("tir.BijectiveLayoutForwardShape", &BijectiveLayout::ForwardShape) .def_method("tir.BijectiveLayoutBackwardShape", &BijectiveLayout::BackwardShape); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/ir/expr.cc b/src/tir/ir/expr.cc index 646f2fd3fa08..252b8693a737 100644 --- a/src/tir/ir/expr.cc +++ b/src/tir/ir/expr.cc @@ -36,7 +36,7 @@ namespace tvm { namespace tir { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { VarNode::RegisterReflection(); SizeVarNode::RegisterReflection(); IterVarNode::RegisterReflection(); @@ -70,7 +70,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ShuffleNode::RegisterReflection(); CommReducerNode::RegisterReflection(); ReduceNode::RegisterReflection(); -}); +} /* \brief Convert an object to a PrimExpr * @@ -80,11 +80,11 @@ TVM_FFI_STATIC_INIT_BLOCK({ * `expr.dtype` field), this function allows the FFI conversions to be * explicitly invoked. */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.convert", [](ffi::Variant> expr) { return expr; }); -}); +} #define TVM_DEFINE_BINOP_CONSTRUCTOR(Name) \ Name::Name(PrimExpr a, PrimExpr b, Span span) { \ @@ -166,7 +166,7 @@ Var Var::copy_with_dtype(DataType dtype) const { return Var(new_ptr); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Var", [](ffi::String name_hint, ffi::AnyView type, Span span) { if (type.as()) { @@ -175,7 +175,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return Var(name_hint, type.cast(), span); } }); -}); +} // SizeVar SizeVar::SizeVar(ffi::String name_hint, DataType dtype, Span span) { @@ -196,11 +196,11 @@ SizeVar::SizeVar(ffi::String name_hint, Type type_annotation, Span span) { data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.SizeVar", [](ffi::String s, DataType t, Span span) { return SizeVar(s, t, span); }); -}); +} // IterVar IterVar::IterVar(Range dom, Var var, IterVarType t, ffi::String thread_tag, Span span) { @@ -222,13 +222,13 @@ IterVar::IterVar(Range dom, Var var, IterVarType t, ffi::String thread_tag, Span data_ = std::move(n); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tir.IterVar", [](Range dom, Var var, int iter_type, ffi::String thread_tag, Span span) { return IterVar(dom, var, static_cast(iter_type), thread_tag, span); }); -}); +} // StringImm StringImm::StringImm(ffi::String value, Span span) { @@ -239,11 +239,11 @@ StringImm::StringImm(ffi::String value, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.StringImm", [](ffi::String value, Span span) { return StringImm(value, span); }); -}); +} // Cast Cast::Cast(DataType t, PrimExpr value, Span span) { @@ -257,141 +257,141 @@ Cast::Cast(DataType t, PrimExpr value, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Cast", [](DataType dtype, PrimExpr value, Span span) { return Cast(dtype, value, span); }); -}); +} // Add TVM_DEFINE_BINOP_CONSTRUCTOR(Add); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Add", [](PrimExpr a, PrimExpr b, Span span) { return Add(a, b, span); }); -}); +} // Sub TVM_DEFINE_BINOP_CONSTRUCTOR(Sub); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Sub", [](PrimExpr a, PrimExpr b, Span span) { return Sub(a, b, span); }); -}); +} // Mul TVM_DEFINE_BINOP_CONSTRUCTOR(Mul); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Mul", [](PrimExpr a, PrimExpr b, Span span) { return Mul(a, b, span); }); -}); +} // Div TVM_DEFINE_BINOP_CONSTRUCTOR(Div); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Div", [](PrimExpr a, PrimExpr b, Span span) { return Div(a, b, span); }); -}); +} // Mod TVM_DEFINE_BINOP_CONSTRUCTOR(Mod); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Mod", [](PrimExpr a, PrimExpr b, Span span) { return Mod(a, b, span); }); -}); +} // FloorDiv TVM_DEFINE_BINOP_CONSTRUCTOR(FloorDiv); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.FloorDiv", [](PrimExpr a, PrimExpr b, Span span) { return FloorDiv(a, b, span); }); -}); +} // FloorMod TVM_DEFINE_BINOP_CONSTRUCTOR(FloorMod); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.FloorMod", [](PrimExpr a, PrimExpr b, Span span) { return FloorMod(a, b, span); }); -}); +} // Min TVM_DEFINE_BINOP_CONSTRUCTOR(Min); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Min", [](PrimExpr a, PrimExpr b, Span span) { return Min(a, b, span); }); -}); +} // Max TVM_DEFINE_BINOP_CONSTRUCTOR(Max); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Max", [](PrimExpr a, PrimExpr b, Span span) { return Max(a, b, span); }); -}); +} // EQ TVM_DEFINE_CMPOP_CONSTRUCTOR(EQ); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.EQ", [](PrimExpr a, PrimExpr b, Span span) { return EQ(a, b, span); }); -}); +} // NE TVM_DEFINE_CMPOP_CONSTRUCTOR(NE); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.NE", [](PrimExpr a, PrimExpr b, Span span) { return NE(a, b, span); }); -}); +} // LT TVM_DEFINE_CMPOP_CONSTRUCTOR(LT); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.LT", [](PrimExpr a, PrimExpr b, Span span) { return LT(a, b, span); }); -}); +} // LE TVM_DEFINE_CMPOP_CONSTRUCTOR(LE); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.LE", [](PrimExpr a, PrimExpr b, Span span) { return LE(a, b, span); }); -}); +} // GT TVM_DEFINE_CMPOP_CONSTRUCTOR(GT); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.GT", [](PrimExpr a, PrimExpr b, Span span) { return GT(a, b, span); }); -}); +} // GE TVM_DEFINE_CMPOP_CONSTRUCTOR(GE); -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.GE", [](PrimExpr a, PrimExpr b, Span span) { return GE(a, b, span); }); -}); +} // And And::And(PrimExpr a, PrimExpr b, Span span) { @@ -410,11 +410,11 @@ And::And(PrimExpr a, PrimExpr b, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.And", [](PrimExpr a, PrimExpr b, Span span) { return And(a, b, span); }); -}); +} // Or Or::Or(PrimExpr a, PrimExpr b, Span span) { @@ -433,10 +433,10 @@ Or::Or(PrimExpr a, PrimExpr b, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Or", [](PrimExpr a, PrimExpr b, Span span) { return Or(a, b, span); }); -}); +} // Not Not::Not(PrimExpr a, Span span) { @@ -451,10 +451,10 @@ Not::Not(PrimExpr a, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Not", [](PrimExpr a, Span span) { return Not(a, span); }); -}); +} // Select Select::Select(PrimExpr condition, PrimExpr true_value, PrimExpr false_value, Span span) { @@ -478,13 +478,13 @@ Select::Select(PrimExpr condition, PrimExpr true_value, PrimExpr false_value, Sp data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tir.Select", [](PrimExpr condition, PrimExpr true_value, PrimExpr false_value, Span span) { return Select(condition, true_value, false_value, span); }); -}); +} // Ramp Ramp::Ramp(PrimExpr base, PrimExpr stride, PrimExpr lanes, Span span) { @@ -518,12 +518,12 @@ Ramp::Ramp(PrimExpr base, PrimExpr stride, PrimExpr lanes, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Ramp", [](PrimExpr base, PrimExpr stride, PrimExpr lanes, Span span) { return Ramp(base, stride, lanes, span); }); -}); +} // Broadcast Broadcast::Broadcast(PrimExpr value, PrimExpr lanes, Span span) { @@ -551,12 +551,12 @@ Broadcast::Broadcast(PrimExpr value, PrimExpr lanes, Span span) { data_ = node; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Broadcast", [](PrimExpr value, PrimExpr lanes, Span span) { return Broadcast(value, lanes, span); }); -}); +} // Let Let::Let(Var var, PrimExpr value, PrimExpr body, Span span) { @@ -573,12 +573,12 @@ Let::Let(Var var, PrimExpr value, PrimExpr body, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Let", [](Var var, PrimExpr value, PrimExpr body, Span span) { return Let(var, value, body, span); }); -}); +} // Call Call::Call(DataType dtype, RelaxExpr op, ffi::Array args, Span span) { @@ -594,7 +594,7 @@ Call::Call(DataType dtype, RelaxExpr op, ffi::Array args, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tir.Call", @@ -628,7 +628,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } return Call(dtype.value_or(DataType::Void()), op, prim_expr_args, span); }); -}); +} // Shuffle Shuffle::Shuffle(ffi::Array vectors, ffi::Array indices, Span span) { @@ -671,13 +671,13 @@ PrimExpr Shuffle::ExtractElement(PrimExpr vector, int index, Span span) { return Shuffle({vector}, {Integer(index)}, span); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Shuffle", [](ffi::Array vectors, ffi::Array indices, Span span) { return Shuffle(vectors, indices, span); }); -}); +} // CommReducer CommReducer::CommReducer(ffi::Array lhs, ffi::Array rhs, ffi::Array result, @@ -733,7 +733,7 @@ ffi::Array CommReducerNode::operator()(ffi::Array a, return Substitute(this->result, value_map); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.CommReducer", @@ -741,7 +741,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ffi::Array identity_element, Span span) { return CommReducer(lhs, rhs, result, identity_element, span); }) .def_method("tir.CommReducerCombine", &tir::CommReducerNode::operator()); -}); +} // Reduce Reduce::Reduce(CommReducer combiner, ffi::Array source, ffi::Array axis, @@ -778,14 +778,14 @@ Reduce::Reduce(CommReducer combiner, ffi::Array source, ffi::Array source, ffi::Array axis, PrimExpr condition, int value_index, ffi::Array init, Span span) { return Reduce(combiner, source, axis, condition, value_index, init, span); }); -}); +} // BufferLoad void BufferLoadNode::LegalizeDType() { @@ -854,13 +854,13 @@ BufferLoad::BufferLoad(Buffer buffer, ffi::Array indices, data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.BufferLoad", [](Buffer buffer, ffi::Array indices, ffi::Optional predicate, Span span) { return BufferLoad(buffer, indices, predicate, span); }); -}); +} // ProducerLoad ProducerLoad::ProducerLoad(DataProducer producer, ffi::Array indices, Span span) { @@ -872,13 +872,13 @@ ProducerLoad::ProducerLoad(DataProducer producer, ffi::Array indices, data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.ProducerLoad", [](DataProducer producer, ffi::Array indices, Span span) { return ProducerLoad(producer, indices, span); }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/ir/function.cc b/src/tir/ir/function.cc index 9b4f559fd0a8..9daf09695086 100644 --- a/src/tir/ir/function.cc +++ b/src/tir/ir/function.cc @@ -31,10 +31,10 @@ namespace tvm { namespace tir { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { PrimFuncNode::RegisterReflection(); TensorIntrinNode::RegisterReflection(); -}); +} namespace { relax::StructInfo InferStructInfo(const PrimFunc& prim_func) { @@ -157,7 +157,7 @@ ffi::Optional TensorIntrin::Get(ffi::String name, bool allow_missi return (*it).second; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.PrimFunc", @@ -170,7 +170,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ }) .def("tir.TensorIntrinRegister", TensorIntrin::Register) .def("tir.TensorIntrinGet", TensorIntrin::Get); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/ir/index_map.cc b/src/tir/ir/index_map.cc index 0ac6a9ab341b..cdd1d8ad56d8 100644 --- a/src/tir/ir/index_map.cc +++ b/src/tir/ir/index_map.cc @@ -35,7 +35,7 @@ namespace tvm { namespace tir { -TVM_FFI_STATIC_INIT_BLOCK({ IndexMapNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { IndexMapNode::RegisterReflection(); } IndexMap::IndexMap(ffi::Array initial_indices, ffi::Array final_indices, ffi::Optional inverse_index_map) { @@ -423,7 +423,7 @@ IndexMap Substitute(const IndexMap& index_map, return IndexMap{index_map->initial_indices, new_output, new_inverse_map}; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.IndexMap", @@ -454,7 +454,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ auto result = forward.NonSurjectiveInverse(initial_ranges, &analyzer); return ffi::Array{result.first, result.second}; }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/ir/py_functor.cc b/src/tir/ir/py_functor.cc index 19be57ab4ecd..d2cf81eae795 100644 --- a/src/tir/ir/py_functor.cc +++ b/src/tir/ir/py_functor.cc @@ -826,20 +826,20 @@ class PyStmtExprMutator : public ObjectRef { // TVM Register // ================================================ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { PyStmtExprVisitorNode::RegisterReflection(); PyStmtExprMutatorNode::RegisterReflection(); -}); +} -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.MakePyStmtExprVisitor", PyStmtExprVisitor::MakePyStmtExprVisitor) .def("tir.MakePyStmtExprMutator", PyStmtExprMutator::MakePyStmtExprMutator); -}); +} // StmtExprVisitor -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.PyStmtExprVisitorDefaultVisitExpr", @@ -850,10 +850,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ [](PyStmtExprVisitor visitor, const Stmt& stmt) { visitor->VisitStmt(stmt); }) .def("tir.PyStmtExprVisitorVisitExpr", [](PyStmtExprVisitor visitor, const PrimExpr& expr) { visitor->VisitExpr(expr); }); -}); +} // StmtExprMutator -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.PyStmtExprMutatorDefaultVisitExpr", @@ -868,7 +868,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ [](PyStmtExprMutator mutator, const PrimExpr& expr) { return mutator->VisitExpr(expr); }) .def("tir.PyStmtExprMutatorVisitStmt", [](PyStmtExprMutator mutator, const Stmt& stmt) { return mutator->VisitStmt(stmt); }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/ir/script/script_complete.cc b/src/tir/ir/script/script_complete.cc index e94a3bfd9b82..bf2b333f2501 100644 --- a/src/tir/ir/script/script_complete.cc +++ b/src/tir/ir/script/script_complete.cc @@ -162,10 +162,10 @@ PrimFunc ScriptComplete(PrimFunc func, const ffi::Array& root_allocates) } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("script.Complete", ScriptComplete); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/ir/specialize.cc b/src/tir/ir/specialize.cc index 7e92cc4e6983..083dd8dedf31 100644 --- a/src/tir/ir/specialize.cc +++ b/src/tir/ir/specialize.cc @@ -434,10 +434,10 @@ PrimFunc Specialize(PrimFunc func, const ffi::Map(kind), body, thread_binding, annotations.value_or(ffi::Map()), span); }); -}); +} std::ostream& operator<<(std::ostream& out, ForKind type) { // NOLINT(*) switch (type) { @@ -226,12 +226,12 @@ While::While(PrimExpr condition, Stmt body, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.While", [](PrimExpr condition, Stmt body, Span span) { return While(condition, body, span); }); -}); +} // Allocate Allocate::Allocate(Var buffer_var, DataType dtype, ffi::Array extents, PrimExpr condition, @@ -277,7 +277,7 @@ int64_t AllocateNode::ConstantAllocationSize(const ffi::Array& extents return static_cast(result); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tir.Allocate", @@ -285,7 +285,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ffi::Map annotations, Span span) { return Allocate(buffer_var, type, extents, condition, body, annotations, span); }); -}); +} // Const // The constructor to create a IRNode with constant data @@ -340,7 +340,7 @@ int64_t AllocateConstNode::ConstantAllocationSize(const ffi::Array& ex } return static_cast(result); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tir.AllocateConst", @@ -349,7 +349,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return AllocateConst(buffer_var, dtype, extents, data_or_idx, body, annotations.value_or({}), span); }); -}); +} // DeclBuffer DeclBuffer::DeclBuffer(Buffer buffer, Stmt body, Span span) { @@ -360,12 +360,12 @@ DeclBuffer::DeclBuffer(Buffer buffer, Stmt body, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.DeclBuffer", [](Buffer buffer, Stmt body, Span span) { return DeclBuffer(buffer, body, span); }); -}); +} // SeqStmt SeqStmt::SeqStmt(ffi::Array seq, Span span) { @@ -394,11 +394,11 @@ SeqStmt::SeqStmt(ffi::Array seq, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tir.SeqStmt", [](ffi::Array seq, Span span) { return SeqStmt(std::move(seq), span); }); -}); +} // IfThenElse IfThenElse::IfThenElse(PrimExpr condition, Stmt then_case, ffi::Optional else_case, @@ -414,13 +414,13 @@ IfThenElse::IfThenElse(PrimExpr condition, Stmt then_case, ffi::Optional e data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.IfThenElse", [](PrimExpr condition, Stmt then_case, Stmt else_case, Span span) { return IfThenElse(condition, then_case, else_case, span); }); -}); +} // Evaluate Evaluate::Evaluate(PrimExpr value, Span span) { @@ -432,11 +432,11 @@ Evaluate::Evaluate(PrimExpr value, Span span) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Evaluate", [](PrimExpr value, Span span) { return Evaluate(value, span); }); -}); +} // BufferStore BufferStore::BufferStore(Buffer buffer, PrimExpr value, ffi::Array indices, @@ -514,14 +514,14 @@ BufferStore::BufferStore(Buffer buffer, PrimExpr value, ffi::Array ind data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.BufferStore", [](Buffer buffer, PrimExpr value, ffi::Array indices, ffi::Optional predicate, Span span) { return BufferStore(buffer, value, indices, predicate, span); }); -}); +} // BufferRealize BufferRealize::BufferRealize(Buffer buffer, ffi::Array bounds, PrimExpr condition, Stmt body, @@ -529,13 +529,13 @@ BufferRealize::BufferRealize(Buffer buffer, ffi::Array bounds, PrimExpr c data_ = ffi::make_object(buffer, bounds, condition, body, span); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.BufferRealize", [](Buffer buffer, ffi::Array bounds, PrimExpr condition, Stmt body, Span span) { return BufferRealize(buffer, bounds, condition, body, span); }); -}); +} // BufferRegion PrimExpr BufferRegionNode::ToPrimExpr() const { @@ -585,12 +585,12 @@ BufferRegion BufferRegion::FromPoint(Buffer buffer, ffi::Array indices return BufferRegion(buffer, region); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.BufferRegion", [](Buffer buffer, ffi::Array region) { return BufferRegion(buffer, region); }); -}); +} // MatchBufferRegion MatchBufferRegion::MatchBufferRegion(Buffer buffer, BufferRegion source) { @@ -643,12 +643,12 @@ MatchBufferRegion::MatchBufferRegion(Buffer buffer, BufferRegion source) { data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.MatchBufferRegion", [](Buffer buffer, BufferRegion source) { return MatchBufferRegion(buffer, source); }); -}); +} // Block Block::Block(ffi::Array iter_vars, ffi::Array reads, @@ -670,7 +670,7 @@ Block::Block(ffi::Array iter_vars, ffi::Array reads, data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.Block", [](ffi::Array iter_vars, ffi::Array reads, @@ -681,7 +681,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return Block(iter_vars, reads, writes, name_hint, body, init, alloc_buffers, match_buffers, annotations, span); }); -}); +} // BlockRealize BlockRealize::BlockRealize(ffi::Array values, PrimExpr predicate, Block block, @@ -697,13 +697,13 @@ BlockRealize::BlockRealize(ffi::Array values, PrimExpr predicate, Bloc data_ = std::move(node); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.BlockRealize", [](ffi::Array iter_values, PrimExpr predicate, Block block, Span span) { return BlockRealize(iter_values, predicate, block, span); }); -}); +} PrimExpr TypeAnnotation(DataType dtype, Span span) { static auto op = Op::Get("tir.type_annotation"); diff --git a/src/tir/ir/stmt_functor.cc b/src/tir/ir/stmt_functor.cc index 0e2759f3c4a4..80c787b11400 100644 --- a/src/tir/ir/stmt_functor.cc +++ b/src/tir/ir/stmt_functor.cc @@ -835,7 +835,7 @@ PrimExpr SubstituteWithDataTypeLegalization( return IRSubstituteWithDataTypeLegalization(vmap)(std::move(expr)); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.IRTransform", IRTransform) @@ -854,7 +854,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return Substitute(Downcast(node), vmap); } }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/ir/transform.cc b/src/tir/ir/transform.cc index 9f23b6948bd7..68b494d41144 100644 --- a/src/tir/ir/transform.cc +++ b/src/tir/ir/transform.cc @@ -145,9 +145,9 @@ Pass CreatePrimFuncPass(std::function return PrimFuncPass(std::move(pass_func), pass_info); } -TVM_FFI_STATIC_INIT_BLOCK({ PrimFuncPassNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { PrimFuncPassNode::RegisterReflection(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tir.transform.CreatePrimFuncPass", @@ -158,7 +158,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ }; return PrimFuncPass(wrapped_pass_func, pass_info); }); -}); +} TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) .set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { diff --git a/src/tir/op/op.cc b/src/tir/op/op.cc index ea6f91002182..700bc5f0e486 100644 --- a/src/tir/op/op.cc +++ b/src/tir/op/op.cc @@ -246,19 +246,19 @@ PrimExpr ret(PrimExpr value, Span span) { return tir::Call(value.dtype(), tir::builtin::ret(), {value}, span); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.ret", ret); -}); +} PrimExpr thread_return(Span span) { return tir::Call(DataType::Void(), tir::builtin::thread_return(), {}, span); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.thread_return", thread_return); -}); +} // maximum and min limits PrimExpr max_value(const DataType& dtype, Span span) { @@ -815,11 +815,11 @@ PrimExpr bitwise_neg(PrimExpr a, Span span) { return tir::Call(a.dtype(), tir::builtin::bitwise_not(), {a}, span); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.bitwise_not", [](PrimExpr a, Span span) { return bitwise_neg(a, span); }); -}); +} // pow PrimExpr pow(PrimExpr x, PrimExpr y, Span span) { @@ -1127,7 +1127,7 @@ TVM_TIR_REGISTER_OP("TVMBackendFreeWorkspace") .set_attr("TCallEffectKind", Integer(CallEffectKind::kOpaque)); // expose basic functions to node namespace -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("node._const", @@ -1158,7 +1158,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def("tir.trunc", tvm::trunc) .def("tir._cast", tvm::cast) .def("tir.reinterpret", tvm::reinterpret); -}); +} // operator overloading, smarter than make #define DEF_MAKE_BINARY_OP(Node, Func) \ @@ -1177,7 +1177,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } \ }) -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir._OpIfThenElse", @@ -1214,7 +1214,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .DEF_MAKE_BIT_OP(bitwise_xor, bitwise_xor) .DEF_MAKE_BIT_OP(left_shift, left_shift) // NOLINT(*) .DEF_MAKE_BIT_OP(right_shift, right_shift); -}); +} PrimExpr fast_erf_float_expr(PrimExpr arg, int bits) { auto plus_4 = make_const(DataType::Float(bits), 4.f); diff --git a/src/tir/schedule/analysis/analysis.cc b/src/tir/schedule/analysis/analysis.cc index 9607f02f1048..b0d712b5acc7 100644 --- a/src/tir/schedule/analysis/analysis.cc +++ b/src/tir/schedule/analysis/analysis.cc @@ -24,10 +24,10 @@ namespace tvm { namespace tir { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { TensorizeInfoNode::RegisterReflection(); AutoTensorizeMappingInfoNode::RegisterReflection(); -}); +} /******** IR Module ********/ @@ -335,13 +335,13 @@ bool IsReductionBlock(const ScheduleState& self, const StmtSRef& block_sref, return CheckReductionBlockErrorCode(self, block_sref, scope_root_sref) == 0; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tir.schedule.IsReductionBlock", [](Schedule sch, BlockRV block_rv, BlockRV scope_block_rv) { return IsReductionBlock(sch->state(), sch->GetSRef(block_rv), sch->GetSRef(scope_block_rv)); }); -}); +} void CheckReductionBlock(const ScheduleState& self, const StmtSRef& block_sref, const StmtSRef& scope_root_sref) { @@ -877,12 +877,12 @@ BlockRealize GetBlockRealize(const ScheduleState& self, const StmtSRef& block_sr } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.schedule.GetBlockRealize", [](Schedule sch, BlockRV block_rv) { return GetBlockRealize(sch->state(), sch->GetSRef(block_rv)); }); -}); +} IterVarType GetLoopIterType(const StmtSRef& loop_sref) { const ForNode* loop = TVM_SREF_TO_FOR(loop_sref); @@ -1500,12 +1500,12 @@ bool IsTrivialBinding(const ScheduleState& self, const StmtSRef& block_sref) { return true; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.schedule.IsTrivialBinding", [](Schedule sch, BlockRV block_rv) { return IsTrivialBinding(sch->state(), sch->GetSRef(block_rv)); }); -}); +} bool NeedsMultiLevelTiling(const ScheduleState& self, const StmtSRef& block_sref) { if (HasBeenMultiLevelTiled(block_sref)) { @@ -1908,7 +1908,7 @@ ffi::Optional GetTensorizeLoopMapping(const tir::ScheduleState& s return TensorizeInfo(ret); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.schedule.IsSpatialPrimFunc", IsSpatialPrimFunc) @@ -1916,7 +1916,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ PrimFunc desc_func, bool allow_padding) { return GetTensorizeLoopMapping(sch->state(), sch->GetSRef(block), desc_func, allow_padding); }); -}); +} /******** Auto Tensorization ********/ @@ -2141,7 +2141,7 @@ ffi::Optional GetAutoTensorizeMappingInfo( return AutoTensorizeMappingInfo(ret); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.schedule.GetAutoTensorizeMappingInfo", @@ -2165,7 +2165,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return "O"; } }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/schedule/analysis/layout.cc b/src/tir/schedule/analysis/layout.cc index eedf32ba06e8..ddc15ab5e592 100644 --- a/src/tir/schedule/analysis/layout.cc +++ b/src/tir/schedule/analysis/layout.cc @@ -240,7 +240,7 @@ ffi::Optional SuggestIndexMap(const Buffer& buffer, const ffi::Array

outputs) -> Instruction { return Instruction(kind, inputs, attrs, outputs); }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/schedule/primitive/decompose_padding.cc b/src/tir/schedule/primitive/decompose_padding.cc index fe76823b8972..5499ab9c58d0 100644 --- a/src/tir/schedule/primitive/decompose_padding.cc +++ b/src/tir/schedule/primitive/decompose_padding.cc @@ -533,13 +533,13 @@ bool CanDecomposePadding(ScheduleState self, const StmtSRef& block_sref, /******** FFI ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tir.schedule.CanDecomposePadding", [](Schedule self, BlockRV block_rv, LoopRV loop_rv) { return CanDecomposePadding(self->state(), self->GetSRef(block_rv), self->GetSRef(loop_rv)); }); -}); +} /******** InstructionKind Registration ********/ diff --git a/src/tir/schedule/primitive/reduction.cc b/src/tir/schedule/primitive/reduction.cc index f2b5613abbb5..49dc31e6f6e5 100644 --- a/src/tir/schedule/primitive/reduction.cc +++ b/src/tir/schedule/primitive/reduction.cc @@ -1351,7 +1351,7 @@ TVM_REGISTER_INST_KIND_TRAITS(DecomposeReductionTraits); /******** FFI ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def( "tir.schedule.RegisterReducer", @@ -1359,7 +1359,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ReducerRegistry::RegisterReducer(n_buffers, std::move(combiner_getter), std::move(identity_getter)); }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/schedule/schedule.cc b/src/tir/schedule/schedule.cc index 006a6e081755..96481542896e 100644 --- a/src/tir/schedule/schedule.cc +++ b/src/tir/schedule/schedule.cc @@ -22,10 +22,10 @@ namespace tvm { namespace tir { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { BlockRVNode::RegisterReflection(); LoopRVNode::RegisterReflection(); -}); +} /**************** Constructor ****************/ @@ -46,7 +46,7 @@ StmtSRef ScheduleNode::GetSRef(const StmtNode* stmt) const { /**************** FFI ****************/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("tir.schedule.ScheduleGetMod", &ScheduleNode::mod) @@ -57,11 +57,11 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_method("tir.schedule.ScheduleSeed", &ScheduleNode::Seed) .def_method("tir.schedule.ScheduleForkSeed", &ScheduleNode::ForkSeed) .def_method("tir.schedule.ScheduleWorkOn", &ScheduleNode::WorkOn); -}); +} /**************** (FFI) Constructor ****************/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.schedule.BlockRV", []() { return BlockRV(); }) @@ -80,11 +80,11 @@ TVM_FFI_STATIC_INIT_BLOCK({ static_cast(error_render_level), enable_check); }); -}); +} /******** (FFI) Lookup random variables ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.schedule.ScheduleGet", @@ -129,10 +129,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ LOG(FATAL) << "TypeError: Invalid type: " << obj->GetTypeKey(); throw; }); -}); +} /******** (FFI) Sampling ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("tir.schedule.ScheduleSampleCategorical", &ScheduleNode::SampleCategorical) @@ -141,9 +141,9 @@ TVM_FFI_STATIC_INIT_BLOCK({ &ScheduleNode::SamplePartitionedTile) .def_method("tir.schedule.ScheduleSampleComputeLocation", &ScheduleNode::SampleComputeLocation); -}); +} /******** (FFI) Get blocks & loops ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("tir.schedule.ScheduleGetBlock", &ScheduleNode::GetBlock) @@ -163,9 +163,9 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_method("tir.schedule.ScheduleGetProducers", &ScheduleNode::GetProducers) .def_method("tir.schedule.ScheduleGetConsumers", &ScheduleNode::GetConsumers) .def_method("tir.schedule.ScheduleGetOutputBlocks", &ScheduleNode::GetOutputBlocks); -}); +} /******** (FFI) Transform loops ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("tir.schedule.ScheduleMerge", &ScheduleNode::Merge) @@ -185,18 +185,18 @@ TVM_FFI_STATIC_INIT_BLOCK({ throw; } }); -}); +} /******** (FFI) Manipulate ForKind ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("tir.schedule.ScheduleParallel", &ScheduleNode::Parallel) .def_method("tir.schedule.ScheduleVectorize", &ScheduleNode::Vectorize) .def_method("tir.schedule.ScheduleBind", &ScheduleNode::Bind) .def_method("tir.schedule.ScheduleUnroll", &ScheduleNode::Unroll); -}); +} /******** (FFI) Insert cache stages ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("tir.schedule.ScheduleCacheRead", &ScheduleNode::CacheRead) @@ -210,40 +210,40 @@ TVM_FFI_STATIC_INIT_BLOCK({ return self->ReIndex(block_rv, buffer_index, static_cast(buffer_index_type)); }); -}); +} /******** (FFI) Data movement ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("tir.schedule.ScheduleReadAt", &ScheduleNode::ReadAt) .def_method("tir.schedule.ScheduleWriteAt", &ScheduleNode::WriteAt); -}); +} /******** (FFI) Compute location ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("tir.schedule.ScheduleComputeAt", &ScheduleNode::ComputeAt) .def_method("tir.schedule.ScheduleReverseComputeAt", &ScheduleNode::ReverseComputeAt) .def_method("tir.schedule.ScheduleComputeInline", &ScheduleNode::ComputeInline) .def_method("tir.schedule.ScheduleReverseComputeInline", &ScheduleNode::ReverseComputeInline); -}); +} /******** (FFI) Reduction ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("tir.schedule.ScheduleDecomposeReduction", &ScheduleNode::DecomposeReduction) .def_method("tir.schedule.ScheduleRFactor", &ScheduleNode::RFactor); -}); +} /******** (FFI) Block annotation ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("tir.schedule.ScheduleStorageAlign", &ScheduleNode::StorageAlign) .def_method("tir.schedule.ScheduleSetScope", &ScheduleNode::SetScope) .def_method("tir.schedule.ScheduleUnsafeSetDType", &ScheduleNode::UnsafeSetDType); -}); +} /******** (FFI) Blockize & Tensorize ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.schedule.ScheduleBlockize", @@ -266,10 +266,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ << rv->GetTypeKey() << ". Its value is: " << rv; } }); -}); +} /******** (FFI) Annotation ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.schedule.ScheduleAnnotate", @@ -296,10 +296,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ << ". Its value is: " << rv; throw; }); -}); +} /******** (FFI) Layout transformation ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.schedule.ScheduleTransformLayout", @@ -318,30 +318,30 @@ TVM_FFI_STATIC_INIT_BLOCK({ static_cast(buffer_index_type), axis_separators); }); -}); +} /******** (FFI) Padding decomposition ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("tir.schedule.ScheduleDecomposePadding", &ScheduleNode::DecomposePadding) .def_method("tir.schedule.SchedulePadEinsum", &ScheduleNode::PadEinsum); -}); +} /******** (FFI) Buffer transformation ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_method("tir.schedule.ScheduleRollingBuffer", &ScheduleNode::RollingBuffer); -}); +} /******** (FFI) Misc ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_method("tir.schedule.ScheduleEnterPostproc", &ScheduleNode::EnterPostproc) .def_method("tir.schedule.ScheduleUnsafeHideBufferAccess", &ScheduleNode::UnsafeHideBufferAccess); -}); +} /******** (FFI) Annotate buffer access ********/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.schedule.ScheduleAnnotateBufferAccess", [](Schedule self, const BlockRV& block_rv, int buffer_index, @@ -350,7 +350,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ block_rv, buffer_index, static_cast(buffer_index_type), index_map); }); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/schedule/state.cc b/src/tir/schedule/state.cc index d6d787e83650..c299f52fde55 100644 --- a/src/tir/schedule/state.cc +++ b/src/tir/schedule/state.cc @@ -23,7 +23,7 @@ namespace tvm { namespace tir { -TVM_FFI_STATIC_INIT_BLOCK({ ScheduleStateNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ScheduleStateNode::RegisterReflection(); } template using SMap = std::unordered_map; @@ -1016,7 +1016,7 @@ TVM_DLL ffi::Array GetCachedFlags(const ScheduleState& self, const StmtSRe /**************** FFI ****************/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.schedule.ScheduleState", @@ -1031,7 +1031,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ return it != self->stmt2ref.end() ? it->second : ffi::Optional(std::nullopt); }) .def("tir.schedule.ScheduleStateGetCachedFlags", GetCachedFlags); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/schedule/trace.cc b/src/tir/schedule/trace.cc index 02f99ddfd2a9..371aa0cb092d 100644 --- a/src/tir/schedule/trace.cc +++ b/src/tir/schedule/trace.cc @@ -23,7 +23,7 @@ namespace tvm { namespace tir { -TVM_FFI_STATIC_INIT_BLOCK({ TraceNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { TraceNode::RegisterReflection(); } /**************** Constructors ****************/ @@ -568,7 +568,7 @@ TVM_REGISTER_INST_KIND_TRAITS(EnterPostprocTraits); /**************** FFI ****************/ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.schedule.Trace", @@ -592,7 +592,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_method("tir.schedule.TraceWithDecision", &TraceNode::WithDecision) .def_method("tir.schedule.TraceSimplified", &TraceNode::Simplified) .def("tir.schedule.TraceApplyJSONToSchedule", Trace::ApplyJSONToSchedule); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/schedule/transform.cc b/src/tir/schedule/transform.cc index 032365e9f592..9c3da9f32bea 100644 --- a/src/tir/schedule/transform.cc +++ b/src/tir/schedule/transform.cc @@ -446,10 +446,10 @@ ffi::Optional TileWithTensorIntrin(const tir::Schedule& sch, const tir:: return reorder_suffix[0]; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.schedule.TileWithTensorIntrin", TileWithTensorIntrin); -}); +} /******** BlockBufferAccessSimplifier ********/ void BlockBufferAccessSimplifier::SimplifyAccessRegion( @@ -568,10 +568,10 @@ ffi::Optional NormalizePrimFunc(Schedule sch) { return ffi::Array{leaf_blocks, block_loops, block_iters, block_is_reduction}; } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.schedule.NormalizePrimFunc", NormalizePrimFunc); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/transforms/annotate_device_regions.cc b/src/tir/transforms/annotate_device_regions.cc index 310cb74e4ee6..47b3df5fdaa3 100644 --- a/src/tir/transforms/annotate_device_regions.cc +++ b/src/tir/transforms/annotate_device_regions.cc @@ -75,10 +75,10 @@ Pass AnnotateDeviceRegions() { return CreatePrimFuncPass(pass_func, 0, "tir.AnnotateDeviceRegions", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.AnnotateDeviceRegions", AnnotateDeviceRegions); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/bind_target.cc b/src/tir/transforms/bind_target.cc index 6e3b9ff853a4..9ec0a506a314 100644 --- a/src/tir/transforms/bind_target.cc +++ b/src/tir/transforms/bind_target.cc @@ -373,10 +373,10 @@ transform::Pass BindTarget(Target target) { return tir::transform::CreateModulePass(fpass, 0, "tir.BindTarget", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.BindTarget", BindTarget); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/bound_checker.cc b/src/tir/transforms/bound_checker.cc index c9ad70bf807a..99d990ece627 100644 --- a/src/tir/transforms/bound_checker.cc +++ b/src/tir/transforms/bound_checker.cc @@ -257,10 +257,10 @@ Pass InstrumentBoundCheckers() { return CreatePrimFuncPass(pass_func, 0, "tir.InstrumentBoundCheckers", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.InstrumentBoundCheckers", InstrumentBoundCheckers); -}); +} } // namespace transform diff --git a/src/tir/transforms/combine_context_call.cc b/src/tir/transforms/combine_context_call.cc index 2945c8e20f97..bd9d67352659 100644 --- a/src/tir/transforms/combine_context_call.cc +++ b/src/tir/transforms/combine_context_call.cc @@ -113,10 +113,10 @@ Pass CombineContextCall() { return CreatePrimFuncPass(pass_func, 0, "tir.CombineContextCall", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.CombineContextCall", CombineContextCall); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/common_subexpr_elim.cc b/src/tir/transforms/common_subexpr_elim.cc index 71f425c25048..dfeb7fe2e219 100644 --- a/src/tir/transforms/common_subexpr_elim.cc +++ b/src/tir/transforms/common_subexpr_elim.cc @@ -638,10 +638,10 @@ Pass CommonSubexprElimTIR(bool enable_cse_tir, bool identify_equiv_terms) { } // The pass can now be invoked via the pass infrastructure, but we also add a Python binding for it -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.CommonSubexprElimTIR", CommonSubexprElimTIR); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/compact_buffer_region.cc b/src/tir/transforms/compact_buffer_region.cc index 713ddcad298c..0ba4e75c3004 100644 --- a/src/tir/transforms/compact_buffer_region.cc +++ b/src/tir/transforms/compact_buffer_region.cc @@ -757,10 +757,10 @@ Pass CompactBufferAllocation(bool is_strict) { return CreatePrimFuncPass(pass_func, 0, "tir.CompactBufferAllocation", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.CompactBufferAllocation", CompactBufferAllocation); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/convert_blocks_to_opaque.cc b/src/tir/transforms/convert_blocks_to_opaque.cc index a359367ee70b..f187252b2e31 100644 --- a/src/tir/transforms/convert_blocks_to_opaque.cc +++ b/src/tir/transforms/convert_blocks_to_opaque.cc @@ -123,10 +123,10 @@ Pass ConvertBlocksToOpaque() { return CreatePrimFuncPass(pass_func, 0, "tir.ConvertBlocksToOpaque", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.ConvertBlocksToOpaque", ConvertBlocksToOpaque); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/convert_for_loops_serial.cc b/src/tir/transforms/convert_for_loops_serial.cc index 9b2554779360..a8b30ebf9101 100644 --- a/src/tir/transforms/convert_for_loops_serial.cc +++ b/src/tir/transforms/convert_for_loops_serial.cc @@ -67,10 +67,10 @@ Pass ConvertForLoopsToSerial() { return CreatePrimFuncPass(pass_func, 0, "tir.ConvertForLoopsToSerial", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.ConvertForLoopsToSerial", ConvertForLoopsToSerial); -}); +} } // namespace transform diff --git a/src/tir/transforms/decorate_device_scope.cc b/src/tir/transforms/decorate_device_scope.cc index a8c6b07c7602..ab0078a50ae0 100644 --- a/src/tir/transforms/decorate_device_scope.cc +++ b/src/tir/transforms/decorate_device_scope.cc @@ -45,10 +45,10 @@ Pass DecorateDeviceScope() { return CreatePrimFuncPass(pass_func, 0, "tir.DecorateDeviceScope", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.DecorateDeviceScope", DecorateDeviceScope); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/default_gpu_schedule.cc b/src/tir/transforms/default_gpu_schedule.cc index 2113136cf4cd..74c299456a4b 100644 --- a/src/tir/transforms/default_gpu_schedule.cc +++ b/src/tir/transforms/default_gpu_schedule.cc @@ -164,10 +164,10 @@ Pass DefaultGPUSchedule() { /*required=*/{}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.DefaultGPUSchedule", DefaultGPUSchedule); -}); +} } // namespace transform diff --git a/src/tir/transforms/extract_constants.cc b/src/tir/transforms/extract_constants.cc index 404a16fadf05..be5da45d9f6f 100644 --- a/src/tir/transforms/extract_constants.cc +++ b/src/tir/transforms/extract_constants.cc @@ -104,10 +104,10 @@ tvm::transform::Pass ExtractPrimFuncConstants() { return tvm::transform::CreateModulePass(pass_func, 0, "tir.ExtractPrimFuncConstants", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.ExtractPrimFuncConstants", ExtractPrimFuncConstants); -}); +} } // namespace transform diff --git a/src/tir/transforms/flatten_buffer.cc b/src/tir/transforms/flatten_buffer.cc index ffaa274e2871..1a9ba390703f 100644 --- a/src/tir/transforms/flatten_buffer.cc +++ b/src/tir/transforms/flatten_buffer.cc @@ -281,10 +281,10 @@ Pass FlattenBuffer() { return CreatePrimFuncPass(pass_func, 0, "tir.FlattenBuffer", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.FlattenBuffer", FlattenBuffer); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/force_narrow_index_to_i32.cc b/src/tir/transforms/force_narrow_index_to_i32.cc index 52d68460e8e3..711c2a739f59 100644 --- a/src/tir/transforms/force_narrow_index_to_i32.cc +++ b/src/tir/transforms/force_narrow_index_to_i32.cc @@ -87,10 +87,10 @@ Pass ForceNarrowIndexToInt32() { return CreatePrimFuncPass(pass_func, 0, "tir.NarrowDataType", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.ForceNarrowIndexToInt32", ForceNarrowIndexToInt32); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/hoist_expression.cc b/src/tir/transforms/hoist_expression.cc index 62bf21158258..ebd90583c93d 100644 --- a/src/tir/transforms/hoist_expression.cc +++ b/src/tir/transforms/hoist_expression.cc @@ -97,7 +97,7 @@ class HoistExpressionConfig : public Attrs { HoistExpressionConfigNode); }; -TVM_FFI_STATIC_INIT_BLOCK({ HoistExpressionConfigNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { HoistExpressionConfigNode::RegisterReflection(); } TVM_REGISTER_PASS_CONFIG_OPTION("tir.HoistExpression", HoistExpressionConfig); @@ -120,7 +120,7 @@ class HoistIfThenElseConfig : public Attrs { HoistIfThenElseConfigNode); }; -TVM_FFI_STATIC_INIT_BLOCK({ HoistIfThenElseConfigNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { HoistIfThenElseConfigNode::RegisterReflection(); } TVM_REGISTER_PASS_CONFIG_OPTION("tir.HoistIfThenElse", HoistIfThenElseConfig); @@ -560,10 +560,10 @@ Pass HoistExpression() { "tir.HoistExpression"); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.HoistExpression", HoistExpression); -}); +} Pass HoistIfThenElse() { auto pass_func = [=](PrimFunc f, IRModule m, PassContext ctx) { @@ -598,10 +598,10 @@ Pass HoistIfThenElse() { "tir.HoistIfThenElse"); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.HoistIfThenElse", HoistIfThenElse); -}); +} Pass HoistIfThenElseBasic() { auto pass_func = [=](PrimFunc f, IRModule m, PassContext ctx) { @@ -621,10 +621,10 @@ Pass HoistIfThenElseBasic() { "tir.HoistIfThenElseBasic"); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.HoistIfThenElseBasic", HoistIfThenElseBasic); -}); +} } // namespace transform diff --git a/src/tir/transforms/inject_double_buffer.cc b/src/tir/transforms/inject_double_buffer.cc index 710618f9f546..e874dc0564cf 100644 --- a/src/tir/transforms/inject_double_buffer.cc +++ b/src/tir/transforms/inject_double_buffer.cc @@ -51,7 +51,7 @@ class InjectDoubleBufferConfig : public Attrs { InjectDoubleBufferConfigNode); }; -TVM_FFI_STATIC_INIT_BLOCK({ InjectDoubleBufferConfigNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { InjectDoubleBufferConfigNode::RegisterReflection(); } TVM_REGISTER_PASS_CONFIG_OPTION("tir.InjectDoubleBuffer", InjectDoubleBufferConfig); @@ -326,10 +326,10 @@ Pass InjectDoubleBuffer() { return CreatePrimFuncPass(pass_func, 0, "tir.InjectDoubleBuffer", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.InjectDoubleBuffer", InjectDoubleBuffer); -}); +} } // namespace transform diff --git a/src/tir/transforms/inject_permuted_layout.cc b/src/tir/transforms/inject_permuted_layout.cc index b2433ee70a35..cdbe17508339 100644 --- a/src/tir/transforms/inject_permuted_layout.cc +++ b/src/tir/transforms/inject_permuted_layout.cc @@ -297,10 +297,10 @@ Pass InjectPermutedLayout() { return CreatePrimFuncPass(pass_func, 0, "tir.InjectPermutedLayout", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.InjectPermutedLayout", InjectPermutedLayout); -}); +} } // namespace transform diff --git a/src/tir/transforms/inject_ptx_async_copy.cc b/src/tir/transforms/inject_ptx_async_copy.cc index 8abcabae4048..0e9820aa659e 100644 --- a/src/tir/transforms/inject_ptx_async_copy.cc +++ b/src/tir/transforms/inject_ptx_async_copy.cc @@ -200,10 +200,10 @@ Pass InjectPTXAsyncCopy() { return CreatePrimFuncPass(pass_func, 0, "tir.InjectPTXAsyncCopy", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.InjectPTXAsyncCopy", InjectPTXAsyncCopy); -}); +} } // namespace transform diff --git a/src/tir/transforms/inject_ptx_ldg32.cc b/src/tir/transforms/inject_ptx_ldg32.cc index 3713531cfa37..1b4bd7b41088 100644 --- a/src/tir/transforms/inject_ptx_ldg32.cc +++ b/src/tir/transforms/inject_ptx_ldg32.cc @@ -124,10 +124,10 @@ Pass InjectPTXLDG32(bool enable_inject_ptx_intrin) { // The pass can now be invoked via the pass infrastructure, but we also add a // Python binding for it -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.InjectPTXLDG32", InjectPTXLDG32); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/inject_rolling_buffer.cc b/src/tir/transforms/inject_rolling_buffer.cc index 6fb4b94fdb0e..c3b41e05899b 100644 --- a/src/tir/transforms/inject_rolling_buffer.cc +++ b/src/tir/transforms/inject_rolling_buffer.cc @@ -316,10 +316,10 @@ Pass InjectRollingBuffer() { return CreatePrimFuncPass(pass_func, 0, "tir.InjectRollingBuffer", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.InjectRollingBuffer", InjectRollingBuffer); -}); +} } // namespace transform diff --git a/src/tir/transforms/inject_software_pipeline.cc b/src/tir/transforms/inject_software_pipeline.cc index 340c21140253..af1b7c8bdfa5 100644 --- a/src/tir/transforms/inject_software_pipeline.cc +++ b/src/tir/transforms/inject_software_pipeline.cc @@ -1263,10 +1263,10 @@ Pass InjectSoftwarePipeline() { return CreatePrimFuncPass(pass_func, 0, "tir.InjectSoftwarePipeline", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.InjectSoftwarePipeline", InjectSoftwarePipeline); -}); +} } // namespace transform diff --git a/src/tir/transforms/inject_virtual_thread.cc b/src/tir/transforms/inject_virtual_thread.cc index 9016ffdbf9fe..cd7283a7ef4d 100644 --- a/src/tir/transforms/inject_virtual_thread.cc +++ b/src/tir/transforms/inject_virtual_thread.cc @@ -524,10 +524,10 @@ Pass InjectVirtualThread() { return CreatePrimFuncPass(pass_func, 0, "tir.InjectVirtualThread", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.InjectVirtualThread", InjectVirtualThread); -}); +} } // namespace transform diff --git a/src/tir/transforms/inline_private_functions.cc b/src/tir/transforms/inline_private_functions.cc index 03d814333ca4..ce69053311d1 100644 --- a/src/tir/transforms/inline_private_functions.cc +++ b/src/tir/transforms/inline_private_functions.cc @@ -294,10 +294,10 @@ Pass InlinePrivateFunctions() { return tvm::transform::CreateModulePass(pass_func, 0, "tir.InlinePrivateFunctions", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.InlinePrivateFunctions", InlinePrivateFunctions); -}); +} } // namespace transform diff --git a/src/tir/transforms/ir_utils.cc b/src/tir/transforms/ir_utils.cc index cdebfcfcfa7a..dba13cfbbcf1 100644 --- a/src/tir/transforms/ir_utils.cc +++ b/src/tir/transforms/ir_utils.cc @@ -851,10 +851,10 @@ Pass ConvertSSA() { return tvm::transform::CreateModulePass(pass_func, 0, "tir.ConvertSSA", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.ConvertSSA", ConvertSSA); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/lift_thread_binding.cc b/src/tir/transforms/lift_thread_binding.cc index 0f643e5e18cb..2dffc11b7257 100644 --- a/src/tir/transforms/lift_thread_binding.cc +++ b/src/tir/transforms/lift_thread_binding.cc @@ -184,10 +184,10 @@ Pass LiftThreadBinding() { return CreatePrimFuncPass(pass_func, 0, "tir.LiftThreadBinding", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.LiftThreadBinding", LiftThreadBinding); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/loop_partition.cc b/src/tir/transforms/loop_partition.cc index a99c9311146b..e644c387cf5a 100644 --- a/src/tir/transforms/loop_partition.cc +++ b/src/tir/transforms/loop_partition.cc @@ -63,7 +63,7 @@ struct LoopPartitionConfigNode : public AttrsNodeReflAdapter fcond) { return tir::transform::CreatePrimFuncPass(fpass, 0, "tir.Filter", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("tir.transform.AnnotateEntryFunc", AnnotateEntryFunc) .def("tir.transform.Filter", Filter); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/profile_instrumentation.cc b/src/tir/transforms/profile_instrumentation.cc index d7763ee543b8..513f0d730e8c 100644 --- a/src/tir/transforms/profile_instrumentation.cc +++ b/src/tir/transforms/profile_instrumentation.cc @@ -284,10 +284,10 @@ Pass InstrumentProfileIntrinsics() { return tvm::transform::CreateModulePass(pass_func, 0, "tir.InstrumentProfileIntrinsics", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.InstrumentProfileIntrinsics", InstrumentProfileIntrinsics); -}); +} } // namespace transform diff --git a/src/tir/transforms/reduce_branching_through_overcompute.cc b/src/tir/transforms/reduce_branching_through_overcompute.cc index 6a3db99bc74e..9a03b143d0f9 100644 --- a/src/tir/transforms/reduce_branching_through_overcompute.cc +++ b/src/tir/transforms/reduce_branching_through_overcompute.cc @@ -61,7 +61,7 @@ class ReduceBranchingThroughOvercomputeConfig : public Attrs { ReduceBranchingThroughOvercomputeConfigNode); }; -TVM_FFI_STATIC_INIT_BLOCK({ ReduceBranchingThroughOvercomputeConfigNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { ReduceBranchingThroughOvercomputeConfigNode::RegisterReflection(); } TVM_REGISTER_PASS_CONFIG_OPTION("tir.ReduceBranchingThroughOvercompute", ReduceBranchingThroughOvercomputeConfig); @@ -175,11 +175,11 @@ Pass ReduceBranchingThroughOvercompute() { return CreatePrimFuncPass(pass_func, 0, "tir.ReduceBranchingThroughOvercompute", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.ReduceBranchingThroughOvercompute", ReduceBranchingThroughOvercompute); -}); +} } // namespace transform diff --git a/src/tir/transforms/remap_thread_axis.cc b/src/tir/transforms/remap_thread_axis.cc index 46fb38b48ba0..c7184e07a036 100644 --- a/src/tir/transforms/remap_thread_axis.cc +++ b/src/tir/transforms/remap_thread_axis.cc @@ -104,10 +104,10 @@ Pass RemapThreadAxis(ffi::Map thread_map) { return CreatePrimFuncPass(pass_func, 0, "tir.RemapThreadAxis", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.RemapThreadAxis", RemapThreadAxis); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/remove_assume.cc b/src/tir/transforms/remove_assume.cc index 95d55ed0a3f5..6475befa1cf8 100644 --- a/src/tir/transforms/remove_assume.cc +++ b/src/tir/transforms/remove_assume.cc @@ -62,10 +62,10 @@ Pass RemoveAssume() { return Sequential({RemoveAssumeInternal(), RemoveNoOp()}, "tir.RemoveAssume"); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.RemoveAssume", RemoveAssume); -}); +} } // namespace transform diff --git a/src/tir/transforms/remove_no_op.cc b/src/tir/transforms/remove_no_op.cc index 7d213c0ddda0..6cc80535085f 100644 --- a/src/tir/transforms/remove_no_op.cc +++ b/src/tir/transforms/remove_no_op.cc @@ -68,7 +68,7 @@ class RemoveNoOpConfig : public Attrs { TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(RemoveNoOpConfig, Attrs, RemoveNoOpConfigNode); }; -TVM_FFI_STATIC_INIT_BLOCK({ RemoveNoOpConfigNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { RemoveNoOpConfigNode::RegisterReflection(); } TVM_REGISTER_PASS_CONFIG_OPTION("tir.RemoveNoOp", RemoveNoOpConfig); @@ -332,10 +332,10 @@ Pass RemoveNoOp() { return CreatePrimFuncPass(pass_func, 0, "tir.RemoveNoOp", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.RemoveNoOp", RemoveNoOp); -}); +} } // namespace transform diff --git a/src/tir/transforms/remove_store_undef.cc b/src/tir/transforms/remove_store_undef.cc index 62b4391ef336..93cdd4ed145a 100644 --- a/src/tir/transforms/remove_store_undef.cc +++ b/src/tir/transforms/remove_store_undef.cc @@ -172,10 +172,10 @@ Pass RemoveStoreUndef() { "tir.RemoveStoreUndef"); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.RemoveStoreUndef", RemoveStoreUndef); -}); +} } // namespace transform diff --git a/src/tir/transforms/remove_weight_layout_rewrite_block.cc b/src/tir/transforms/remove_weight_layout_rewrite_block.cc index 561d46164b5a..5b2b5704c5c9 100644 --- a/src/tir/transforms/remove_weight_layout_rewrite_block.cc +++ b/src/tir/transforms/remove_weight_layout_rewrite_block.cc @@ -287,11 +287,11 @@ Pass RemoveWeightLayoutRewriteBlock(bool skip_tensor_rewrite) { return CreatePrimFuncPass(pass_func, 0, "tir.RemoveWeightLayoutRewriteBlock", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.RemoveWeightLayoutRewriteBlock", RemoveWeightLayoutRewriteBlock); -}); +} } // namespace transform diff --git a/src/tir/transforms/renew_defs.cc b/src/tir/transforms/renew_defs.cc index 47bbc73dfed6..69002a9e1d78 100644 --- a/src/tir/transforms/renew_defs.cc +++ b/src/tir/transforms/renew_defs.cc @@ -291,10 +291,10 @@ class RenewDefMutator : public StmtExprMutator { PrimFunc RenewDefs(const PrimFunc& func) { return RenewDefMutator::Transform(func); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.RenewDefs", RenewDefs); -}); +} } // namespace tir } // namespace tvm diff --git a/src/tir/transforms/renormalize_split_pattern.cc b/src/tir/transforms/renormalize_split_pattern.cc index bcb143f3323e..04dbcca510e1 100644 --- a/src/tir/transforms/renormalize_split_pattern.cc +++ b/src/tir/transforms/renormalize_split_pattern.cc @@ -206,10 +206,10 @@ Pass RenormalizeSplitPattern() { return CreatePrimFuncPass(pass_func, 0, "tir.RenormalizeSplitPattern", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.RenormalizeSplitPattern", RenormalizeSplitPattern); -}); +} } // namespace transform diff --git a/src/tir/transforms/rewrite_unsafe_select.cc b/src/tir/transforms/rewrite_unsafe_select.cc index 1d311f9bac13..3dfbcb9967d5 100644 --- a/src/tir/transforms/rewrite_unsafe_select.cc +++ b/src/tir/transforms/rewrite_unsafe_select.cc @@ -140,10 +140,10 @@ Pass RewriteUnsafeSelect() { return CreatePrimFuncPass(pass_func, 0, "tir.RewriteUnsafeSelect", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.RewriteUnsafeSelect", RewriteUnsafeSelect); -}); +} } // namespace transform diff --git a/src/tir/transforms/simplify.cc b/src/tir/transforms/simplify.cc index ffd91a324941..a3365db9b700 100644 --- a/src/tir/transforms/simplify.cc +++ b/src/tir/transforms/simplify.cc @@ -142,7 +142,7 @@ class SimplifyConfig : public Attrs { TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(SimplifyConfig, Attrs, SimplifyConfigNode); }; -TVM_FFI_STATIC_INIT_BLOCK({ SimplifyConfigNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { SimplifyConfigNode::RegisterReflection(); } TVM_REGISTER_PASS_CONFIG_OPTION("tir.Simplify", SimplifyConfig); @@ -362,10 +362,10 @@ Pass Simplify() { return CreatePrimFuncPass(pass_func, 0, "tir.Simplify", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.Simplify", Simplify); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/skip_assert.cc b/src/tir/transforms/skip_assert.cc index 6a9e62cd1ec7..b2c473c97c96 100644 --- a/src/tir/transforms/skip_assert.cc +++ b/src/tir/transforms/skip_assert.cc @@ -48,10 +48,10 @@ Pass SkipAssert() { return CreatePrimFuncPass(pass_func, 0, "tir.SkipAssert", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.SkipAssert", SkipAssert); -}); +} } // namespace transform diff --git a/src/tir/transforms/split_host_device.cc b/src/tir/transforms/split_host_device.cc index feeea7b3fcfe..130cc177f0b1 100644 --- a/src/tir/transforms/split_host_device.cc +++ b/src/tir/transforms/split_host_device.cc @@ -166,10 +166,10 @@ Pass SplitHostDevice() { return tvm::transform::CreateModulePass(pass_func, 0, "tir.SplitHostDevice", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.SplitHostDevice", SplitHostDevice); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/storage_rewrite.cc b/src/tir/transforms/storage_rewrite.cc index 9570a3f17f04..4af12c69a3b8 100644 --- a/src/tir/transforms/storage_rewrite.cc +++ b/src/tir/transforms/storage_rewrite.cc @@ -1764,10 +1764,10 @@ Pass StorageRewrite() { return CreatePrimFuncPass(pass_func, 0, "tir.StorageRewrite", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.StorageRewrite", StorageRewrite); -}); +} Pass PointerValueTypeRewrite() { auto pass_func = [](PrimFunc f, IRModule m, PassContext ctx) { @@ -1776,10 +1776,10 @@ Pass PointerValueTypeRewrite() { return CreatePrimFuncPass(pass_func, 0, "tir.PointerValueTypeRewrite", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.PointerValueTypeRewrite", PointerValueTypeRewrite); -}); +} } // namespace transform diff --git a/src/tir/transforms/tensorcore_infer_fragment.cc b/src/tir/transforms/tensorcore_infer_fragment.cc index 082f19e782ef..7c1b5b05d093 100644 --- a/src/tir/transforms/tensorcore_infer_fragment.cc +++ b/src/tir/transforms/tensorcore_infer_fragment.cc @@ -218,10 +218,10 @@ Pass InferFragment() { return CreatePrimFuncPass(pass_func, 0, "tir.InferFragment", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.InferFragment", InferFragment); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/thread_storage_sync.cc b/src/tir/transforms/thread_storage_sync.cc index bb8d733d880e..d41d474a0864 100644 --- a/src/tir/transforms/thread_storage_sync.cc +++ b/src/tir/transforms/thread_storage_sync.cc @@ -472,10 +472,10 @@ Pass ThreadSync(ffi::String storage_scope) { return CreatePrimFuncPass(pass_func, 0, "tir.ThreadSync", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.ThreadSync", ThreadSync); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/transform_mma_buffer_layout.cc b/src/tir/transforms/transform_mma_buffer_layout.cc index 626bc807dea0..60b6ffda3219 100644 --- a/src/tir/transforms/transform_mma_buffer_layout.cc +++ b/src/tir/transforms/transform_mma_buffer_layout.cc @@ -187,10 +187,10 @@ Pass TransformMmaBufferLayout() { return CreatePrimFuncPass(pass_func, 0, "tir.TransformMmaBufferLayout", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.TransformMmaBufferLayout", TransformMmaBufferLayout); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/unify_thread_binding.cc b/src/tir/transforms/unify_thread_binding.cc index 4da295980c50..fa1e221459c0 100644 --- a/src/tir/transforms/unify_thread_binding.cc +++ b/src/tir/transforms/unify_thread_binding.cc @@ -201,10 +201,10 @@ Pass UnifyThreadBinding() { return CreatePrimFuncPass(pass_func, 0, "tir.UnifyThreadBinding", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.UnifyThreadBinding", UnifyThreadBinding); -}); +} } // namespace transform diff --git a/src/tir/transforms/unroll_loop.cc b/src/tir/transforms/unroll_loop.cc index 544b89567877..d1269634ab4b 100644 --- a/src/tir/transforms/unroll_loop.cc +++ b/src/tir/transforms/unroll_loop.cc @@ -73,7 +73,7 @@ class UnrollLoopConfig : public Attrs { TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(UnrollLoopConfig, Attrs, UnrollLoopConfigNode); }; -TVM_FFI_STATIC_INIT_BLOCK({ UnrollLoopConfigNode::RegisterReflection(); }); +TVM_FFI_STATIC_INIT_BLOCK() { UnrollLoopConfigNode::RegisterReflection(); } TVM_REGISTER_PASS_CONFIG_OPTION("tir.UnrollLoop", UnrollLoopConfig); @@ -292,10 +292,10 @@ Pass UnrollLoop() { return CreatePrimFuncPass(pass_func, 0, "tir.UnrollLoop", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.UnrollLoop", UnrollLoop); -}); +} } // namespace transform diff --git a/src/tir/transforms/unsupported_dtype_legalize.cc b/src/tir/transforms/unsupported_dtype_legalize.cc index 2b26633ac4e4..ecdb9883d15f 100644 --- a/src/tir/transforms/unsupported_dtype_legalize.cc +++ b/src/tir/transforms/unsupported_dtype_legalize.cc @@ -759,10 +759,10 @@ Pass BF16ComputeLegalize() { return CreatePrimFuncPass(pass_func, 0, "tir.BF16ComputeLegalize", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.BF16ComputeLegalize", BF16ComputeLegalize); -}); +} Pass BF16StorageLegalize() { auto pass_func = [](PrimFunc f, IRModule m, PassContext ctx) { @@ -775,10 +775,10 @@ Pass BF16StorageLegalize() { return CreatePrimFuncPass(pass_func, 0, "tir.BF16StorageLegalize", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.BF16StorageLegalize", BF16StorageLegalize); -}); +} Pass FP8ComputeLegalize(ffi::String promote_dtype_str) { auto pass_func = [=](PrimFunc f, IRModule m, PassContext ctx) { @@ -791,10 +791,10 @@ Pass FP8ComputeLegalize(ffi::String promote_dtype_str) { return CreatePrimFuncPass(pass_func, 0, "tir.FP8ComputeLegalize", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.FP8ComputeLegalize", FP8ComputeLegalize); -}); +} Pass FP8StorageLegalize() { auto pass_func = [=](PrimFunc f, IRModule m, PassContext ctx) { @@ -807,10 +807,10 @@ Pass FP8StorageLegalize() { return CreatePrimFuncPass(pass_func, 0, "tir.FP8StorageLegalize", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.FP8StorageLegalize", FP8StorageLegalize); -}); +} } // namespace transform } // namespace tir diff --git a/src/tir/transforms/using_assume_to_reduce_branches.cc b/src/tir/transforms/using_assume_to_reduce_branches.cc index f7edeb25dde7..21f3dc43ba28 100644 --- a/src/tir/transforms/using_assume_to_reduce_branches.cc +++ b/src/tir/transforms/using_assume_to_reduce_branches.cc @@ -382,10 +382,10 @@ Pass UseAssumeToReduceBranches() { return CreatePrimFuncPass(pass_func, 0, "tir.UseAssumeToReduceBranches", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.UseAssumeToReduceBranches", UseAssumeToReduceBranches); -}); +} } // namespace transform diff --git a/src/tir/transforms/vectorize_loop.cc b/src/tir/transforms/vectorize_loop.cc index 5bf60d3b675a..857f0b4cea99 100644 --- a/src/tir/transforms/vectorize_loop.cc +++ b/src/tir/transforms/vectorize_loop.cc @@ -1021,10 +1021,10 @@ Pass VectorizeLoop(bool enable_vectorize) { return CreatePrimFuncPass(pass_func, 0, "tir.VectorizeLoop", {}); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tir.transform.VectorizeLoop", VectorizeLoop); -}); +} } // namespace transform diff --git a/src/topi/broadcast.cc b/src/topi/broadcast.cc index 65cbe3680572..c90b20877101 100644 --- a/src/topi/broadcast.cc +++ b/src/topi/broadcast.cc @@ -47,7 +47,7 @@ using namespace tvm::runtime; } \ }) -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("topi.broadcast_to", @@ -80,7 +80,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .TOPI_DEF_BCAST_OP("topi.not_equal", topi::not_equal) .TOPI_DEF_BCAST_OP("topi.greater_equal", topi::greater_equal) .TOPI_DEF_BCAST_OP("topi.less_equal", topi::less_equal); -}); +} } // namespace topi } // namespace tvm diff --git a/src/topi/einsum.cc b/src/topi/einsum.cc index 32131e975b3d..42c8c768d275 100644 --- a/src/topi/einsum.cc +++ b/src/topi/einsum.cc @@ -362,12 +362,12 @@ ffi::Array InferEinsumShape(const std::string& subscripts, return einsum_builder.InferShape(); } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("topi.einsum", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = einsum(args[0].cast(), args[1].cast>()); }); -}); +} } // namespace topi } // namespace tvm diff --git a/src/topi/elemwise.cc b/src/topi/elemwise.cc index 718f078dbe9f..922c40619908 100644 --- a/src/topi/elemwise.cc +++ b/src/topi/elemwise.cc @@ -31,7 +31,7 @@ namespace topi { using namespace tvm; using namespace tvm::runtime; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("topi.acos", [](ffi::PackedArgs args, @@ -119,7 +119,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_packed("topi.bitwise_not", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = bitwise_not(args[0].cast()); }); -}); +} } // namespace topi } // namespace tvm diff --git a/src/topi/nn.cc b/src/topi/nn.cc index e77508a912d5..1f8118231fae 100644 --- a/src/topi/nn.cc +++ b/src/topi/nn.cc @@ -45,7 +45,7 @@ using namespace tvm; using namespace tvm::runtime; /* Ops from nn.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed( @@ -84,44 +84,44 @@ TVM_FFI_STATIC_INIT_BLOCK({ nll_loss(args[0].cast(), args[1].cast(), args[2].cast(), args[3].cast(), args[4].cast()); }); -}); +} /* Ops from nn/dense.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("topi.nn.dense", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = nn::dense(args[0].cast(), args[1].cast(), args[2].cast(), args[3].cast()); }); -}); +} /* Ops from nn/bias_add.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("topi.nn.bias_add", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = nn::bias_add(args[0].cast(), args[1].cast(), args[2].cast()); }); -}); +} /* Ops from nn/dilate.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("topi.nn.dilate", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = nn::dilate(args[0].cast(), args[1].cast>(), args[2].cast()); }); -}); +} /* Ops from nn/flatten.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("topi.nn.flatten", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = nn::flatten(args[0].cast()); }); -}); +} /* Ops from nn/mapping.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("topi.nn.scale_shift_nchw", @@ -134,10 +134,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ *rv = nn::scale_shift_nhwc(args[0].cast(), args[1].cast(), args[2].cast()); }); -}); +} /* Ops from nn/pooling.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("topi.nn.pool_grad", @@ -201,10 +201,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ static_cast(args[5].cast()), args[6].cast(), args[7].cast(), args[8].cast()); }); -}); +} /* Ops from nn/softmax.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("topi.nn.softmax", @@ -219,10 +219,10 @@ TVM_FFI_STATIC_INIT_BLOCK({ *rv = nn::lrn(args[0].cast(), args[1].cast(), args[2].cast(), args[3].cast(), args[4].cast(), args[5].cast()); }); -}); +} /* Ops from nn/bnn.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("topi.nn.binarize_pack", @@ -232,46 +232,46 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_packed("topi.nn.binary_dense", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = nn::binary_dense(args[0].cast(), args[1].cast()); }); -}); +} /* Ops from nn/layer_norm.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("topi.nn.layer_norm", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = nn::layer_norm(args[0].cast(), args[1].cast(), args[2].cast(), args[3].cast>(), args[4].cast()); }); -}); +} /* Ops from nn/group_norm.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("topi.nn.group_norm", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = nn::group_norm(args[0].cast(), args[1].cast(), args[2].cast(), args[3].cast(), args[4].cast(), args[5].cast>(), args[6].cast()); }); -}); +} /* Ops from nn/instance_norm.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("topi.nn.instance_norm", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = nn::instance_norm(args[0].cast(), args[1].cast(), args[2].cast(), args[3].cast(), args[4].cast>(), args[5].cast()); }); -}); +} /* Ops from nn/rms_norm.h */ -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("topi.nn.rms_norm", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = nn::rms_norm(args[0].cast(), args[1].cast(), args[2].cast>(), args[3].cast()); }); -}); +} } // namespace topi } // namespace tvm diff --git a/src/topi/reduction.cc b/src/topi/reduction.cc index 503840df8aae..0f2a7f49fc73 100644 --- a/src/topi/reduction.cc +++ b/src/topi/reduction.cc @@ -32,7 +32,7 @@ namespace topi { using namespace tvm; using namespace tvm::runtime; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("topi.sum", @@ -78,7 +78,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ .def_packed("topi.collapse_sum", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = topi::collapse_sum(args[0].cast(), args[1].cast>()); }); -}); +} } // namespace topi } // namespace tvm diff --git a/src/topi/transform.cc b/src/topi/transform.cc index 911f9320b55a..d9545e637405 100644 --- a/src/topi/transform.cc +++ b/src/topi/transform.cc @@ -37,7 +37,7 @@ namespace topi { using namespace tvm; using namespace tvm::runtime; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("topi.expand_dims", @@ -268,7 +268,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ }) .def("topi.adv_index", [](te::Tensor x, ffi::Array indices) { return adv_index(x, indices); }); -}); +} } // namespace topi } // namespace tvm diff --git a/src/topi/utils.cc b/src/topi/utils.cc index a518d28f0277..6bc1570bd196 100644 --- a/src/topi/utils.cc +++ b/src/topi/utils.cc @@ -28,7 +28,7 @@ namespace tvm { namespace topi { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("topi.utils.is_empty_shape", @@ -46,7 +46,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ args[1].cast>(), args[2].cast(), args[3].cast()); }); -}); +} } // namespace topi } // namespace tvm diff --git a/src/topi/vision.cc b/src/topi/vision.cc index 8e6a5f4cbc06..7babb0591676 100644 --- a/src/topi/vision.cc +++ b/src/topi/vision.cc @@ -31,12 +31,12 @@ namespace topi { using namespace tvm; using namespace tvm::runtime; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("topi.vision.reorg", [](ffi::PackedArgs args, ffi::Any* rv) { *rv = vision::reorg(args[0].cast(), args[1].cast()); }); -}); +} } // namespace topi } // namespace tvm diff --git a/tests/cpp-runtime/hexagon/run_all_tests.cc b/tests/cpp-runtime/hexagon/run_all_tests.cc index e6793b530172..6ede0f119281 100644 --- a/tests/cpp-runtime/hexagon/run_all_tests.cc +++ b/tests/cpp-runtime/hexagon/run_all_tests.cc @@ -38,7 +38,7 @@ namespace tvm { namespace runtime { namespace hexagon { -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("hexagon.run_all_tests", [](ffi::PackedArgs args, ffi::Any* rv) { // gtest args are passed into this packed func as a singular string @@ -64,7 +64,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ::testing::InitGoogleTest(&argc, argv.data()); *rv = RUN_ALL_TESTS(); }); -}); +} } // namespace hexagon } // namespace runtime diff --git a/tests/cpp-runtime/hexagon/run_unit_tests.cc b/tests/cpp-runtime/hexagon/run_unit_tests.cc index 03f786b58b07..88b04dd963a1 100644 --- a/tests/cpp-runtime/hexagon/run_unit_tests.cc +++ b/tests/cpp-runtime/hexagon/run_unit_tests.cc @@ -80,7 +80,7 @@ class GtestPrinter : public testing::EmptyTestEventListener { std::string GetOutput() { return gtest_out_.str(); } }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("hexagon.run_unit_tests", [](ffi::PackedArgs args, ffi::Any* rv) { // gtest args are passed into this packed func as a singular string @@ -118,7 +118,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ *rv = gtest_error_code_and_output.str(); delete gprinter; }); -}); +} } // namespace hexagon } // namespace runtime diff --git a/tests/python/contrib/test_hexagon/README_RPC.md b/tests/python/contrib/test_hexagon/README_RPC.md index f1942d252f06..c70aa1e99087 100644 --- a/tests/python/contrib/test_hexagon/README_RPC.md +++ b/tests/python/contrib/test_hexagon/README_RPC.md @@ -80,7 +80,7 @@ Which eventually jumps to the following line in C++, which creates a RPC client [https://github.com/apache/tvm/blob/2cca934aad1635e3a83b712958ea83ff65704316/src/runtime/rpc/rpc_socket_impl.cc#L123-L129](https://github.com/apache/tvm/blob/2cca934aad1635e3a83b712958ea83ff65704316/src/runtime/rpc/rpc_socket_impl.cc#L123-L129) ```cpp -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("rpc.Connect", [](ffi::PackedArgs args, ffi::Any* rv) { auto url = args[0].cast(); @@ -89,7 +89,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ *rv = RPCClientConnect(url, port, key, ffi::PackedArgs(args.values + 3, args.type_codes + 3, args.size() - 3)); }); -}); +} ``` `tvm.contrib.hexagon.create_hexagon_session` is defined here. It establishes a link between android and hexagon, this code runs on android. @@ -98,7 +98,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ```cpp -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed( "tvm.contrib.hexagon.create_hexagon_session", [](ffi::PackedArgs args, ffi::Any* rv) { @@ -111,7 +111,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ auto sess = CreateClientSession(ep); *rv = CreateRPCSessionModule(sess); }); -}); +} ``` `HexagonTransportChannel` is the one that actually knows how to talk to Hexagon. It uses functions such as `hexagon_rpc_send`, `hexagon_rpc_receive` defined in diff --git a/web/emcc/tvmjs_support.cc b/web/emcc/tvmjs_support.cc index d658c094796e..467fbbd4ab03 100644 --- a/web/emcc/tvmjs_support.cc +++ b/web/emcc/tvmjs_support.cc @@ -302,12 +302,12 @@ class AsyncLocalSession : public LocalSession { } }; -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("wasm.LocalSession", []() { return CreateRPCSessionModule(std::make_shared()); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/web/emcc/wasm_runtime.cc b/web/emcc/wasm_runtime.cc index c0228a20b320..b7a1bd83e9eb 100644 --- a/web/emcc/wasm_runtime.cc +++ b/web/emcc/wasm_runtime.cc @@ -105,7 +105,7 @@ void LogMessageImpl(const std::string& file, int lineno, int level, const std::s } // namespace detail -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvmjs.testing.call", @@ -120,7 +120,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ ffi::Function pf = args[0].cast(); *ret = ffi::TypedFunction([pf]() { pf(); }); }); -}); +} void ArrayDecodeStorage(Tensor cpu_arr, std::string bytes, std::string format, std::string dtype) { if (format == "f32-to-bf16" && dtype == "float32") { @@ -143,13 +143,13 @@ void ArrayDecodeStorage(Tensor cpu_arr, std::string bytes, std::string format, s } } -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def("tvmjs.array.decode_storage", ArrayDecodeStorage); -}); +} // Concatenate n TVMArrays -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef().def_packed("tvmjs.runtime.ArrayConcat", [](ffi::PackedArgs args, ffi::Any* ret) { @@ -165,7 +165,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ } *ret = ffi::Array(data); }); -}); +} Tensor ConcatEmbeddings(const std::vector& embeddings) { // Get output shape @@ -202,7 +202,7 @@ Tensor ConcatEmbeddings(const std::vector& embeddings) { } // Concatenate n Tensors -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def_packed("tvmjs.runtime.ConcatEmbeddings", @@ -223,7 +223,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ nd.CopyToBytes(bytes.data(), size); return ffi::Bytes(bytes); }); -}); +} } // namespace runtime } // namespace tvm diff --git a/web/emcc/webgpu_runtime.cc b/web/emcc/webgpu_runtime.cc index 6c9f437303af..03d08f731b95 100644 --- a/web/emcc/webgpu_runtime.cc +++ b/web/emcc/webgpu_runtime.cc @@ -241,7 +241,7 @@ ffi::Module WebGPUModuleLoadFromBytes(const ffi::Bytes& bytes) { } // for now webgpu is hosted via a vulkan module. -TVM_FFI_STATIC_INIT_BLOCK({ +TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() .def("ffi.Module.load_from_bytes.webgpu", WebGPUModuleLoadFromBytes) @@ -249,7 +249,7 @@ TVM_FFI_STATIC_INIT_BLOCK({ DeviceAPI* ptr = WebGPUDeviceAPI::Global(); *rv = static_cast(ptr); }); -}); +} } // namespace runtime } // namespace tvm