Tentatively remove special treatment of Half type in randperm_out_cuda #22033
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The special treatment was first added in edfcbfb (#7606), but it does not seem to be necessary.
Could @yf225 give a little explanation, perhaps?
The diff shown on GitHub is pretty messy because of the indentation changes, but all I have done is the following (plus indentation changes):
--- a/aten/src/ATen/native/cuda/TensorFactories.cu +++ b/aten/src/ATen/native/cuda/TensorFactories.cu @@ -80,10 +80,6 @@ Tensor& randperm_out_cuda(Tensor& result, int64_t n, Generator* generator) { result.resize_({n}); - if (result.scalar_type() == at::ScalarType::Half) { - auto result_float = at::empty({n}, initialTensorOptions().device(Device(DeviceType::CUDA))); - result.copy_(randperm_out_cuda(result_float, n, generator)); - } else { if (n < 30000) { // For small inputs, we offload it to CPU instead. auto result_cpu = at::empty({n}, result.options().device(kCPU)); randperm_out(result_cpu, n, generator); @@ -108,7 +104,6 @@ Tensor& randperm_out_cuda(Tensor& result, int64_t n, Generator* generator) { } ); } - } return result; }