Skip to content

Commit

Permalink
EvalGemmlowp: Construct 0-size gemmlowp::VectorMap if ptr is null
Browse files Browse the repository at this point in the history
This avoids constructing an invalid VectorMap (with null base and non-zero
size).  Assertions will be added to gemmlowp for this case.

PiperOrigin-RevId: 708191712
  • Loading branch information
Ruy Contributors authored and copybara-github committed Dec 20, 2024
1 parent 8467039 commit 83fd40d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ruy/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -811,10 +811,16 @@ void EvalGemmlowp(const Matrix<LhsScalar>& lhs, const Matrix<RhsScalar>& rhs,
quantize_down_stage_pc.result_offset_after_shift = dst->zero_point();
using ColVectorMap =
gemmlowp::VectorMap<const std::int32_t, gemmlowp::VectorShape::Col>;
quantize_down_stage_pc.result_fixedpoint_multiplier = ColVectorMap(
mul_params.multiplier_fixedpoint_perchannel(), lhs.layout().rows());
quantize_down_stage_pc.result_exponent = ColVectorMap(
mul_params.multiplier_exponent_perchannel(), lhs.layout().rows());
quantize_down_stage_pc.result_fixedpoint_multiplier =
ColVectorMap(mul_params.multiplier_fixedpoint_perchannel(),
mul_params.multiplier_fixedpoint_perchannel() != nullptr
? lhs.layout().rows()
: 0);
quantize_down_stage_pc.result_exponent =
ColVectorMap(mul_params.multiplier_exponent_perchannel(),
mul_params.multiplier_exponent_perchannel() != nullptr
? lhs.layout().rows()
: 0);

gemmlowp::OutputStageClamp clamp_stage;
clamp_stage.min = mul_params.clamp_min();
Expand Down

0 comments on commit 83fd40d

Please sign in to comment.