From a30e2e52999b5874008971bde3005840295382c0 Mon Sep 17 00:00:00 2001 From: bhalimi <benjamin.halimi@cea.fr> Date: Mon, 27 Jan 2025 14:35:45 +0000 Subject: [PATCH] replace the couts with logs --- src/PTQ/CLE.cpp | 7 ++----- src/PTQ/Clipping.cpp | 2 +- src/PTQ/PTQ.cpp | 13 ++++++------- src/QAT/QAT_FixedQ.cpp | 6 +++--- src/QAT/QAT_LSQ.cpp | 3 +-- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/PTQ/CLE.cpp b/src/PTQ/CLE.cpp index c47c619..cbfb91f 100644 --- a/src/PTQ/CLE.cpp +++ b/src/PTQ/CLE.cpp @@ -126,11 +126,8 @@ void crossLayerEqualization(std::shared_ptr<GraphView> graphView, double targetD { ++iteration; maxRangeDelta = 0.0; - //std::cout << " ----- " << std::endl; - //for (std::shared_ptr<Node> node : affineNodeVector) - // std::cout << getTensorAbsoluteMax(getWeightTensor(node)) << std::endl; - - for (std::size_t i = 0; i < (affineNodeVector.size() - 1); i++) + + for (size_t i = 0; i < (affineNodeVector.size() - 1); i++) { std::shared_ptr<Node> n1 = affineNodeVector[i]; std::shared_ptr<Node> n2 = affineNodeVector[i+1]; diff --git a/src/PTQ/Clipping.cpp b/src/PTQ/Clipping.cpp index 57ad7a8..66b0ab3 100644 --- a/src/PTQ/Clipping.cpp +++ b/src/PTQ/Clipping.cpp @@ -26,7 +26,7 @@ std::map<std::string, std::vector<int>> computeHistograms(std::map<std::string, std::shared_ptr<Node> firstNode = retrieveNodeVector(graphView)[0]; - //std::cout << " COMPUTING HISTOGRAMS ... " << std::endl; + // Log::debug(" COMPUTING HISTOGRAMS ... "); std::map<std::string, std::vector<int>> histograms; diff --git a/src/PTQ/PTQ.cpp b/src/PTQ/PTQ.cpp index e510880..073e5e0 100644 --- a/src/PTQ/PTQ.cpp +++ b/src/PTQ/PTQ.cpp @@ -987,7 +987,6 @@ void performSingleShiftApproximation(std::shared_ptr<GraphView> graphView, bool static void printScalingFactors(std::shared_ptr<GraphView> graphView) { - Log::info(" === SCALING FACTORS === "); for (auto node : retrieveNodeVector(graphView)) if (node->type() == "Scaling" || node->type() == "Quantizer") { @@ -1020,7 +1019,7 @@ static void printRanges(std::shared_ptr<GraphView> graphView, std::map<std::stri auto scheduling = scheduler.getStaticScheduling(); for (auto node : scheduling) if (node->type() == "Scaling") - fmt::println("{} range = {}", node->name(), valueRanges[node->name()]); + Log::info(" {} range = {} ", node->name(), valueRanges[node->name()]); } void quantizeNetwork(std::shared_ptr<GraphView> graphView, std::uint8_t nbBits, std::vector<std::shared_ptr<Tensor>> inputDataSet, Clipping clippingMode, bool noQuant, bool optimizeSigns, bool singleShift, bool useCuda, bool verbose) @@ -1049,13 +1048,13 @@ void quantizeNetwork(std::shared_ptr<GraphView> graphView, std::uint8_t nbBits, Log::info(" Computing the value ranges ..."); std::map<std::string, double> valueRanges = computeRanges(graphView, inputDataSet, true, useCuda); - //std::cout << " === RANGES (BEFORE ADJUST) ===" << std::endl; + //Log::info(" === RANGES (BEFORE ADJUST) ==="); //printRanges(graphView, valueRanges); Log::info(" Optimizing the clipping values ..."); valueRanges = adjustRanges(clippingMode, valueRanges, nbBits, graphView, inputDataSet, useCuda, verbose); - //std::cout << " === RANGES (AFTER ADJUST) ===" << std::endl; + //Log::info(" === RANGES (AFTER ADJUST) ==="); //printRanges(graphView, valueRanges); Log::info(" Normalizing the activations ..."); @@ -1076,7 +1075,7 @@ void quantizeNetwork(std::shared_ptr<GraphView> graphView, std::uint8_t nbBits, if (verbose) printScalingFactors(graphView); - //std::cout << " === SCALINGS (BEFORE CAST) ===" << std::endl; + //Log::info(" === SCALINGS (BEFORE CAST) ==="); //printScalingFactors(graphView); setupDataType(graphView, inputDataSet, initialDataType); @@ -1084,7 +1083,7 @@ void quantizeNetwork(std::shared_ptr<GraphView> graphView, std::uint8_t nbBits, if (useCuda) graphView->setBackend("cuda"); - //std::cout << " === SCALINGS (AFTER CAST) ===" << std::endl; + //Log::info(" === SCALINGS (AFTER CAST) ==="); //printScalingFactors(graphView); Log::info(" Reseting the scheduler ..."); @@ -1124,7 +1123,7 @@ void clearBiases(std::shared_ptr<GraphView> graphView) void devPTQ(std::shared_ptr<GraphView> graphView) { for (std::shared_ptr<Node> node : graphView->getNodes()) - fmt::println(" UUU : {}", node->name()); + Log::info(" UUU : {}", node->name()); } } diff --git a/src/QAT/QAT_FixedQ.cpp b/src/QAT/QAT_FixedQ.cpp index 9160b4a..6ada532 100644 --- a/src/QAT/QAT_FixedQ.cpp +++ b/src/QAT/QAT_FixedQ.cpp @@ -91,7 +91,7 @@ static std::map<std::string, float> collectInputStats(std::shared_ptr<GraphView> const auto op = std::static_pointer_cast<FixedQ_Op>(node->getOperator()); float inputStd = getTensorStd(op->getInput(0)); inputStats.insert(std::make_pair(node->name(), inputStd)); - fmt::println("{} -> {}", node->name(), inputStd); + Log::info(" {} -> {} ", node->name(), inputStd); } } @@ -108,7 +108,7 @@ static std::map<std::string, float> collectParamStats(std::shared_ptr<GraphView> const auto op = std::static_pointer_cast<FixedQ_Op>(node->getOperator()); float paramStd = getTensorStd(op->getInput(1)); paramStats.insert(std::make_pair(node->name(), paramStd)); - fmt::println("{} -> {}", node->name(), paramStd); + Log::info(" {} -> {} ", node->name(), paramStd); } } @@ -156,7 +156,7 @@ void QuantFixedQ::devQAT(std::shared_ptr<GraphView> graphView) scheduler.generateScheduling(); auto s = scheduler.getStaticScheduling(); for (std::shared_ptr<Node> node : s) - fmt::println(" name : {}", node->name()); + Log::info(" name : {} ", node->name()); } } \ No newline at end of file diff --git a/src/QAT/QAT_LSQ.cpp b/src/QAT/QAT_LSQ.cpp index 80e8a05..0508fc7 100644 --- a/src/QAT/QAT_LSQ.cpp +++ b/src/QAT/QAT_LSQ.cpp @@ -27,7 +27,6 @@ namespace Aidge static float getTensorAbsMean(std::shared_ptr<Tensor> tensor) { - //std::cout << " GET TENSOR ABS MEAN " << std::endl; auto valueTensor = (*tensor).abs().mean(); std::shared_ptr<Tensor> fallback; const Tensor& localTensor = valueTensor.refCastFrom(fallback, DataType::Float32, "cpu"); @@ -76,7 +75,7 @@ static bool initStepSize(std::shared_ptr<Node> quantizer) stepSizeProducer->getOperator()->setOutput(0, stepSizeTensor); - std::cout << " [ INIT STEP SIZE = " << stepSize << " ] " << std::endl; + Log::info(" [ INIT STEP SIZE = {} ] ", stepSize); return false; } -- GitLab