From ebf9108a48b3c4812175b705077a9285f0d90443 Mon Sep 17 00:00:00 2001 From: Nishak Date: Mon, 26 Aug 2024 21:10:52 -0700 Subject: [PATCH] correcting quantized_conv_ref --- .../cadence/reference/operators/quantized_conv_out.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backends/cadence/reference/operators/quantized_conv_out.cpp b/backends/cadence/reference/operators/quantized_conv_out.cpp index 95236b4397b..1a9e5fcd85f 100644 --- a/backends/cadence/reference/operators/quantized_conv_out.cpp +++ b/backends/cadence/reference/operators/quantized_conv_out.cpp @@ -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. @@ -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; } } @@ -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; } }