Skip to content

Move torch.nn.quantized.conv2d to GPU #27811

@Linkeyboard

Description

@Linkeyboard

❓ Questions and Help

from torch.nn.quantized import functional as qF
filters = torch.randn(1, 1, 1, 1, dtype=torch.float)
inputs = torch.randn(1, 1, 5, 5, dtype=torch.float)
bias = torch.randn(1, dtype=torch.float)

scale, zero_point = 1.0, 0
dtype = torch.qint8

q_filters = torch.quantize_per_tensor(filters, scale, zero_point, torch.qint8)
q_inputs = torch.quantize_per_tensor(inputs, scale, zero_point, torch.quint8)
qF.conv2d(q_inputs, q_filters, bias)

It works successfully on CPU, and what can I do if I want to move conv2d to GPU.

qF.conv2d(q_inputs.cuda(), q_filters.cuda(), bias.cuda())

I tried in this way and got mistakes as below.

RuntimeError: Didn't find kernel to dispatch to for operator 'quantized::conv_prepack'. Tried to look up kernel for dispatch key 'CUDATensorId'. Registered dispatch keys are:[QuantizedCPUTensorId] (lookup_ at /opt/conda/conda-bld/pytorch_1570711556059/work/aten/src/ATen/core/dispatch/DispatchTable.h:249)

cc @jerryzh168 @jianyuh @dzhulgakov

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions