Port `topk` from THC to ATen, migrate most of sort as well (#55392)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/24648
The large tensor codepath is ported, but there is a legacy codepath that depends on an inplace sort in THC that is not callable from `at::`. At first glance, THC `topk` seems to be the only function that uses this `sortKeyValueInplace`.
Is the correct change to wrap `sortKeyValueInplace` in legacy functions for visibility in the `at::` namespace?
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55392
Reviewed By: ezyang
Differential Revision: D28014257
Pulled By: ngimel
fbshipit-source-id: e297423c763f0691151cb62a4f5eff4cb31fb2b3