From b4a834bed50de1cbb094950a93aaa6d3c094495d Mon Sep 17 00:00:00 2001 From: Lukas Thomann Date: Tue, 24 Feb 2026 19:30:06 +0100 Subject: [PATCH] fixed lambda indents to be more consistent --- .../autograd/AutogradNormalizationTest.cpp | 47 ++++++++++++------- uncrustify.cfg | 1 + 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/flashlight/fl/test/autograd/AutogradNormalizationTest.cpp b/flashlight/fl/test/autograd/AutogradNormalizationTest.cpp index f558268..83f730f 100644 --- a/flashlight/fl/test/autograd/AutogradNormalizationTest.cpp +++ b/flashlight/fl/test/autograd/AutogradNormalizationTest.cpp @@ -70,8 +70,10 @@ TEST(AutogradNormalizationTest, BatchNormEvalModeOutputSingleAxis) { auto expectedOut = (thisInput - thisMean) / std::sqrt(thisVar + 1E-5); expectedOut = expectedOut * thisWeight + thisBias; - ASSERT_TRUE(allClose( - out.tensor()(sel[0], sel[1], sel[2], sel[3]), expectedOut, 1E-5)); + ASSERT_TRUE( + allClose( + out.tensor()(sel[0], sel[1], sel[2], sel[3]), expectedOut, 1E-5) + ); } // test on empty weigts and bias @@ -93,8 +95,10 @@ TEST(AutogradNormalizationTest, BatchNormEvalModeOutputSingleAxis) { auto thisVar = runningVar.tensor().flatten()(i).scalar(); auto expectedOut = (thisInput - thisMean) / std::sqrt(thisVar + 1E-5); - ASSERT_TRUE(allClose( - out.tensor()(sel[0], sel[1], sel[2], sel[3]), expectedOut, 1E-5)); + ASSERT_TRUE( + allClose( + out.tensor()(sel[0], sel[1], sel[2], sel[3]), expectedOut, 1E-5) + ); } } @@ -123,9 +127,7 @@ TEST(AutogradNormalizationTest, BatchNormEvalModeOutputMultipleAxis) { 1E-5 )); for(int i = 0; i < nfeatures; ++i) { - std::array sel = { - i % 13, (i / 13) % 13, (i / 13) / 13, fl::span - }; + std::array sel = {i % 13, (i / 13) % 13, (i / 13) / 13, fl::span}; auto thisInput = input.tensor()(sel[0], sel[1], sel[2], sel[3]); auto thisMean = runningMean.tensor().flatten()(i).scalar(); auto thisVar = runningVar.tensor().flatten()(i).scalar(); @@ -135,8 +137,10 @@ TEST(AutogradNormalizationTest, BatchNormEvalModeOutputMultipleAxis) { auto expectedOut = (thisInput - thisMean) / std::sqrt(thisVar + 1e-5); expectedOut = expectedOut * thisWeight + thisBias; - ASSERT_TRUE(allClose( - out.tensor()(sel[0], sel[1], sel[2], sel[3]), expectedOut, 1e-4)); + ASSERT_TRUE( + allClose( + out.tensor()(sel[0], sel[1], sel[2], sel[3]), expectedOut, 1e-4) + ); } // test on empty weigts and bias @@ -153,15 +157,20 @@ TEST(AutogradNormalizationTest, BatchNormEvalModeOutputMultipleAxis) { )); for(int i = 0; i < nfeatures; ++i) { std::array sel = { - i % 13, (i / 13) % 13, (i / 13) / 13, fl::span + i % 13, + (i / 13) % 13, + (i / 13) / 13, + fl::span }; auto thisInput = input.tensor()(sel[0], sel[1], sel[2], sel[3]); auto thisMean = runningMean.tensor().flatten()(i).scalar(); auto thisVar = runningVar.tensor().flatten()(i).scalar(); auto expectedOut = (thisInput - thisMean) / std::sqrt(thisVar + 1e-5); - ASSERT_TRUE(allClose( - out.tensor()(sel[0], sel[1], sel[2], sel[3]), expectedOut, 5e-5)); + ASSERT_TRUE( + allClose( + out.tensor()(sel[0], sel[1], sel[2], sel[3]), expectedOut, 5e-5) + ); } } @@ -230,7 +239,10 @@ TEST(AutogradNormalizationTest, BatchNormTrainModeOutputMultipleAxis) { for(int i = 0; i < nfeatures; ++i) { std::array sel = { - i % 13, (i / 13) % 13, (i / 13) / 13, fl::span + i % 13, + (i / 13) % 13, + (i / 13) / 13, + fl::span }; auto thisInput = input.tensor()(sel[0], sel[1], sel[2], sel[3]); auto thisMean = avg.tensor().flatten()(i).scalar(); @@ -240,8 +252,10 @@ TEST(AutogradNormalizationTest, BatchNormTrainModeOutputMultipleAxis) { auto expectedOut = (thisInput - thisMean) / std::sqrt(thisVar + 1e-5); expectedOut = expectedOut * thisWeight + thisBias; - ASSERT_TRUE(allClose( - out.tensor()(sel[0], sel[1], sel[2], sel[3]), expectedOut, 1e-5)); + ASSERT_TRUE( + allClose( + out.tensor()(sel[0], sel[1], sel[2], sel[3]), expectedOut, 1e-5) + ); } } @@ -528,8 +542,7 @@ TEST_F(AutogradTestF16, LayerNormJacobianF16) { std::vector featAxes = {0, 1, 2, 3}; const float inputScale = 4.0; // scale the input to prevent grad underflow - auto input = - Variable(inputScale * fl::rand({2, 2, 2, 4}, fl::dtype::f16), true); + auto input = Variable(inputScale * fl::rand({2, 2, 2, 4}, fl::dtype::f16), true); auto nfeatures = 1; for(auto ax : featAxes) nfeatures *= input.dim(ax); diff --git a/uncrustify.cfg b/uncrustify.cfg index 022145b..b3d15dc 100644 --- a/uncrustify.cfg +++ b/uncrustify.cfg @@ -26,6 +26,7 @@ indent_func_class_param = false indent_func_ctor_var_param = false indent_template_param = false indent_cpp_lambda_body = true +indent_cpp_lambda_only_once = true use_indent_func_call_param = true donot_indent_func_def_close_paren = true align_func_params = false