-
Notifications
You must be signed in to change notification settings - Fork 6k
[Compat] Update DispatchKey usage to c10::DispatchKey and replace dispatch_key_to_string with c10::toString
#78525
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
Changes from 1 commit
3d23d14
5330e7c
7480d3c
b9979f9
4cbea5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -238,7 +238,7 @@ void OperatorRegistry::register_implementation( | |
| auto& op = get_or_create_operator(qualified_name); | ||
| op.implementations[key] = std::move(func); | ||
| VLOG(3) << "Registered implementation: " << qualified_name << " for " | ||
| << dispatch_key_to_string(key); | ||
| << c10::toString(key); | ||
| } | ||
|
Comment on lines
236
to
244
|
||
|
|
||
| OperatorRegistration* OperatorRegistry::find_operator( | ||
|
|
@@ -257,7 +257,7 @@ void OperatorRegistry::print_all_operators() const { | |
| } | ||
| oss << " Implementations: "; | ||
| for (const auto& [key, impl] : op.implementations) { | ||
| oss << dispatch_key_to_string(key) << " "; | ||
| oss << c10::toString(key) << " "; | ||
| } | ||
| oss << std::endl; | ||
| } | ||
|
|
@@ -280,7 +280,7 @@ Library::Library(Kind kind, | |
| oss << "Created Library: kind=" << kind_to_string(kind) | ||
| << ", namespace=" << ns; | ||
| if (dispatch_key) { | ||
| oss << ", dispatch_key=" << dispatch_key_to_string(*dispatch_key); | ||
| oss << ", dispatch_key=" << c10::toString(*dispatch_key); | ||
| } | ||
|
Comment on lines
270
to
286
|
||
| VLOG(3) << oss.str() << std::endl; | ||
| } | ||
|
|
@@ -309,7 +309,7 @@ void Library::print_info() const { | |
| std::ostringstream oss; | ||
| oss << "Library Info: " << kind_to_string(kind_) << ", namespace=" << ns_; | ||
| if (dispatch_key_) { | ||
| oss << ", dispatch_key=" << dispatch_key_to_string(*dispatch_key_); | ||
| oss << ", dispatch_key=" << c10::toString(*dispatch_key_); | ||
| } | ||
| std::cout << oss.str() << std::endl; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |||||
| #include <type_traits> | ||||||
| #include <unordered_map> | ||||||
| #include <vector> | ||||||
| #include "c10/core/DispatchKey.h" | ||||||
|
||||||
| #include "c10/core/DispatchKey.h" | |
| #include <c10/core/DispatchKey.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个人家说的有道理,我们 compat 的统一用 <>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我对比了一下 torch,发现他们都是使用 c10::DispatchKey, 我们在这里保留这个 namespace 不太合适
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DispatchKey enum and dispatch_key_to_string() were removed, but this header still uses DispatchKey in multiple places (e.g., Library constructor/member, value_or(DispatchKey::CPU), and the TORCH_LIBRARY_IMPL macro uses torch::DispatchKey::k). As-is, this will not compile. Please either switch all remaining uses to c10::DispatchKey (and update DispatchKey::CPU etc), or introduce using DispatchKey = c10::DispatchKey; in namespace torch to keep the existing torch::DispatchKey references working (and update the .cpp definitions and tests accordingly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/skip-reason 编译过了就不影响效果