Description
caffe2/core/export_caffe2_op_to_c10.h is still using the old API. Among other problems, @jackm321 ran into trouble because these were all having aliasing inferred conservatively when actually most of these functions are pure. Let's switch it to the new API.
1Change the macros to use the new operator API (c.f. https://pytorch.org/tutorials/advanced/dispatcher.html). For the most part, you should be able to do this directly in the macro definitions themselves, but for the C10_EXPORT_CAFFE2_OP_TO_C10_SCHEMA_ONLY
call, you will have to use TORCH_LIBRARY_FRAGMENT_THIS_API_IS_FOR_PER_OP_REGISTRATION_ONLY
to relax the restriction that all definitions are made in one place.
One fly in the ointment is the use of TORCH_LIBRARY_FRAGMENT_THIS_API_IS_FOR_PER_OP_REGISTRATION_ONLY
. When we designed TORCH_LIBRARY, we added the constraint that all operators for a namespace had to be declared in one place. However, the Caffe2 operators are pretty decentralized, and live in both fb/ and non-fb folders. This is making me wonder if we should keep caffe2 as a special namespace which is allowed to be registered anywhere you want (in keeping with Caffe2's historical nature). Otherwise, we will have to go on a renamespacing spree for all fb/ folder caffe2 operators, which seems like a lot of work for not much gain.
Activity