Skip to content

Commit

Permalink
Fix incorrect group/batch size computation for qp8 fully-connected …
Browse files Browse the repository at this point in the history
…ops.

PiperOrigin-RevId: 707518051
  • Loading branch information
gonnet authored and xnnpack-bot committed Dec 18, 2024
1 parent f012860 commit c8b60a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
10 changes: 4 additions & 6 deletions src/subgraph/unary.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,11 @@ static enum xnn_status reshape_convert_operator(
break;
}
case xnn_operator_type_convert_nc_f32_qp8: {
const size_t num_groups =
xnn_shape_multiply_batch_dims(&input_value->shape, 2);
const size_t batch_size = input_value->shape.dim[num_input_dims - 2];
const size_t channels = input_value->shape.dim[num_input_dims - 1];
status = xnn_reshape_convert_nc_f32_qp8(
opdata->operator_objects[0], num_groups, batch_size, channels,
/*input_stride=*/channels, threadpool);
opdata->operator_objects[0], /*num_groups=*/1,
/*batch_size=*/dq_batch_size,
/*channels=*/dq_channel_stride,
/*input_stride=*/dq_channel_stride, threadpool);
break;
}
default:
Expand Down
7 changes: 3 additions & 4 deletions src/tensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,10 @@ size_t xnn_tensor_get_size(const struct xnn_value* value)
// Special handling for packed quantized types.
if (value->datatype == xnn_datatype_qpint8) {
assert(value->gemm_config != NULL);
const size_t num_groups = xnn_shape_multiply_batch_dims(&value->shape, 2);
const size_t m = value->shape.dim[value->shape.num_dims - 2];
const size_t batch_dims = xnn_shape_multiply_batch_dims(&value->shape, 1);
const size_t k = value->shape.dim[value->shape.num_dims - 1];
return num_groups *
xnn_x8_packq_f32qp8_gemm_packed_size(value->gemm_config, m, k);
return xnn_x8_packq_f32qp8_gemm_packed_size(value->gemm_config, batch_dims,
k);
}

uint64_t size_bits = xnn_datatype_size_bits(value->datatype);
Expand Down

0 comments on commit c8b60a7

Please sign in to comment.