mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
`register_functional_op`: - constructs the functional variant of an op - registers a functionalization kernel to the op To get this to work: - `register_functional_op` makes assumptions that it checks about the op's schema. In particular, the op is not allowed to return anything it mutates. We can relax these constraints in the future. - We add a "boxed" python functionalization kernel that handles this case. I'm not actually sure (or convinced) this should be public API or how it should work. If we want this to be public, then it should probably be a torch.library API, but does that also mean we should give the same lifetime guarantees? If so, then it would be up to the user to construct a Library object to actually register the functional variant onto. Test Plan: - new tests Pull Request resolved: https://github.com/pytorch/pytorch/pull/102293 Approved by: https://github.com/bdhirsh