Skip to content

Commit

Permalink
Clean up for loop item types
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Jan 17, 2025
1 parent 37395dd commit 51d4d47
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/sleipnir/autodiff/Expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
8 changes: 4 additions & 4 deletions include/sleipnir/autodiff/ExpressionGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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];

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion include/sleipnir/autodiff/Jacobian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 51d4d47

Please sign in to comment.