SIGN IN SIGN UP

Cleanup operator class (#113)

Summary:
Pull Request resolved: https://github.com/pytorch/executorch/pull/113

This work is to improve memory efficiency on operator/kernel registration.

We deprecated `Operator` in favor of `Kernel` quite a while ago in the specialized kernels project. From then on `Operator` contains a fixed number ( 8 ) of kernels and the registry contains a fixed number (250) of `Operator`s. This is a waste of memory in two aspects:
1. We register prim ops unconditionally as `Operators` but they only have 1 kernel. This is a 8 times of waste.
2. We should be able to leverage selective build information on how many kernels are being registered for this build. This number can be passed in by a preprocessing flag.

To address this issue, this diff changes the 2-layer structure of Operator and Kernel, only store kernels in the registry.

The downside is that we may experience a slight regression on static init time `register_kernels()` call because now it needs to do a linear search and make sure there's no duplicate kernels in the registry. This is O(N^2).

Reviewed By: JacobSzwejbka

Differential Revision: D48619001

fbshipit-source-id: 4b9d5ad8bba288d0673f1b5c994911884974d86f
M
Mengwei Liu committed
792388f925500bd5ef799502dab6c8569f0d8a65
Parent: 8683882
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> on 8/24/2023, 5:56:57 PM