diff options
Diffstat (limited to 'mlir/lib/Quantizer/Support')
| -rw-r--r-- | mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp | 8 | ||||
| -rw-r--r-- | mlir/lib/Quantizer/Support/Metadata.cpp | 2 | ||||
| -rw-r--r-- | mlir/lib/Quantizer/Support/Statistics.cpp | 16 | ||||
| -rw-r--r-- | mlir/lib/Quantizer/Support/UniformConstraints.cpp | 14 | ||||
| -rw-r--r-- | mlir/lib/Quantizer/Support/UniformSolvers.cpp | 10 |
5 files changed, 23 insertions, 27 deletions
diff --git a/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp b/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp index cfed2a2647c..d38c76255f0 100644 --- a/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp +++ b/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp @@ -157,15 +157,15 @@ Type CAGAnchorNode::getTransformedType() { getOriginalType()); } -void CAGNode::printLabel(llvm::raw_ostream &os) const { +void CAGNode::printLabel(raw_ostream &os) const { os << "Node<" << static_cast<const void *>(this) << ">"; } -void CAGAnchorNode::printLabel(llvm::raw_ostream &os) const { +void CAGAnchorNode::printLabel(raw_ostream &os) const { getUniformMetadata().printSummary(os); } -void CAGOperandAnchor::printLabel(llvm::raw_ostream &os) const { +void CAGOperandAnchor::printLabel(raw_ostream &os) const { os << "Operand<"; op->getName().print(os); os << "," << operandIdx; @@ -173,7 +173,7 @@ void CAGOperandAnchor::printLabel(llvm::raw_ostream &os) const { CAGAnchorNode::printLabel(os); } -void CAGResultAnchor::printLabel(llvm::raw_ostream &os) const { +void CAGResultAnchor::printLabel(raw_ostream &os) const { os << "Result<"; getOp()->getName().print(os); os << ">"; diff --git a/mlir/lib/Quantizer/Support/Metadata.cpp b/mlir/lib/Quantizer/Support/Metadata.cpp index 3661f52b52f..89478c4209d 100644 --- a/mlir/lib/Quantizer/Support/Metadata.cpp +++ b/mlir/lib/Quantizer/Support/Metadata.cpp @@ -24,7 +24,7 @@ using namespace mlir; using namespace mlir::quantizer; -void CAGUniformMetadata::printSummary(llvm::raw_ostream &os) const { +void CAGUniformMetadata::printSummary(raw_ostream &os) const { if (requiredRange.hasValue()) { os << "\n[" << requiredRange.getValue().first << "," << requiredRange.getValue().second << "]"; diff --git a/mlir/lib/Quantizer/Support/Statistics.cpp b/mlir/lib/Quantizer/Support/Statistics.cpp index 788c2f67e27..d155875cfe3 100644 --- a/mlir/lib/Quantizer/Support/Statistics.cpp +++ b/mlir/lib/Quantizer/Support/Statistics.cpp @@ -28,11 +28,12 @@ using namespace mlir::quantizer; // AttributeTensorStatistics implementation //===----------------------------------------------------------------------===// -static void -collectElementsStatisticsDim(ElementsAttr attr, unsigned numElements, - ArrayRef<int64_t> shape, - llvm::SmallVectorImpl<uint64_t> &indices, - uint64_t dim, TensorAxisStatistics &statistics) { +static void collectElementsStatisticsDim(ElementsAttr attr, + unsigned numElements, + ArrayRef<int64_t> shape, + SmallVectorImpl<uint64_t> &indices, + uint64_t dim, + TensorAxisStatistics &statistics) { // Recursive terminating condition. if (dim >= shape.size()) return; @@ -71,7 +72,7 @@ static bool getElementsStatistics(ElementsAttr attr, if (!elementTy.isa<FloatType>()) return false; - llvm::SmallVector<uint64_t, 4> indices; + SmallVector<uint64_t, 4> indices; indices.resize(sType.getRank()); ArrayRef<int64_t> shape = sType.getShape(); @@ -97,8 +98,7 @@ bool AttributeTensorStatistics::get(TensorAxisStatistics &stats) const { namespace mlir { namespace quantizer { -llvm::raw_ostream &operator<<(llvm::raw_ostream &os, - const TensorAxisStatistics &stats) { +raw_ostream &operator<<(raw_ostream &os, const TensorAxisStatistics &stats) { os << "STATS[sampleSize=" << stats.sampleSize << ", min=" << stats.minValue << ", maxValue=" << stats.maxValue << ", mean=" << stats.mean << ", variance=" << stats.variance << "]"; diff --git a/mlir/lib/Quantizer/Support/UniformConstraints.cpp b/mlir/lib/Quantizer/Support/UniformConstraints.cpp index c43ecdfb5c2..1a800dad4ac 100644 --- a/mlir/lib/Quantizer/Support/UniformConstraints.cpp +++ b/mlir/lib/Quantizer/Support/UniformConstraints.cpp @@ -118,7 +118,7 @@ public: } private: - void printLabel(llvm::raw_ostream &os) const override { + void printLabel(raw_ostream &os) const override { os << "PropagateExplicitScale"; } void propagate(SolverContext &solverContext, @@ -127,7 +127,7 @@ private: // Get scale/zp from all parents. for (auto it = incoming_begin(), e = incoming_end(); it != e; ++it) { - auto parentAnchor = llvm::cast<CAGAnchorNode>(*it); + auto parentAnchor = cast<CAGAnchorNode>(*it); auto selectedType = parentAnchor->getUniformMetadata().selectedType; if (auto uqType = selectedType.dyn_cast_or_null<UniformQuantizedType>()) { scaleZp.assertValue( @@ -139,7 +139,7 @@ private: // Propagate to children. if (scaleZp.hasValue()) { for (auto it = begin(), e = end(); it != e; ++it) { - auto childAnchor = llvm::cast<CAGAnchorNode>(*it); + auto childAnchor = cast<CAGAnchorNode>(*it); if (modified(childAnchor->getUniformMetadata() .explicitScaleZeroPoint.mergeFrom(scaleZp))) { childAnchor->markDirty(); @@ -163,9 +163,7 @@ public: } private: - void printLabel(llvm::raw_ostream &os) const override { - os << "SolveUniform"; - } + void printLabel(raw_ostream &os) const override { os << "SolveUniform"; } void propagate(SolverContext &solverContext, const TargetConfiguration &config) override { @@ -176,7 +174,7 @@ private: ClusteredFacts clusteredFacts; Type originalElementType; for (auto it = incoming_begin(), e = incoming_end(); it != e; ++it) { - auto parentAnchor = llvm::cast<CAGAnchorNode>(*it); + auto parentAnchor = cast<CAGAnchorNode>(*it); auto metadata = parentAnchor->getUniformMetadata(); // TODO: Possibly use a location that fuses all involved parents. fusedLoc = parentAnchor->getOp()->getLoc(); @@ -226,7 +224,7 @@ private: // Apply it to all parents. for (auto it = incoming_begin(), e = incoming_end(); it != e; ++it) { - auto parentAnchor = llvm::cast<CAGAnchorNode>(*it); + auto parentAnchor = cast<CAGAnchorNode>(*it); auto &metadata = parentAnchor->getUniformMetadata(); if (metadata.selectedType != selectedType) { metadata.selectedType = selectedType; diff --git a/mlir/lib/Quantizer/Support/UniformSolvers.cpp b/mlir/lib/Quantizer/Support/UniformSolvers.cpp index 341df5bf888..bd2fe686ee1 100644 --- a/mlir/lib/Quantizer/Support/UniformSolvers.cpp +++ b/mlir/lib/Quantizer/Support/UniformSolvers.cpp @@ -16,9 +16,8 @@ // ============================================================================= #include "mlir/Quantizer/Support/UniformSolvers.h" - +#include "mlir/Support/LLVM.h" #include "llvm/Support/raw_ostream.h" - #include <cmath> using namespace mlir; @@ -131,14 +130,13 @@ double UniformParamsFromMinMaxSolver::dequantize(int64_t xq) const { namespace mlir { namespace quantizer { -llvm::raw_ostream &operator<<(llvm::raw_ostream &os, - const UniformStorageParams &p) { +raw_ostream &operator<<(raw_ostream &os, const UniformStorageParams &p) { os << "UniformStorageParams{" << p.numLevels << ", " << p.minValue << "}"; return os; } -llvm::raw_ostream &operator<<(llvm::raw_ostream &os, - const UniformParamsFromMinMaxSolver &s) { +raw_ostream &operator<<(raw_ostream &os, + const UniformParamsFromMinMaxSolver &s) { os << "UniformParamsFromMinMaxSolver(" << s.getStepCount() << "){"; os << "(" << s.getBoundingMin() << ":" << s.getBoundingMax() << ") -> "; if (!s.isSatisfied()) { |

