mirror of
https://github.com/zebrajr/tensorflow.git
synced 2025-12-06 12:20:11 +01:00
Reject quantized type tensor with zero scales in flatbuffer importer.
PiperOrigin-RevId: 320648545 Change-Id: If31a8b3ae8598fbd06129f052211fbf8d4583990
This commit is contained in:
parent
fc0b3b42ea
commit
d4a0544a49
|
|
@ -152,6 +152,14 @@ StatusOr<QuantizedType> GetQuantizedType(const TensorT& tensor, Builder builder,
|
|||
uint32_t flags =
|
||||
is_signed ? mlir::quant::QuantizationFlags::FlagValue::Signed : 0;
|
||||
|
||||
// Rejects if quantized tensors have zero scales.
|
||||
for (float scale : quant_params.scale) {
|
||||
if (scale == 0) {
|
||||
return errors::InvalidArgument(
|
||||
"Quantized tensors must have non-zero scales");
|
||||
}
|
||||
}
|
||||
|
||||
// Scale size can't be zero as it is checked before.
|
||||
if (quant_params.scale.size() != 1) {
|
||||
llvm::SmallVector<double, 4> scales(quant_params.scale.begin(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user