-
Notifications
You must be signed in to change notification settings - Fork 26.3k
First version of dispatcher #8713
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
Conversation
|
@pytorchbot retest this please |
| template<class Key_> | ||
| void emplace(Key_&& key, void* value) { | ||
| // TODO Locking | ||
| //std::unique_lock<std::shared_timed_mutex> lock(mutex_); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
|
||
| void erase(const Key& key) { | ||
| // TODO Locking | ||
| //std::unique_lock<std::shared_timed_mutex> lock(mutex_); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
caffe2/core/dispatch/DispatchTable.h
Outdated
|
|
||
| private: | ||
| ska::flat_hash_map<Key, void*> map_; | ||
| // TODO Figure out how to get fast locking in C++11 (use boost::shared_timed_mutex? folly::SharedMutex?) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
caffe2/core/dispatch/DispatchTable.h
Outdated
|
|
||
| auto result = map_.emplace(std::forward<Key>(key), value); | ||
| if (!result.second) { | ||
| throw std::logic_error("Tried to register conflicting operators to the dispatcher."); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| // TODO The current implementation below does not have the correct correctness characteristics | ||
| // which we need. It's worth spelling out exactly what we need: | ||
| // | ||
| // - We need LOCK FREE read access to the table (as per the performance benchmark |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
caffe2/core/dispatch/DispatchTable.h
Outdated
| * @param func Concrete function implementation to register | ||
| * @param dispatch_key Dispatch key to implement this function with | ||
| */ | ||
| void registerOp(typename Schema::signature::func_type* func, typename Schema::dispatch::dispatch_key_type dispatch_key) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
caffe2/core/dispatch/DispatchTable.h
Outdated
| auto dispatch_key = Schema::dispatch::dispatch_key(args...); | ||
| void* found = ops_.lookup(dispatch_key); | ||
| if (found == nullptr) { | ||
| throw std::logic_error("Didn't find operator to dispatch to"); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| * @tparam hasKernel Boolean for compile-time checking that a kernel is specified before finalizing the builder | ||
| * @tparam hasDispatchKey Boolean for compile-time checking thhat a dispatch key is specified before finalizing the builder | ||
| */ | ||
| template<class OpSchemaDef, bool hasKernel, bool hasDispatchKey> |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
dzhulgakov
left a comment
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.
Stamping to unblock - please address comments
caffe2/core/dispatch/DeviceId.h
Outdated
| case DeviceTypeId::CUDA: return stream << "DeviceTypeId(CUDA)"; | ||
| case DeviceTypeId::UNDEFINED: return stream << "DeviceTypeId(UNDEFINED)"; | ||
| } | ||
| throw std::logic_error("Unknown DeviceTypeId"); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This is a first version of the dispatcher. It uses multi-dispatch by default, but allows the operator schema to override that. It currently only defines unboxed kernel registration and unboxed calling APIs, boxed kernel registration and boxed calling APIs will come as well.