Context.h 936 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
  2. #ifndef MetalContext_h
  3. #define MetalContext_h
  4. #include <atomic>
  5. #include <ATen/Tensor.h>
  6. namespace at::metal {
  7. struct MetalInterface {
  8. virtual ~MetalInterface() = default;
  9. virtual bool is_metal_available() const = 0;
  10. virtual at::Tensor& metal_copy_(at::Tensor& self, const at::Tensor& src)
  11. const = 0;
  12. };
  13. extern std::atomic<const MetalInterface*> g_metal_impl_registry;
  14. class MetalImplRegistrar {
  15. public:
  16. explicit MetalImplRegistrar(MetalInterface* /*impl*/);
  17. };
  18. at::Tensor& metal_copy_(at::Tensor& self, const at::Tensor& src);
  19. } // namespace at::metal
  20. namespace at::native {
  21. bool is_metal_available();
  22. } // namespace at::native
  23. #endif /* MetalContext_h */
  24. #else
  25. #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
  26. #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)