Skip to content

Commit 2e13f97

Browse files
Support quantized UpSampleNearest2d and remove former WA (#1686)
1 parent 8988d32 commit 2e13f97

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

csrc/aten/operators/UpSampleNearest.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,15 @@ static void upsample_nearest_out_dpcpp_kernel(
109109
#endif
110110

111111
if (!src_ctx.is_plain()) {
112-
output = empty_opaque_tensor(
113-
resampling_pd.dst_desc(), input.options(), c10::nullopt);
112+
if (input.is_quantized()) {
113+
auto quantizer = dpcpp_make_per_tensor_affine_quantizer(
114+
input.q_scale(), input.q_zero_point(), input.scalar_type());
115+
output = empty_opaque_qtensor(
116+
resampling_pd.dst_desc(), c10::nullopt, quantizer);
117+
} else {
118+
output = empty_opaque_tensor(
119+
resampling_pd.dst_desc(), input.options(), c10::nullopt);
120+
}
114121
}
115122
memory src_memory =
116123
dpcpp_onednn_memory(resampling_pd.src_desc(), eng, input.data_ptr());

scripts/tools/codegen/dest/register_dispatch_key.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,10 @@ class RegisterDispatchKey:
264264
'upsample_nearest3d',
265265
'upsample_nearest3d_backward_out',
266266
'upsample_nearest3d_backward',
267-
# 'upsample_nearest2d_out',
268-
# 'upsample_nearest2d',
269-
# 'upsample_nearest2d_backward_out',
270-
# 'upsample_nearest2d_backward',
267+
'upsample_nearest2d_out',
268+
'upsample_nearest2d',
269+
'upsample_nearest2d_backward_out',
270+
'upsample_nearest2d_backward',
271271
'upsample_nearest1d_out',
272272
'upsample_nearest1d',
273273
'upsample_nearest1d_backward_out',

0 commit comments

Comments
 (0)