Skip to content

Conversation

@xuhdev
Copy link
Collaborator

@xuhdev xuhdev commented Jun 20, 2019

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;
  }

The special treatment was first added in
edfcbfb (pytorch#7606), but it does not seem
to be necessary.
@pytorchbot pytorchbot added module: cuda Related to torch.cuda, and CUDA support in general module: operators labels Jun 20, 2019
@xuhdev
Copy link
Collaborator Author

xuhdev commented Jun 20, 2019

Oops, pinged the wrong person. @yf225

@xuhdev
Copy link
Collaborator Author

xuhdev commented Jun 20, 2019

Sort of seen what's going on. Closing now.

@xuhdev xuhdev closed this Jun 20, 2019
@xuhdev xuhdev deleted the randperm-type branch June 20, 2019 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: cuda Related to torch.cuda, and CUDA support in general open source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants