mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Summary: The CPU version is based on the TH version. The GPU version is based on #8406 by Pararth Shah (thank you). CPU quickselect based on that in TH's THTensorMoreMath.cpp, but with C++ (quickselectnoindex will be achieved by a different swap) CPU kthvalue is based on the THTensor function in the same file. The dim_apply function is a C++ replacement for TH_TENSOR_DIM_APPLYx macros. The CUDA kernel uses functions adapted from the THCTensorSortK implementation. In particular radixSelect is from THCTensorTopK.cuh. The CUDA launcher code replaces a bunch of macros with C++. It will be re-used in one of the following patches. Plan for further PRs: - This - Sort - TopK + Mode + Median in any order - Rip out THC stuff. There may be utility functions / structs in the SortingCommon.cuh that come into relevance only with sort. Pull Request resolved: https://github.com/pytorch/pytorch/pull/17544 Differential Revision: D14286934 Pulled By: ezyang fbshipit-source-id: 35dbea050b097e88777ac5fa5c0f499d5e23c738