diff options
| author | River Riddle <riverriddle@google.com> | 2019-06-25 21:31:54 -0700 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-06-25 21:32:23 -0700 |
| commit | a4c3a6455c404ef4e56a73be9457affb53536873 (patch) | |
| tree | 98c799b972d8e5eaec881d1c1ef524a35e0394ab /mlir/lib/Dialect/QuantOps | |
| parent | 679a3b41911457ef0f4a79a3135bb7ecca6d2f97 (diff) | |
| download | bcm5719-llvm-a4c3a6455c404ef4e56a73be9457affb53536873.tar.gz bcm5719-llvm-a4c3a6455c404ef4e56a73be9457affb53536873.zip | |
Move the emitError/Warning/Remark utility methods out of MLIRContext and into the mlir namespace.
Now that Locations are attributes, they have direct access to the MLIR context. This allows for simplifying error emission by removing unnecessary context lookups.
PiperOrigin-RevId: 255112791
Diffstat (limited to 'mlir/lib/Dialect/QuantOps')
| -rw-r--r-- | mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp | 22 | ||||
| -rw-r--r-- | mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp | 2 | ||||
| -rw-r--r-- | mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp | 4 |
3 files changed, 14 insertions, 14 deletions
diff --git a/mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp b/mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp index 1b63b8f4f55..6cc8ab0f52f 100644 --- a/mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp +++ b/mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp @@ -42,7 +42,7 @@ LogicalResult QuantizedType::verifyConstructionInvariants( auto intStorageType = storageType.dyn_cast<IntegerType>(); if (!intStorageType) { if (loc) { - context->emitError(*loc, "storage type must be integral"); + emitError(*loc, "storage type must be integral"); } return failure(); } @@ -51,7 +51,7 @@ LogicalResult QuantizedType::verifyConstructionInvariants( // Verify storage width. if (integralWidth == 0 || integralWidth > MaxStorageBits) { if (loc) { - context->emitError(*loc, "illegal storage type size: ") << integralWidth; + emitError(*loc, "illegal storage type size: ") << integralWidth; } return failure(); } @@ -67,7 +67,7 @@ LogicalResult QuantizedType::verifyConstructionInvariants( storageTypeMin < defaultIntegerMin || storageTypeMax > defaultIntegerMax) { if (loc) { - context->emitError(*loc, "illegal storage min and storage max: (") + emitError(*loc, "illegal storage min and storage max: (") << storageTypeMin << ":" << storageTypeMax << ")"; } return failure(); @@ -249,7 +249,7 @@ LogicalResult AnyQuantizedType::verifyConstructionInvariants( // extended. if (expressedType && !expressedType.isa<FloatType>()) { if (loc) { - context->emitError(*loc, "expressed type must be floating point"); + emitError(*loc, "expressed type must be floating point"); } return failure(); } @@ -293,7 +293,7 @@ LogicalResult UniformQuantizedType::verifyConstructionInvariants( // expressed type. if (!expressedType) { if (loc) { - context->emitError(*loc, "uniform quantization requires expressed type"); + emitError(*loc, "uniform quantization requires expressed type"); } return failure(); } @@ -303,7 +303,7 @@ LogicalResult UniformQuantizedType::verifyConstructionInvariants( // extended. if (!expressedType.isa<FloatType>()) { if (loc) { - context->emitError(*loc, "expressed type must be floating point"); + emitError(*loc, "expressed type must be floating point"); } return failure(); } @@ -311,7 +311,7 @@ LogicalResult UniformQuantizedType::verifyConstructionInvariants( // Verify scale. if (scale <= 0.0 || std::isinf(scale) || std::isnan(scale)) { if (loc) { - context->emitError(*loc) << "illegal scale: " << scale; + emitError(*loc) << "illegal scale: " << scale; } return failure(); } @@ -362,7 +362,7 @@ LogicalResult UniformQuantizedPerAxisType::verifyConstructionInvariants( // expressed type. if (!expressedType) { if (loc) { - context->emitError(*loc, "uniform quantization requires expressed type"); + emitError(*loc, "uniform quantization requires expressed type"); } return failure(); } @@ -372,7 +372,7 @@ LogicalResult UniformQuantizedPerAxisType::verifyConstructionInvariants( // extended. if (!expressedType.isa<FloatType>()) { if (loc) { - context->emitError(*loc, "expressed type must be floating point"); + emitError(*loc, "expressed type must be floating point"); } return failure(); } @@ -380,7 +380,7 @@ LogicalResult UniformQuantizedPerAxisType::verifyConstructionInvariants( // Ensure that the number of scales and zeroPoints match. if (scales.size() != zeroPoints.size()) { if (loc) { - context->emitError(*loc, "illegal number of scales and zeroPoints: ") + emitError(*loc, "illegal number of scales and zeroPoints: ") << scales.size() << ", " << zeroPoints.size(); } return failure(); @@ -390,7 +390,7 @@ LogicalResult UniformQuantizedPerAxisType::verifyConstructionInvariants( for (double scale : scales) { if (scale <= 0.0 || std::isinf(scale) || std::isnan(scale)) { if (loc) { - context->emitError(*loc) << "illegal scale: " << scale; + emitError(*loc) << "illegal scale: " << scale; } return failure(); } diff --git a/mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp b/mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp index 1172f82bffa..b3fbad8bd62 100644 --- a/mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp +++ b/mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp @@ -258,7 +258,7 @@ private: // TODO: All errors show up at the beginning of the extended type location. // Figure out how to make this location relative to where the error occurred // in this instance. - context->emitError(location, message); + mlir::emitError(location, message); } // Parsers. diff --git a/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp b/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp index 5562e45bb4a..9ec9151991d 100644 --- a/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp +++ b/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp @@ -44,7 +44,7 @@ UniformQuantizedType mlir::quant::fakeQuantAttrsToType(Location loc, qmin = -32768; qmax = 32767; } else { - ctx->emitError(loc, "unsupported FakeQuant number of bits: ") << numBits; + emitError(loc, "unsupported FakeQuant number of bits: ") << numBits; return nullptr; } @@ -55,7 +55,7 @@ UniformQuantizedType mlir::quant::fakeQuantAttrsToType(Location loc, // Range must straddle zero. if (rmin > 0.0 || rmax < 0.0) { - return (ctx->emitError(loc, "FakeQuant range must straddle zero: [") + return (emitError(loc, "FakeQuant range must straddle zero: [") << rmin << "," << rmax << "]", nullptr); } |

