Skip to content

Commit

Permalink
[quant] Fix applying non-zero offset 1 to null pointer in quantized i…
Browse files Browse the repository at this point in the history
…nterpolation

Summary: Although this is not an issue that could pop-up in practice, LLVM-12 throws an error about this issue if not checked.

Test Plan: `buck test mode/dev //caffe2/test:quantization -- --exact 'caffe2/test:quantization - test_empty_batch (quantization.core.test_quantized_op.TestQuantizedOps)'`

Reviewed By: r-barnes

Differential Revision: D31151681

fbshipit-source-id: 2f890cf44b8918f1600c7ed7027004d867ed1153
  • Loading branch information
Zafar Takhirov authored and facebook-github-bot committed Sep 23, 2021
1 parent 36485d3 commit f04376a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions aten/src/ATen/native/quantized/cpu/qupsample_bilinear2d.cpp
Expand Up @@ -30,6 +30,9 @@ static void upsample_bilinear2d_out_frame(
auto* odata = static_cast<scalar_t*>(output.data_ptr());

channels = channels * nbatch;
if (channels == 0 || output_height == 0 || output_width == 0) {
return;
}
auto* i_p = reinterpret_cast<typename scalar_t::underlying*>(idata);
auto* o_p = reinterpret_cast<typename scalar_t::underlying*>(odata);

Expand Down
3 changes: 3 additions & 0 deletions aten/src/ATen/native/quantized/cpu/qupsample_nearest2d.cpp
Expand Up @@ -29,6 +29,9 @@ static void upsample_nearest2d_out_frame(
float width_scale = compute_scales_value<float>(scales_w, input_width, output_width);

channels = channels * nbatch;
if (channels == 0 || output_height == 0 || output_width == 0) {
return;
}
auto* i_p = reinterpret_cast<typename scalar_t::underlying*>(idata);
auto* o_p = reinterpret_cast<typename scalar_t::underlying*>(odata);

Expand Down
3 changes: 3 additions & 0 deletions aten/src/ATen/native/quantized/cpu/qupsample_nearest3d.cpp
Expand Up @@ -33,6 +33,9 @@ static void upsample_nearest3d_out_frame(
float width_scale = compute_scales_value<float>(scales_w, input_width, output_width);

channels = channels * nbatch;
if (channels == 0 || output_depth == 0 || output_height == 0 || output_width == 0) {
return;
}
auto* i_p = reinterpret_cast<typename scalar_t::underlying*>(idata);
auto* o_p = reinterpret_cast<typename scalar_t::underlying*>(odata);

Expand Down

0 comments on commit f04376a

Please sign in to comment.