MAIAHooksInterface.h 1.2 KB

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