Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ruy/kernel_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,13 @@ void MakeKernelParams8bit(const PMat<std::int8_t>& lhs,
params->rhs_zero_point = rhs.zero_point;
params->dst_zero_point = dst->zero_point;
params->depth = depth;
params->prod_zp_depth = lhs.zero_point * rhs.zero_point * depth;
// prod_zp_depth intentionally relies on two's-complement wraparound to match
// the wrapping arithmetic performed by the asm kernels. Compute it in unsigned
// so the overflow is well-defined.
params->prod_zp_depth = static_cast<std::int32_t>(
static_cast<std::uint32_t>(lhs.zero_point) *
static_cast<std::uint32_t>(rhs.zero_point) *
static_cast<std::uint32_t>(depth));
params->flags |= RUY_ASM_FLAG_NEEDS_LEFT_SHIFT;
if (mul_params.multiplier_fixedpoint_perchannel()) {
// Temporary release-assert to debug some crashes in an application.
Expand Down