Skip to content

Commit 9c31d1d

Browse files
authored
Fix pointer to contiguous data in quantized roi_align (#3904)
1 parent 21049e9 commit 9c31d1d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

torchvision/csrc/ops/quantized/cpu/qroi_align_kernel.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ void qroi_align_forward_kernel_impl(
2323
bool aligned,
2424
const at::Tensor& t_rois,
2525
T* output) {
26-
const T* input = t_input.contiguous().data_ptr<T>();
26+
// Don't delete these otherwise the .data_ptr() data might be undefined
27+
auto t_input_cont = t_input.contiguous();
28+
auto t_rois_cont = t_rois.contiguous();
29+
30+
const T* input = t_input_cont.data_ptr<T>();
2731
int64_t input_zp = t_input.q_zero_point();
2832
float input_scale = t_input.q_scale();
2933

30-
const T* rois = t_rois.contiguous().data_ptr<T>();
34+
const T* rois = t_rois_cont.data_ptr<T>();
3135
int64_t rois_zp = t_rois.q_zero_point();
3236
float rois_scale = t_rois.q_scale();
3337

0 commit comments

Comments
 (0)