How the ops are registerd to ATenDispatch's op tables_

I want to know how ops are registered to ATenDispatch’s op_tables_;
I see ATenDispatch has registerOp/registerVariableOp interface, but not found code that these interfaces are called to register ops;
Is ATenDispatch use the global static varable to trigger the registration like C10_DECLARE_REGISTRY mechanism?

I see the code below, but cannot find where “aten::linear(Tensor input, Tensor weight, Tensor? bias=None) -> Tensor” is registered to ATenDispatch.

static inline Tensor linear(const Tensor & input, const Tensor & weight, const Tensor & bias) { static auto table = globalATenDispatch().getOpTable("aten::linear(Tensor input, Tensor weight, Tensor? bias=None) -> Tensor"); return table->getOp<Tensor (const Tensor &, const Tensor &, const Tensor &)>(at::detail::infer_backend(input), at::detail::infer_is_variable(input))(input, weight, bias); }

After effort. I see where the registerOp/registerVariableOp are called===>In auto generated code like CPUType. cpp, also use global static varable to register ops.

1 Like

Thank you!
Although ”convolution“ is not in CPUType.cpp, but it’s in TypeDefault.cpp use TORCH_LIBRARY to register.
Do you have any idea which DispatchKey it use?