Operator registration and dispatch: how PyTorch selects a kernel算子注册与调度:PyTorch 如何选择内核
PyTorch separates operator schemas from implementations. The dispatcher combines tensor dispatch keys with thread-local state, selects an operator-specific table entry, and lets wrappers redispatch to lower layers. Autograd dispatch and gradient recording are separate decisions.PyTorch 将算子接口与实现分开注册。调度器合并张量的调度键与线程局部状态,从算子专属的调度表中选择入口;包装层再通过 redispatch 进入下层实现。进入 Autograd 调度层与记录反向图是两个不同的判断。