22 virtual int NumBits()
const = 0;
38 double highest = (1 <<
NumBits()) - 1;
40 min = std::min(0.0, min);
41 max = std::max(0.0, max);
44 if (min == 0.0 && max == 0.0)
50 double scale = (max-min) / highest;
51 double offset = -min / scale;
54 offset = std::max(0.0, std::min(highest, offset));
56 return std::make_pair(static_cast<float>(scale), static_cast<int>(std::round(offset)));
59 int NumBits()
const override {
return 8; }
73 double highest = (1 <<
NumBits()) - 1;
75 min = std::min(0.0, min);
76 max = std::max(0.0, max);
79 if (min == 0.0 && max == 0.0)
85 double scale = (max-min) / highest ;
86 double offset = - min / scale;
89 offset = std::max(0.0, std::min(highest, offset));
92 return std::make_pair(static_cast<float>(scale), static_cast<int>(std::round(offset)-128));
95 int NumBits()
const override {
return 8; }
110 if (min == 0.0 && max == 0.0)
115 double highest = (1 << (
NumBits()-1)) - 1;
117 double extent = std::max(std::abs(min), std::abs(max));
118 double scale = extent / highest;
120 return std::make_pair(static_cast<float>(scale), 0);
138 if (min == 0.0 && max == 0.0)
143 double highest = (1 << (
NumBits()-1)) - 1;
145 double extent = std::max(std::abs(min), std::abs(max));
146 double scale = extent / highest;
148 return std::make_pair(static_cast<float>(scale), 0);
int NumBits() const override
std::pair< float, int > OffsetScalePair
DataType GetDataType() const override
DataType GetDataType() const override
int NumBits() const override
Copyright (c) 2020 ARM Limited.
virtual OffsetScalePair ComputeScheme(double min, double max) const =0
virtual int NumBits() const =0
OffsetScalePair ComputeScheme(double min, double max) const override
virtual DataType GetDataType() const =0
DataType GetDataType() const override
DataType GetDataType() const override
OffsetScalePair ComputeScheme(double min, double max) const override
OffsetScalePair ComputeScheme(double min, double max) const override
virtual ~IQuantizationScheme()
OffsetScalePair ComputeScheme(double min, double max) const override
int NumBits() const override
int NumBits() const override