From 51d4d47cdee529379e4474b979427d4df4e79e05 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Fri, 17 Jan 2025 15:42:22 -0800 Subject: [PATCH] Clean up for loop item types --- include/sleipnir/autodiff/Expression.hpp | 2 +- include/sleipnir/autodiff/ExpressionGraph.hpp | 8 ++++---- include/sleipnir/autodiff/Jacobian.hpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/sleipnir/autodiff/Expression.hpp b/include/sleipnir/autodiff/Expression.hpp index f7e9627a..8c6ffa8f 100644 --- a/include/sleipnir/autodiff/Expression.hpp +++ b/include/sleipnir/autodiff/Expression.hpp @@ -672,7 +672,7 @@ inline constexpr void IntrusiveSharedPtrDecRefCount(Expression* expr) { if (elem->adjointExpr != nullptr) { stack.emplace_back(elem->adjointExpr.Get()); } - for (auto&& arg : elem->args) { + for (auto& arg : elem->args) { if (arg != nullptr) { stack.emplace_back(arg.Get()); } diff --git a/include/sleipnir/autodiff/ExpressionGraph.hpp b/include/sleipnir/autodiff/ExpressionGraph.hpp index 038cceef..57ebe8ad 100644 --- a/include/sleipnir/autodiff/ExpressionGraph.hpp +++ b/include/sleipnir/autodiff/ExpressionGraph.hpp @@ -46,7 +46,7 @@ class ExpressionGraph { auto node = stack.back(); stack.pop_back(); - for (auto&& arg : node->args) { + for (auto& arg : node->args) { // Only continue if the node is not a constant and hasn't already been // explored. if (arg != nullptr && arg->Type() != ExpressionType::kConstant) { @@ -75,7 +75,7 @@ class ExpressionGraph { m_valueList.emplace_back(node); } - for (auto&& arg : node->args) { + for (auto& arg : node->args) { // Only add node if it's not a constant and doesn't already exist in the // tape. if (arg != nullptr && arg->Type() != ExpressionType::kConstant) { @@ -144,7 +144,7 @@ class ExpressionGraph { // multiplied by dy/dx. If there are multiple "paths" from the root node to // variable; the variable's adjoint is the sum of each path's adjoint // contribution. - for (auto node : m_adjointList) { + for (auto& node : m_adjointList) { auto& lhs = node->args[0]; auto& rhs = node->args[1]; @@ -166,7 +166,7 @@ class ExpressionGraph { // Unlink adjoints to avoid circular references between them and their // parent expressions. This ensures all expressions are returned to the free // list. - for (auto node : m_adjointList) { + for (auto& node : m_adjointList) { for (auto& arg : node->args) { if (arg != nullptr) { arg->adjointExpr = nullptr; diff --git a/include/sleipnir/autodiff/Jacobian.hpp b/include/sleipnir/autodiff/Jacobian.hpp index 6006db96..aff13c10 100644 --- a/include/sleipnir/autodiff/Jacobian.hpp +++ b/include/sleipnir/autodiff/Jacobian.hpp @@ -39,7 +39,7 @@ class SLEIPNIR_DLLEXPORT Jacobian { m_wrt(row).expr->row = row; } - for (Variable variable : m_variables) { + for (auto& variable : m_variables) { m_graphs.emplace_back(variable.expr); }