Ignore the stats for the un-quantizable tensors

PiperOrigin-RevId: 278913249
Change-Id: I41432ff188a587dff75899738741908dd4d31fb4
This commit is contained in:
Feng Liu 2019-11-06 12:10:53 -08:00 committed by TensorFlower Gardener
parent 9c5d41b564
commit a419027414

View File

@ -200,7 +200,13 @@ mlir::Operation* ConvertMinMaxToStatsOp(const TensorT& tensor, OpBuilder b,
// If the `tensor` has scale/zero_point, it must have been quantized, then the
// min/max stats is just for comments, so ignore it.
if (!tensor.quantization || IsQuantized(tensor)) return nullptr;
// If the result isn't float and unquantizable, the min/max is ignored.
if (!res->getType()
.cast<mlir::ShapedType>()
.getElementType()
.isa<mlir::FloatType>()) {
return nullptr;
}
auto mins = tensor.quantization->min;
auto maxs = tensor.quantization->max;
if (mins.size() != maxs.size() || mins.empty()) return nullptr;