1 #pragma once 2 3 #include <c10/util/Exception.h> 4 #include <c10/util/Registry.h> 5 6 // NB: Class must live in `at` due to limitations of Registry.h. 7 namespace at { 8 9 struct TORCH_API MAIAHooksInterface { 10 // This should never actually be implemented, but it is used to 11 // squelch -Werror=non-virtual-dtor 12 virtual ~MAIAHooksInterface() = default; 13 showConfigMAIAHooksInterface14 virtual std::string showConfig() const { 15 TORCH_CHECK(false, "Cannot query detailed MAIA version information."); 16 } 17 }; 18 19 // NB: dummy argument to suppress "ISO C++11 requires at least one argument 20 // for the "..." in a variadic macro" 21 struct TORCH_API MAIAHooksArgs {}; 22 23 TORCH_DECLARE_REGISTRY(MAIAHooksRegistry, MAIAHooksInterface, MAIAHooksArgs); 24 #define REGISTER_MAIA_HOOKS(clsname) \ 25 C10_REGISTER_CLASS(MAIAHooksRegistry, clsname, clsname) 26 27 namespace detail { 28 TORCH_API const MAIAHooksInterface& getMAIAHooks(); 29 } // namespace detail 30 31 } // namespace at 32