Skip to content

Commit 5b3b6ff

Browse files
authored
Fall back for asymmetric Conv2d weights (pytorch#21900)
Differential Revision: D116334309 Pull Request resolved: pytorch#21900
1 parent 99afd2c commit 5b3b6ff

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎backends/cadence/hifi/operators/op_quantized_conv2d_nhwc_out.cpp‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ void xa_opt_quantized_conv2d_nhwc(
167167
bool conv1d = input.dim() == 3;
168168
constexpr int kNnlibMaxDim = 4;
169169

170-
if (input.scalar_type() == ScalarType::Char) {
170+
// NNLib's int8 entry points require symmetric weights. Let the generic
171+
// implementation handle non-zero weight zero points.
172+
if (input.scalar_type() == ScalarType::Char && weight_zero_point == 0) {
171173
WORD8* __restrict__ p_out =
172174
(WORD8* __restrict__)out.mutable_data_ptr<int8_t>();
173175
WORD8* __restrict__ p_inp =
@@ -213,11 +215,7 @@ void xa_opt_quantized_conv2d_nhwc(
213215
WORD32 dilation_width = dilation[1];
214216
WORD32 dilation_height = dilation[0];
215217

216-
// WORD32* kernel_bias_ptr =
217-
// (WORD32*)weight_zero_point.const_data_ptr<int32_t>();
218-
219218
WORD32 input_zero_bias = -in_zero_point;
220-
WORD32 kernel_zero_bias = -weight_zero_point;
221219

222220
WORD32 out_multiplier32[out_channels];
223221
WORD32 out_shift32[out_channels];

0 commit comments

Comments
 (0)