Add basic ltc codegen to staging branch (#64104)
This is a working minimal version of codegen for lazy tensor IR node classes, nativefunction impls that build IR nodes, and TorchScript lowering functions. Some care has been taken to align this with the pytorch core codegen infra in a way that will be easy to land to master in the future.
This adds support for a new 'full_codegen' field to the backend YAML file. Ops listed under `full_codegen` get everything that ops listed under the old `supported` field get (nativefunction decls and dispatcher registrations), but in addition they also get nativefunction implementations, IR node classes, and TS lowerings.
Groundwork is laid for shape inference based on structured kernels. Structured kernels (identifiable by the `structured` or `structured_delegate` keywords in native_function.yaml) provide a separate function from their main kernel operator that performs shape inference and bounds checks. This function can be reached by calling at::meta::{op}() or even by converting tensors .to(kMeta) and then invoking at::op() with those meta tensors. The resulting meta tensor can be queried for shape and dtype. This will be the canonical source of truth for lazy IR. Structured kernels aren't implemented for all ATen ops though, so for the missing ones we have to infer shapes/dtypes another way. For this purpose, I also codegen declarations for 'shape_' and 'dtype_' inference functions for each op that is marked as `full_codegen` but is missing a structured kernel in pytorch core.
As for what's not complete, there are a few known things that I plan to address (or have others work on) in following PRs, and get to a clean state before we'd merge the final thing back to pytorch master.
* It has only been tested on a couple ops, but has been tested with at least one structured and unstructured op
* missing support for some dtypes in the codegen (process_ir_nodes) - should be easy to incrementally complete this, or, rigorously complete it in a focused effort.
* need refactoring for TS lowering code - see TODOs referring to hacks there