mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
add warning to dnnlowp fc if quantization kind is not min_max
Summary: Print warning when using DNNLOWP dynamic int8 quant for FC and activation_quantization_kind != min_max. Warning will display in console but not in Bento. Would have to use CAFFE_ENFORCE to alert in Bento. Test Plan: buck run unit test forcing DNNLOWP FC with activation_quantization_kind = "l2" and saw warning printed in console. Reviewed By: csummersea Differential Revision: D17770921 fbshipit-source-id: b6532e4c9a86d74e3db4cb432735505d378a366e
This commit is contained in:
parent
afbbe16f49
commit
381cf2bd24
|
|
@ -71,7 +71,20 @@ TensorQuantizationParams GetInputTensorQuantizationParamsOf(
|
|||
float min, max;
|
||||
fbgemm::FindMinMax(
|
||||
tensor->template data<float>(), &min, &max, tensor->numel());
|
||||
|
||||
auto activation_quantization_kind = qfactory->GetActivationKind();
|
||||
if (activation_quantization_kind !=
|
||||
QuantizationFactory::QuantizationKind::MIN_MAX_QUANTIZATION) {
|
||||
LOG(WARNING)
|
||||
<< "DNNLOWP dynamic int8 FC uses min_max as the only activation_quantization kind. Qparams will be assigned based on min_max regardless of activation_quantization_kind args.";
|
||||
}
|
||||
if (is_weight) {
|
||||
auto weight_quantization_kind = qfactory->GetWeightKind();
|
||||
if (weight_quantization_kind !=
|
||||
QuantizationFactory::QuantizationKind::MIN_MAX_QUANTIZATION) {
|
||||
LOG(WARNING)
|
||||
<< "DNNLOWP dynamic int8 FC weight is not constant, assigning qparams to weight based on min_max, regardless of weight_quantization_kind args.";
|
||||
}
|
||||
}
|
||||
return qfactory->ChooseQuantizationParams(min, max, is_weight);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user