Skip to content

Commit 15a66ad

Browse files
committed
rename: s/OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint/OutputStageQuantizeDownInt32ByFixedPoint/g - and keep the old name supported for compatibility
1 parent d4d1e29 commit 15a66ad

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

doc/quantization.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ the particular quantization paradigm that we detailed above in this document.
301301
The specific output pipeline stage implementing the present quantization
302302
paradigm, i.e. implementing the precise computation detailed in the previous
303303
section (equation (5)), is
304-
`OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint`.
304+
`OutputStageQuantizeDownInt32ByFixedPoint`.
305305

306306
Please refer to the comment explaining it in
307307
[public/output_stages.h](../public/output_stages.h).
@@ -313,7 +313,7 @@ The difference between the older legacy quantization paradigm described in
313313
document boils down to the difference between the legacy output stage
314314
implementing it, `OutputStageQuantizeDownInt32ToUint8Scale`, and the new output
315315
stage implementing the new paradigm,
316-
`OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint`.
316+
`OutputStageQuantizeDownInt32ByFixedPoint`.
317317

318318
Please refer to the comments in
319319
[public/output_stages.h](../public/output_stages.h) for details about these two
@@ -323,7 +323,7 @@ Issues with the old output stage `OutputStageQuantizeDownInt32ToUint8Scale` are:
323323

324324
1. The int32 accumulators (inputs to the output stage) undergo a plain int32
325325
multiplication with a int32 multiplier, which may overflow. By contrast, in
326-
the newer `OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint`, this
326+
the newer `OutputStageQuantizeDownInt32ByFixedPoint`, this
327327
integer multiplication becomes a fixed-point multiplication and cannot
328328
overflow.
329329

doc/quantization_example.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ std::ostream& operator<<(std::ostream& s,
201201
//
202202
// This is how to obtain the fixed-point multiplier and right shift
203203
// parameters to pass to
204-
// OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint.
204+
// OutputStageQuantizeDownInt32ByFixedPoint.
205205
//
206206
// Note: all this code only needs to run offline to generate the quantized
207207
// neural network workload, not at runtime on the
@@ -347,7 +347,7 @@ int main() {
347347
<< "use quantized arithmetic.\n"
348348
<< std::endl;
349349

350-
gemmlowp::OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint
350+
gemmlowp::OutputStageQuantizeDownInt32ByFixedPoint
351351
quantize_down_stage;
352352
quantize_down_stage.result_offset_after_shift = result_offset;
353353
quantize_down_stage.result_fixedpoint_multiplier = quantized_multiplier;

internal/output.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ struct OutputStageEvalImpl<OutputStageQuantizeDownInt32ToUint8ScalePC<Shape>,
119119

120120
template <int Size>
121121
struct OutputStageEvalBufferImpl<
122-
OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint,
122+
OutputStageQuantizeDownInt32ByFixedPoint,
123123
RegisterBuffer<std::int32_t, Size>> {
124124
typedef RegisterBuffer<std::int32_t, Size> InputType;
125125
typedef RegisterBuffer<std::int32_t, Size> OutputType;
126126

127-
typedef OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint OutputStage;
127+
typedef OutputStageQuantizeDownInt32ByFixedPoint OutputStage;
128128

129129
OutputStageEvalBufferImpl(const OutputStage& s) : output_stage(s) {}
130130

public/output_stages.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ struct OutputStageQuantizeDownInt32ToUint8ScalePC {
6666
};
6767

6868
// This output stage takes int32 values and returns still int32 values,
69-
// but "quantized down" to the uint8 scale; in other words, its output
70-
// is typically what one would then clamp to [0..255] and cast to uint8
69+
// but "quantized down" to a difference scale; for example, in a pipeline
70+
// that outputs uint8 values in [0..255], the output of this stage would be
71+
// int32 values ready to be clamped to [0..255] and casted to uint8
7172
// (see OutputStageSaturatingCastToUint8).
7273
//
7374
// This "quantization down" process depends on 3 parameters,
@@ -111,12 +112,17 @@ struct OutputStageQuantizeDownInt32ToUint8ScalePC {
111112
// expansions that implicitly rely on 0-padding. If 0 were not
112113
// a representable value, such operations would have to pad
113114
// using a nonzero value, introducing bias in the computation.
114-
struct OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint {
115+
struct OutputStageQuantizeDownInt32ByFixedPoint {
115116
std::int32_t result_fixedpoint_multiplier;
116117
std::int32_t result_shift;
117118
std::int32_t result_offset_after_shift;
118119
};
119120

121+
// OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint is the old deprecated
122+
// name of OutputStageQuantizeDownInt32ByFixedPoint, before we noticed that
123+
// there really wasn't anything Uint8-specific about it.
124+
using OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint = OutputStageQuantizeDownInt32ByFixedPoint;
125+
120126
// This output stage takes int32 values that are expected to be already
121127
// on the final uint8 scale, but not necessarily in the [0..255] range.
122128
// It clamps them to the [0..255] range and returns them casted to uint8.

test/benchmark_all_sizes.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ float benchmark_8bit(int rows, int depth, int cols) {
122122
MakeZero(&rhs);
123123
MakeZero(&result);
124124

125-
typedef std::tuple<OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint,
125+
typedef std::tuple<OutputStageQuantizeDownInt32ByFixedPoint,
126126
OutputStageSaturatingCastToUint8>
127127
Pipeline;
128-
gemmlowp::OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint
128+
gemmlowp::OutputStageQuantizeDownInt32ByFixedPoint
129129
quantize_down_stage;
130130
quantize_down_stage.result_offset_after_shift = 128;
131131
quantize_down_stage.result_fixedpoint_multiplier = 1234567890;

test/test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,8 +1428,8 @@ void TestOutputStages(int rows, int depth, int cols, int result_offset,
14281428
result_fixedpoint_shift++;
14291429
}
14301430
Check(result_fixedpoint_shift >= 0);
1431-
// Now test OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint
1432-
OutputStageQuantizeDownInt32ToUint8ScaleByFixedPoint
1431+
// Now test OutputStageQuantizeDownInt32ByFixedPoint
1432+
OutputStageQuantizeDownInt32ByFixedPoint
14331433
quantize_down_by_fixedpoint_stage;
14341434
quantize_down_by_fixedpoint_stage.result_offset_after_shift =
14351435
static_cast<std::int32_t>(

0 commit comments

Comments
 (0)