Remove trivial dispatch_key_allowlist_check function (#146169)

Hmmm...this _is_ removing a public function from a public C++ file. But the GH counts for this function total 83, seemingly all copying pytorch: https://github.com/search?q=dispatch_key_allowlist_check&type=code&p=1

Pull Request resolved: https://github.com/pytorch/pytorch/pull/146169
Approved by: https://github.com/albanD, https://github.com/zou3519
This commit is contained in:
Jane Xu 2025-01-31 08:28:21 -08:00 committed by PyTorch MergeBot
parent ec2522e200
commit 8b8c596503
2 changed files with 1 additions and 17 deletions

View file

@ -178,18 +178,4 @@ constexpr bool op_allowlist_contains_name_in_schema(std::string_view allowlist,
return allowlist_contains(allowlist, schema.substr(0, schema.find('(')));
}
// Returns true iff the given dispatch key is on the allowlist
// and should be registered. When we turn this on, the list of valid
// mobile dispatch keys is hard coded (but you need to make sure
// that you have the correct set of dispatch keys for this).
constexpr bool dispatch_key_allowlist_check(DispatchKey /*k*/) {
#ifdef C10_MOBILE
return true;
// Disabled for now: to be enabled later!
// return k == DispatchKey::CPU || k == DispatchKey::Vulkan || k == DispatchKey::QuantizedCPU || k == DispatchKey::BackendSelect || k == DispatchKey::CatchAll;
#else
return true;
#endif
}
} // namespace c10::impl

View file

@ -1027,9 +1027,7 @@ class TorchLibraryInit final {
static const torch::detail::TorchLibraryInit C10_CONCATENATE( \
TORCH_LIBRARY_IMPL_static_init_##ns##_##k##_, uid)( \
torch::Library::IMPL, \
(c10::impl::dispatch_key_allowlist_check(c10::DispatchKey::k) \
? &C10_CONCATENATE(TORCH_LIBRARY_IMPL_init_##ns##_##k##_, uid) \
: [](torch::Library&) -> void {}), \
&C10_CONCATENATE(TORCH_LIBRARY_IMPL_init_##ns##_##k##_, uid), \
#ns, \
std::make_optional(c10::DispatchKey::k), \
__FILE__, \