1 #include <c10/core/impl/DeviceGuardImplInterface.h> 2 #include <c10/macros/Macros.h> 3 4 namespace at { 5 namespace detail { 6 7 namespace { 8 9 struct VulkanGuardImpl final : public c10::impl::DeviceGuardImplInterface { 10 VulkanGuardImpl() = default; 11 12 // NOLINTNEXTLINE VulkanGuardImplat::detail::__anondc0a6ca10111::VulkanGuardImpl13 explicit VulkanGuardImpl(DeviceType t) { 14 TORCH_INTERNAL_ASSERT(t == DeviceType::Vulkan); 15 } 16 typeat::detail::__anondc0a6ca10111::VulkanGuardImpl17 DeviceType type() const override { 18 return DeviceType::Vulkan; 19 } exchangeDeviceat::detail::__anondc0a6ca10111::VulkanGuardImpl20 Device exchangeDevice(Device) const override { 21 // no-op 22 return Device(DeviceType::Vulkan, -1); 23 } getDeviceat::detail::__anondc0a6ca10111::VulkanGuardImpl24 Device getDevice() const override { 25 return Device(DeviceType::Vulkan, -1); 26 } setDeviceat::detail::__anondc0a6ca10111::VulkanGuardImpl27 void setDevice(Device) const override { 28 // no-op 29 } uncheckedSetDeviceat::detail::__anondc0a6ca10111::VulkanGuardImpl30 void uncheckedSetDevice(Device d) const noexcept override { 31 (void)d; 32 // no-op 33 } getStreamat::detail::__anondc0a6ca10111::VulkanGuardImpl34 Stream getStream(Device d) const noexcept override { 35 (void)d; 36 // no-op 37 return Stream(Stream::DEFAULT, Device(DeviceType::Vulkan, -1)); 38 } 39 // NB: These do NOT set the current device exchangeStreamat::detail::__anondc0a6ca10111::VulkanGuardImpl40 Stream exchangeStream(Stream s) const noexcept override { 41 (void)s; 42 // no-op 43 return Stream(Stream::DEFAULT, Device(DeviceType::Vulkan, -1)); 44 } deviceCountat::detail::__anondc0a6ca10111::VulkanGuardImpl45 DeviceIndex deviceCount() const noexcept override { 46 return 1; 47 } 48 49 // Event-related functions recordat::detail::__anondc0a6ca10111::VulkanGuardImpl50 void record( 51 void** event, 52 const Stream& stream, 53 const DeviceIndex device_index, 54 const EventFlag flag) const override { 55 (void)event; 56 (void)stream; 57 (void)device_index; 58 (void)flag; 59 TORCH_CHECK(false, "VULKAN backend doesn't support events."); 60 } blockat::detail::__anondc0a6ca10111::VulkanGuardImpl61 void block(void* event, const Stream& stream) const override { 62 (void)event; 63 (void)stream; 64 TORCH_CHECK(false, "VULKAN backend doesn't support events.") 65 } queryEventat::detail::__anondc0a6ca10111::VulkanGuardImpl66 bool queryEvent(void* event) const override { 67 (void)event; 68 TORCH_CHECK(false, "VULKAN backend doesn't support events.") 69 } destroyEventat::detail::__anondc0a6ca10111::VulkanGuardImpl70 void destroyEvent(void* event, const DeviceIndex device_index) 71 const noexcept override { 72 (void)event; 73 (void)device_index; 74 // no-op 75 } 76 }; 77 78 } // namespace 79 80 C10_REGISTER_GUARD_IMPL(Vulkan, VulkanGuardImpl); 81 82 } // namespace detail 83 } // namespace at 84