-
Notifications
You must be signed in to change notification settings - Fork 23.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[vulkan] Ops registration to TORCH_LIBRARY_IMPL #42194
Conversation
[ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit e467951 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 22 times. |
Differential Revision: [D22803036](https://our.internmc.facebook.com/intern/diff/D22803036) The main intention for this change is for the Vulkan Backend buck build. Where the Vulkan part can be optionally linked to general ATen compiled _without_ USE_VULKAN flag. For this, we have to remove all preprocessor logic based on `#ifdef USE_VULKAN`. These includes: - Registering Vulkan operators through TORCH_LIBRARY_IMPL and removing them from `native_functions.yaml` - Removing `aten/src/ATen/native/vulkan/stub/VulkanAtenStub.cpp` as it registered stubs for vulkan functions without linked Vulkan backend; Changing CMakeLists.txt associated with it - Removing preprocessor logic for incode dispatching to vulkan ops in `aten/src/ATen/native/Convolution.cpp`, `aten/src/ATen/native/AdaptiveAveragePooling.cpp`, `aten/src/ATen/native/Copy.cpp` - Vulkan ops in VulkanAten.cpp without registration in native_functions.yaml can be moved from namespace at::native to more specific at::native::vulkan::aten; Ops are registered in this file with TORCH_LIBRARY_IMPL. - copy is dispatched as CatchAll. As we do not have preprocessor flag USE_VULKAN, we need to have their code for logic if src or dst tensor is on Vulkan backend. The same for function `is_vulkan_available()` that we need for test guards and check if vulkan backend initialized successfully - it should be presented with and without Vulkan backend linked. So now it has `if` condition without preprocessor, that checks if src or dst is Vulkan then calls vulkan_copy from `aten/src/ATen/vulkan/Context.cpp`. `aten/src/ATen/vulkan/Context.cpp` contains runtime registration of `VulkanImplInterface*` and dispatches `vulkan_copy_` and `is_vulkan_available` to no-op if aten was not linked with Vulkan backend and to real implementation if it was linked with it. (Registration is placed in `VulkanAten.cpp`: ``` static at::vulkan::VulkanImplRegistrar g_vulkan_impl(new VulkanImpl()); ``` [ghstack-poisoned]
Differential Revision: [D22803036](https://our.internmc.facebook.com/intern/diff/D22803036) The main intention for this change is for the Vulkan Backend buck build. Where the Vulkan part can be optionally linked to general ATen compiled _without_ USE_VULKAN flag. For this, we have to remove all preprocessor logic based on `#ifdef USE_VULKAN`. These includes: - Registering Vulkan operators through TORCH_LIBRARY_IMPL and removing them from `native_functions.yaml` - Removing `aten/src/ATen/native/vulkan/stub/VulkanAtenStub.cpp` as it registered stubs for vulkan functions without linked Vulkan backend; Changing CMakeLists.txt associated with it - Removing preprocessor logic for incode dispatching to vulkan ops in `aten/src/ATen/native/Convolution.cpp`, `aten/src/ATen/native/AdaptiveAveragePooling.cpp`, `aten/src/ATen/native/Copy.cpp` - Vulkan ops in VulkanAten.cpp without registration in native_functions.yaml can be moved from namespace at::native to more specific at::native::vulkan::aten; Ops are registered in this file with TORCH_LIBRARY_IMPL. - copy is dispatched as CatchAll. As we do not have preprocessor flag USE_VULKAN, we need to have their code for logic if src or dst tensor is on Vulkan backend. The same for function `is_vulkan_available()` that we need for test guards and check if vulkan backend initialized successfully - it should be presented with and without Vulkan backend linked. So now it has `if` condition without preprocessor, that checks if src or dst is Vulkan then calls vulkan_copy from `aten/src/ATen/vulkan/Context.cpp`. `aten/src/ATen/vulkan/Context.cpp` contains runtime registration of `VulkanImplInterface*` and dispatches `vulkan_copy_` and `is_vulkan_available` to no-op if aten was not linked with Vulkan backend and to real implementation if it was linked with it. (Registration is placed in `VulkanAten.cpp`: ``` static at::vulkan::VulkanImplRegistrar g_vulkan_impl(new VulkanImpl()); ``` [ghstack-poisoned]
ghstack-source-id: 25670a6370336d01b340fdd4c502be7c55b72ebe Pull Request resolved: #42194
Differential Revision: [D22803036](https://our.internmc.facebook.com/intern/diff/D22803036) The main intention for this change is for the Vulkan Backend buck build. Where the Vulkan part can be optionally linked to general ATen compiled _without_ USE_VULKAN flag. For this, we have to remove all preprocessor logic based on `#ifdef USE_VULKAN`. These includes: - Registering Vulkan operators through TORCH_LIBRARY_IMPL and removing them from `native_functions.yaml` - Removing `aten/src/ATen/native/vulkan/stub/VulkanAtenStub.cpp` as it registered stubs for vulkan functions without linked Vulkan backend; Changing CMakeLists.txt associated with it - Removing preprocessor logic for incode dispatching to vulkan ops in `aten/src/ATen/native/Convolution.cpp`, `aten/src/ATen/native/AdaptiveAveragePooling.cpp`, `aten/src/ATen/native/Copy.cpp` - Vulkan ops in VulkanAten.cpp without registration in native_functions.yaml can be moved from namespace at::native to more specific at::native::vulkan::aten; Ops are registered in this file with TORCH_LIBRARY_IMPL. - copy is dispatched as CatchAll. As we do not have preprocessor flag USE_VULKAN, we need to have their code for logic if src or dst tensor is on Vulkan backend. The same for function `is_vulkan_available()` that we need for test guards and check if vulkan backend initialized successfully - it should be presented with and without Vulkan backend linked. So now it has `if` condition without preprocessor, that checks if src or dst is Vulkan then calls vulkan_copy from `aten/src/ATen/vulkan/Context.cpp`. `aten/src/ATen/vulkan/Context.cpp` contains runtime registration of `VulkanImplInterface*` and dispatches `vulkan_copy_` and `is_vulkan_available` to no-op if aten was not linked with Vulkan backend and to real implementation if it was linked with it. (Registration is placed in `VulkanAten.cpp`: ``` static at::vulkan::VulkanImplRegistrar g_vulkan_impl(new VulkanImpl()); ``` [ghstack-poisoned]
Differential Revision: [D22803036](https://our.internmc.facebook.com/intern/diff/D22803036) The main intention for this change is for the Vulkan Backend buck build. Where the Vulkan part can be optionally linked to general ATen compiled _without_ USE_VULKAN flag. For this, we have to remove all preprocessor logic based on `#ifdef USE_VULKAN`. These includes: - Registering Vulkan operators through TORCH_LIBRARY_IMPL and removing them from `native_functions.yaml` - Removing `aten/src/ATen/native/vulkan/stub/VulkanAtenStub.cpp` as it registered stubs for vulkan functions without linked Vulkan backend; Changing CMakeLists.txt associated with it - Removing preprocessor logic for incode dispatching to vulkan ops in `aten/src/ATen/native/Convolution.cpp`, `aten/src/ATen/native/AdaptiveAveragePooling.cpp`, `aten/src/ATen/native/Copy.cpp` - Vulkan ops in VulkanAten.cpp without registration in native_functions.yaml can be moved from namespace at::native to more specific at::native::vulkan::aten; Ops are registered in this file with TORCH_LIBRARY_IMPL. - copy is dispatched as CatchAll. As we do not have preprocessor flag USE_VULKAN, we need to have their code for logic if src or dst tensor is on Vulkan backend. The same for function `is_vulkan_available()` that we need for test guards and check if vulkan backend initialized successfully - it should be presented with and without Vulkan backend linked. So now it has `if` condition without preprocessor, that checks if src or dst is Vulkan then calls vulkan_copy from `aten/src/ATen/vulkan/Context.cpp`. `aten/src/ATen/vulkan/Context.cpp` contains runtime registration of `VulkanImplInterface*` and dispatches `vulkan_copy_` and `is_vulkan_available` to no-op if aten was not linked with Vulkan backend and to real implementation if it was linked with it. (Registration is placed in `VulkanAten.cpp`: ``` static at::vulkan::VulkanImplRegistrar g_vulkan_impl(new VulkanImpl()); ``` [ghstack-poisoned]
Differential Revision: [D22803036](https://our.internmc.facebook.com/intern/diff/D22803036) The main intention for this change is for the Vulkan Backend buck build. Where the Vulkan part can be optionally linked to general ATen compiled _without_ USE_VULKAN flag. For this, we have to remove all preprocessor logic based on `#ifdef USE_VULKAN`. These includes: - Registering Vulkan operators through TORCH_LIBRARY_IMPL and removing them from `native_functions.yaml` - Removing `aten/src/ATen/native/vulkan/stub/VulkanAtenStub.cpp` as it registered stubs for vulkan functions without linked Vulkan backend; Changing CMakeLists.txt associated with it - Removing preprocessor logic for incode dispatching to vulkan ops in `aten/src/ATen/native/Convolution.cpp`, `aten/src/ATen/native/AdaptiveAveragePooling.cpp`, `aten/src/ATen/native/Copy.cpp` - Vulkan ops in VulkanAten.cpp without registration in native_functions.yaml can be moved from namespace at::native to more specific at::native::vulkan::aten; Ops are registered in this file with TORCH_LIBRARY_IMPL. - copy is dispatched as CatchAll. As we do not have preprocessor flag USE_VULKAN, we need to have their code for logic if src or dst tensor is on Vulkan backend. The same for function `is_vulkan_available()` that we need for test guards and check if vulkan backend initialized successfully - it should be presented with and without Vulkan backend linked. So now it has `if` condition without preprocessor, that checks if src or dst is Vulkan then calls vulkan_copy from `aten/src/ATen/vulkan/Context.cpp`. `aten/src/ATen/vulkan/Context.cpp` contains runtime registration of `VulkanImplInterface*` and dispatches `vulkan_copy_` and `is_vulkan_available` to no-op if aten was not linked with Vulkan backend and to real implementation if it was linked with it. (Registration is placed in `VulkanAten.cpp`: ``` static at::vulkan::VulkanImplRegistrar g_vulkan_impl(new VulkanImpl()); ``` [ghstack-poisoned]
Differential Revision: [D22803036](https://our.internmc.facebook.com/intern/diff/D22803036) The main intention for this change is for the Vulkan Backend buck build. Where the Vulkan part can be optionally linked to general ATen compiled _without_ USE_VULKAN flag. For this, we have to remove all preprocessor logic based on `#ifdef USE_VULKAN`. These includes: - Registering Vulkan operators through TORCH_LIBRARY_IMPL and removing them from `native_functions.yaml` - Removing `aten/src/ATen/native/vulkan/stub/VulkanAtenStub.cpp` as it registered stubs for vulkan functions without linked Vulkan backend; Changing CMakeLists.txt associated with it - Removing preprocessor logic for incode dispatching to vulkan ops in `aten/src/ATen/native/Convolution.cpp`, `aten/src/ATen/native/AdaptiveAveragePooling.cpp`, `aten/src/ATen/native/Copy.cpp` - Vulkan ops in VulkanAten.cpp without registration in native_functions.yaml can be moved from namespace at::native to more specific at::native::vulkan::aten; Ops are registered in this file with TORCH_LIBRARY_IMPL. - copy is dispatched as CatchAll. As we do not have preprocessor flag USE_VULKAN, we need to have their code for logic if src or dst tensor is on Vulkan backend. The same for function `is_vulkan_available()` that we need for test guards and check if vulkan backend initialized successfully - it should be presented with and without Vulkan backend linked. So now it has `if` condition without preprocessor, that checks if src or dst is Vulkan then calls vulkan_copy from `aten/src/ATen/vulkan/Context.cpp`. `aten/src/ATen/vulkan/Context.cpp` contains runtime registration of `VulkanImplInterface*` and dispatches `vulkan_copy_` and `is_vulkan_available` to no-op if aten was not linked with Vulkan backend and to real implementation if it was linked with it. (Registration is placed in `VulkanAten.cpp`: ``` static at::vulkan::VulkanImplRegistrar g_vulkan_impl(new VulkanImpl()); ``` [ghstack-poisoned]
@IvanKobzarev merged this pull request in 3c66a37. |
@IvanKobzarev I'm super late to the party here, but I just want to point out that one other consequence of moving things out of |
It turns out that after #42194 landed we no longer actually generate any registrations into this file. That means it's completely unnecessary. Signed-off-by: Edward Z. Yang <ezyang@fb.com> [ghstack-poisoned]
It turns out that after #42194 landed we no longer actually generate any registrations into this file. That means it's completely unnecessary. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Differential Revision: [D24573518](https://our.internmc.facebook.com/intern/diff/D24573518) [ghstack-poisoned]
It turns out that after #42194 landed we no longer actually generate any registrations into this file. That means it's completely unnecessary. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Differential Revision: [D24573518](https://our.internmc.facebook.com/intern/diff/D24573518) [ghstack-poisoned]
It turns out that after #42194 landed we no longer actually generate any registrations into this file. That means it's completely unnecessary. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Differential Revision: [D24573518](https://our.internmc.facebook.com/intern/diff/D24573518) [ghstack-poisoned]
Summary: Pull Request resolved: #46938 It turns out that after #42194 landed we no longer actually generate any registrations into this file. That means it's completely unnecessary. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Test Plan: Imported from OSS Reviewed By: IvanKobzarev Differential Revision: D24573518 Pulled By: ezyang fbshipit-source-id: b41ada9e394b780f037f5977596a36b896b5648c
Stack from ghstack:
Differential Revision: D22803036
The main intention for this change is for the Vulkan Backend buck build.
Where the Vulkan part can be optionally linked to general ATen compiled without USE_VULKAN flag.
For this, we have to remove all preprocessor logic based on
#ifdef USE_VULKAN
.These includes:
Registering Vulkan operators through TORCH_LIBRARY_IMPL and removing them from
native_functions.yaml
Removing
aten/src/ATen/native/vulkan/stub/VulkanAtenStub.cpp
as it registered stubs for vulkan functions without linked Vulkan backend; Changing CMakeLists.txt associated with itRemoving preprocessor logic for incode dispatching to vulkan ops in
aten/src/ATen/native/Convolution.cpp
,aten/src/ATen/native/AdaptiveAveragePooling.cpp
,aten/src/ATen/native/Copy.cpp
Vulkan ops in VulkanAten.cpp without registration in native_functions.yaml can be moved from namespace at::native to more specific at::native::vulkan::aten; Ops are registered in this file with TORCH_LIBRARY_IMPL.
copy is dispatched as CatchAll. As we do not have preprocessor flag USE_VULKAN, we need to have their code for logic if src or dst tensor is on Vulkan backend.
The same for function
is_vulkan_available()
that we need for test guards and check if vulkan backend initialized successfully - it should be presented with and without Vulkan backend linked.So now it has
if
condition without preprocessor, that checks if src or dst is Vulkan then calls vulkan_copy fromaten/src/ATen/vulkan/Context.cpp
.aten/src/ATen/vulkan/Context.cpp
contains runtime registration ofVulkanImplInterface*
and dispatchesvulkan_copy_
andis_vulkan_available
to no-op if aten was not linked with Vulkan backend and to real implementation if it was linked with it. (Registration is placed inVulkanAten.cpp
: