forked from mindspore-Ecosystem/mindspore
add int8 operator support activation
This commit is contained in:
parent
59162dc2b1
commit
54bdd9f827
|
@ -54,8 +54,23 @@ int QuantizedAddCPUKernel::Init() {
|
|||
QuantizeMultiplierSmallerThanOne(real_input1_multiplier, ¶_.input1_multiplier_, ¶_.input1_shift_);
|
||||
QuantizeMultiplierSmallerThanOne(real_output_multiplier, ¶_.output_multiplier_, ¶_.output_shift_);
|
||||
|
||||
para_.output_activation_min_ = std::numeric_limits<int8_t>::min();
|
||||
para_.output_activation_max_ = std::numeric_limits<int8_t>::max();
|
||||
switch (arith_para_->activation_type_) {
|
||||
case schema::ActivationType_RELU:
|
||||
para_.output_activation_min_ = 0;
|
||||
para_.output_activation_max_ = std::numeric_limits<int8_t>::max();
|
||||
break;
|
||||
case schema::ActivationType_RELU6:
|
||||
para_.output_activation_min_ = 0;
|
||||
para_.output_activation_max_ = 6;
|
||||
break;
|
||||
case schema::ActivationType_NO_ACTIVATION:
|
||||
para_.output_activation_min_ = std::numeric_limits<int8_t>::min();
|
||||
para_.output_activation_max_ = std::numeric_limits<int8_t>::max();
|
||||
break;
|
||||
default:
|
||||
MS_LOG(ERROR) << "Add does not support activation type " << arith_para_->activation_type_;
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
int left_shift0 = -para_.input0_shift_ > 0 ? -para_.input0_shift_ : 0;
|
||||
para_.right_shift0_ = -para_.input0_shift_ > 0 ? 0 : para_.input0_shift_;
|
||||
|
|
Loading…
Reference in New Issue