where set the dispatch key when i run m.impl(“myadd”, add_func).
I just found code in function Library::impl aten/src/ATen/core/library.cpp
, but where init this dispatch_key?
auto dispatch_key = f.dispatch_key_.has_value() ? f.dispatch_key_ : dispatch_key_;
class TorchLibraryInit final {
private:
using InitFn = void(Library&);
Library lib_;
public:
TorchLibraryInit(
Library::Kind kind,
InitFn* fn,
const char* ns,
c10::optional<c10::DispatchKey> k,
const char* file,
uint32_t line)
: lib_(kind, ns, k, file, line) { // init Library class
fn(lib_); // k in lib_ is dispatchKey
}
};