[caffe2] move the SaveOp implementation from a header to a .cc file (#53298)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/53298
This is a re-land of D26641600 (https://github.com/pytorch/pytorch/commit/3969391c0732bd1e6329438664dba3d7f5ee74b7), but with the `SaveOpImpl` class marked as
`TORCH_API` to ensure that its symbols get exported properly in shared library
builds.
This moves the `SaveOp` code from `load_save_op.h` to `load_save_op.cc`.
Previously this implementation was all in the templatized `SaveOp` class, even
though most of the logic didn't depend on the template parameters. Having
this code be in the header file slows down the build, and forces more files to
be rebuilt than necessary when changing the SaveOp code. Having this code be
in a template class can also increase the generated code size be larger than
needed, as we don't need separate copies instantiated for each context type.
ghstack-source-id: 123146018
Test Plan:
buck test //caffe2/caffe2/python/operator_test:load_save_test
Also tested performing the CMake-based build using shared libraries with CUDA
enabled, and confirmed that the build succeeded.
Reviewed By: mraway
Differential Revision: D26802576
fbshipit-source-id: fc2dbdc1cd20680b082c887366a6305d86688138