Skip to content

GPU histc returns tensor of wrong dtype #20208

@ezyang

Description

@ezyang

cc @xvdp @jaciefan

Original report from @xvdp: #1382 (comment)

Thank you for the implementation, it is present in latest release, but there's an inconsistency in behaviour you may want to fix: cuda and cpu return different types

import torch
import sys
print(sys.version_info)
print(torch.__version__)
normalcpu = torch.zeros(100, dtype=torch.float32, device="cpu", requires_grad=False).normal_(0., 1.)
h_cpu = torch.histc(normalcpu, bins=10)
normalcuda = normalcpu.to(device="cuda")
h_cuda = torch.histc(normalcuda, bins=10)
print(h_cpu, h_cpu.dtype)
print(h_cuda, h_cuda.dtype)
sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)
1.1.0
tensor([ 2.,  5., 15., 26., 17., 18., 10.,  4.,  2.,  1.]) torch.float32
tensor([ 2,  5, 15, 26, 17, 18, 10,  4,  2,  1], device='cuda:0') torch.int64

Metadata

Metadata

Assignees

Labels

high prioritytriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions