[PyTorch] Avoid registering ops into dispatcher in lightweight dispatch (#74664)
Summary:
This change adds the following logic:
If lightweight dispatch is enabled, do not generate `TORCH_LIBARAY` API calls for operator schema and implementations, since these operators will be registered into JIT op registry.
`skip_dispatcher_op_registration` is an existing argument to `gen.py`. With that set, `RegisterDispatchKey.cpp` will not generate `m.def` and `m.impl` for each native function. This logic will be removed once we find a better way to skip op registration into dispatcher.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/74664
Test Plan: Rely on unit tests for lightweight dispatch.
Reviewed By: priyaramani
Differential Revision: D34634300
Pulled By: larryliu0820
fbshipit-source-id: d87828f2c6c62f15024ce9e98823b09ee5a81336
(cherry picked from commit 3eb1c27547dea6accd9fa95496189f3699d91201)