Skip to content

Commit

Permalink
correcting quantized_conv_ref (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
nishpoonia authored Aug 27, 2024
1 parent 3fd8736 commit 5472bbf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions backends/cadence/reference/operators/quantized_conv_out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace native {

using Tensor = exec_aten::Tensor;
using RuntimeContext = torch::executor::RuntimeContext;
using ScalarType = exec_aten::ScalarType;

// This implements a generic 2d conv kernel that operates on raw pointers.
// The version handles both quantized and fp32 convolutions.
Expand Down Expand Up @@ -108,7 +109,8 @@ __attribute__((noinline)) void conv2d_nchw_core_generic(
int woff = _wh * ww + _ww;
float lhs = in_plane[ioff] - in_zero_point;
float rhs = weight_plane[woff] -
(quantized ? weight_zero_point[0] : 0);
(quantized ? 0 : 0);
/*(quantized ? weight_zero_point[0] : 0);*/
acc += lhs * rhs;
}
}
Expand All @@ -122,13 +124,14 @@ __attribute__((noinline)) void conv2d_nchw_core_generic(
if (((_h + d0 * _wh - p0) >= 0) &&
((_h + d0 * _wh - p0) < h) &&
((_w + d1 * _ww - p1) >= 0) &&
((_w + d1 * _ww - p1 < w))) {
((_w + d1 * _ww - p1) < w)) {
int ioff =
(_h + d0 * _wh - p0) * w + (_w + d1 * _ww - p1);
int woff = _wh * ww + _ww;
float lhs = in_plane[ioff] - in_zero_point;
float rhs = weight_plane[woff] -
(quantized ? weight_zero_point[0] : 0);
(quantized ? 0 : 0);
/*(quantized ? weight_zero_point[0] : 0);*/
acc += lhs * rhs;
}
}
Expand Down

0 comments on commit 5472bbf

Please sign in to comment.