Skip to content

Commit

Permalink
Merge pull request google#6267 from mcr229:fc_qcint32_bias
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 627715579
  • Loading branch information
xnnpack-bot committed Apr 24, 2024
2 parents cae3022 + 7ce200a commit 8637b70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/subgraph/fully-connected.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ static inline enum xnn_compute_type validate_datatypes_with_bias(
{
return xnn_compute_type_qd8_to_fp16;
} else if (input_datatype == xnn_datatype_qint8 &&
bias_datatype == xnn_datatype_qint32 &&
bias_datatype == xnn_datatype_qcint32 &&
output_datatype == xnn_datatype_qint8)
{
return xnn_compute_type_qc8;
Expand Down Expand Up @@ -952,6 +952,7 @@ enum xnn_status xnn_define_fully_connected(
case xnn_datatype_fp16:
case xnn_datatype_fp32:
case xnn_datatype_qint32:
case xnn_datatype_qcint32:
break;
default:
xnn_log_error(
Expand Down
9 changes: 4 additions & 5 deletions test/fully-connected.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ TEST_F(FullyConnectedTestQC8, define)

uint32_t bias_id = XNN_INVALID_VALUE_ID;
ASSERT_EQ(
xnn_status_success, xnn_define_quantized_tensor_value(
subgraph, xnn_datatype_qint32, 0, 1.0f, bias_dims.size(), bias_dims.data(), bias.data(),
xnn_status_success, xnn_define_channelwise_quantized_tensor_value(
subgraph, xnn_datatype_qcint32, scale.data(), bias_dims.size(), 0, bias_dims.data(), bias.data(),
/*external_id=*/2, /*flags=*/0, &bias_id));

uint32_t output_id = XNN_INVALID_VALUE_ID;
Expand Down Expand Up @@ -687,7 +687,6 @@ TEST_F(FullyConnectedTestQC8, matches_operator_api)
std::fill(subgraph_output.begin(), subgraph_output.end(), INT8_C(0xA5));
const int8_t input_zero_point = -1;
const float input_scale = scale_dist(rng);
const float kernel_scale = scale_dist(rng);
std::vector<float> requantization_scales(output_channels, 1.0f);
std::generate(requantization_scales.begin(), requantization_scales.end(), [&]() { return f32dist(rng); });

Expand Down Expand Up @@ -756,8 +755,8 @@ TEST_F(FullyConnectedTestQC8, matches_operator_api)

uint32_t bias_id = XNN_INVALID_VALUE_ID;
ASSERT_EQ(
xnn_status_success, xnn_define_quantized_tensor_value(
subgraph, xnn_datatype_qint32, 0, kernel_scale, bias_dims.size(), bias_dims.data(),
xnn_status_success, xnn_define_channelwise_quantized_tensor_value(
subgraph, xnn_datatype_qcint32, requantization_scales.data(), bias_dims.size(), 0, bias_dims.data(),
bias.data(), /*external_id=*/2, /*flags=*/0, &bias_id));

uint32_t output_id = XNN_INVALID_VALUE_ID;
Expand Down

0 comments on commit 8637b70

Please sign in to comment.