Go to the source code of this file.
|
void | CreateRescaleTosaOperator (const std::string &inputName, const std::string &outputName, const std::vector< int32_t > &multipliers, const std::vector< int32_t > &shifts, int32_t input_zp, int32_t output_zp, bool double_round, bool scale32, bool per_channel, TosaSerializationOperator **op) |
|
void | CreateRescaleTosaOperator (const std::string &inputName, const std::string &outputName, int32_t scale_multiplier, int32_t scale_shift, int32_t input_zp, int32_t output_zp, bool double_round, bool scale32, bool per_channel, TosaSerializationOperator **op) |
|
void | CreateRescaleTosaOperator (const std::string &inputName, const std::string &outputName, double scale, int32_t input_zp, int32_t output_zp, bool double_round, bool scale32, TosaSerializationOperator **op) |
|
void | CreateRescaleTosaOperatorPerChannel (const std::string &inputName, const std::string &outputName, int32_t input_zp, int32_t output_zp, bool double_round, bool scale32, double input_scale, double output_scale, const std::vector< float > &weight_scales, TosaSerializationOperator **op) |
|
void | CreateFromInt32RescaleTosaOperator (const std::string &inputName, const std::string &outputName, double output_scale, int32_t output_zp, TosaSerializationOperator **op) |
|
◆ CreateFromInt32RescaleTosaOperator()
void CreateFromInt32RescaleTosaOperator |
( |
const std::string & |
inputName, |
|
|
const std::string & |
outputName, |
|
|
double |
output_scale, |
|
|
int32_t |
output_zp, |
|
|
TosaSerializationOperator ** |
op |
|
) |
| |
|
inline |
◆ CreateRescaleTosaOperator() [1/3]
void CreateRescaleTosaOperator |
( |
const std::string & |
inputName, |
|
|
const std::string & |
outputName, |
|
|
const std::vector< int32_t > & |
multipliers, |
|
|
const std::vector< int32_t > & |
shifts, |
|
|
int32_t |
input_zp, |
|
|
int32_t |
output_zp, |
|
|
bool |
double_round, |
|
|
bool |
scale32, |
|
|
bool |
per_channel, |
|
|
TosaSerializationOperator ** |
op |
|
) |
| |
|
inline |
◆ CreateRescaleTosaOperator() [2/3]
void CreateRescaleTosaOperator |
( |
const std::string & |
inputName, |
|
|
const std::string & |
outputName, |
|
|
double |
scale, |
|
|
int32_t |
input_zp, |
|
|
int32_t |
output_zp, |
|
|
bool |
double_round, |
|
|
bool |
scale32, |
|
|
TosaSerializationOperator ** |
op |
|
) |
| |
|
inline |
Definition at line 151 of file TosaRescaleOperatorUtils.hpp.
165 ComputeMultiplierAndShiftTosaScale32(scale, multiplier, shift);
169 ComputeMultiplierAndShiftTosaScale16(scale, multiplier, shift);
173 input_zp, output_zp, double_round, scale32,
false, op);
◆ CreateRescaleTosaOperator() [3/3]
void CreateRescaleTosaOperator |
( |
const std::string & |
inputName, |
|
|
const std::string & |
outputName, |
|
|
int32_t |
scale_multiplier, |
|
|
int32_t |
scale_shift, |
|
|
int32_t |
input_zp, |
|
|
int32_t |
output_zp, |
|
|
bool |
double_round, |
|
|
bool |
scale32, |
|
|
bool |
per_channel, |
|
|
TosaSerializationOperator ** |
op |
|
) |
| |
|
inline |
◆ CreateRescaleTosaOperatorPerChannel()
void CreateRescaleTosaOperatorPerChannel |
( |
const std::string & |
inputName, |
|
|
const std::string & |
outputName, |
|
|
int32_t |
input_zp, |
|
|
int32_t |
output_zp, |
|
|
bool |
double_round, |
|
|
bool |
scale32, |
|
|
double |
input_scale, |
|
|
double |
output_scale, |
|
|
const std::vector< float > & |
weight_scales, |
|
|
TosaSerializationOperator ** |
op |
|
) |
| |
|
inline |
Definition at line 176 of file TosaRescaleOperatorUtils.hpp.
187 std::vector<int32_t> op_tensor_multipliers;
188 std::vector<int32_t> op_tensor_shifts;
189 op_tensor_multipliers.reserve(weight_scales.size());
190 op_tensor_shifts.reserve(weight_scales.size());
192 for (
const float& weight_scale : weight_scales)
194 double op_tensor_scale = (input_scale * weight_scale) / output_scale;
200 ComputeMultiplierAndShiftTosaScale32(op_tensor_scale, multiplier, shift);
204 ComputeMultiplierAndShiftTosaScale16(op_tensor_scale, multiplier, shift);
207 op_tensor_multipliers.push_back(multiplier);
208 op_tensor_shifts.push_back(shift);
211 bool per_channel = weight_scales.size() == 1 ? false :
true;
213 input_zp, output_zp, double_round, scale32, per_channel, op);