2024-06-21 11:14:19 -07:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Tyler Veness <calcmogul@gmail.com>
|
|
|
|
|
Date: Sun, 16 Jun 2024 12:08:49 -0700
|
2026-03-29 20:39:18 -07:00
|
|
|
Subject: [PATCH 02/10] Use wpi::SmallVector
|
2024-06-21 11:14:19 -07:00
|
|
|
|
|
|
|
|
---
|
2026-05-27 21:26:42 -07:00
|
|
|
include/sleipnir/autodiff/expression.hpp | 4 ++--
|
|
|
|
|
include/sleipnir/autodiff/variable.hpp | 4 ++--
|
|
|
|
|
2 files changed, 4 insertions(+), 4 deletions(-)
|
2024-06-21 11:14:19 -07:00
|
|
|
|
2025-05-27 07:24:15 -07:00
|
|
|
diff --git a/include/sleipnir/autodiff/expression.hpp b/include/sleipnir/autodiff/expression.hpp
|
2026-05-29 14:59:39 -07:00
|
|
|
index f04967c6a84ea76b77cebb7ef8edcb798d03e2a5..361c74702107eadf6f1fbe1682a7ef296abd19a3 100644
|
2025-05-27 07:24:15 -07:00
|
|
|
--- a/include/sleipnir/autodiff/expression.hpp
|
|
|
|
|
+++ b/include/sleipnir/autodiff/expression.hpp
|
2025-12-12 19:40:43 -08:00
|
|
|
@@ -34,7 +34,7 @@ struct Expression;
|
2025-12-01 12:51:28 -08:00
|
|
|
template <typename Scalar>
|
|
|
|
|
constexpr void inc_ref_count(Expression<Scalar>* expr);
|
|
|
|
|
template <typename Scalar>
|
|
|
|
|
-constexpr void dec_ref_count(Expression<Scalar>* expr);
|
|
|
|
|
+void dec_ref_count(Expression<Scalar>* expr);
|
2024-12-07 12:36:25 -08:00
|
|
|
|
2025-12-12 19:40:43 -08:00
|
|
|
/// Typedef for intrusive shared pointer to Expression.
|
|
|
|
|
///
|
2026-05-29 14:59:39 -07:00
|
|
|
@@ -749,7 +749,7 @@ constexpr void inc_ref_count(Expression<Scalar>* expr) {
|
2025-12-12 19:40:43 -08:00
|
|
|
/// @tparam Scalar Scalar type.
|
|
|
|
|
/// @param expr The shared pointer's managed object.
|
2025-12-01 12:51:28 -08:00
|
|
|
template <typename Scalar>
|
|
|
|
|
-constexpr void dec_ref_count(Expression<Scalar>* expr) {
|
|
|
|
|
+void dec_ref_count(Expression<Scalar>* expr) {
|
2024-12-07 12:36:25 -08:00
|
|
|
// If a deeply nested tree is being deallocated all at once, calling the
|
2024-06-21 11:14:19 -07:00
|
|
|
// Expression destructor when expr's refcount reaches zero can cause a stack
|
|
|
|
|
// overflow. Instead, we iterate over its children to decrement their
|
2025-05-27 07:24:15 -07:00
|
|
|
diff --git a/include/sleipnir/autodiff/variable.hpp b/include/sleipnir/autodiff/variable.hpp
|
2026-05-29 14:59:39 -07:00
|
|
|
index a6b054494a18eacbcae10c0e88648550a39ed48e..ad8baa3b58047f5257c210b88446324cca121d4a 100644
|
2025-05-27 07:24:15 -07:00
|
|
|
--- a/include/sleipnir/autodiff/variable.hpp
|
|
|
|
|
+++ b/include/sleipnir/autodiff/variable.hpp
|
2026-05-29 14:59:39 -07:00
|
|
|
@@ -58,7 +58,7 @@ class Variable : public SleipnirBase {
|
2025-12-12 19:40:43 -08:00
|
|
|
Variable() = default;
|
|
|
|
|
|
|
|
|
|
/// Constructs an empty Variable.
|
2025-05-27 07:24:15 -07:00
|
|
|
- explicit constexpr Variable(std::nullptr_t) : expr{nullptr} {}
|
|
|
|
|
+ explicit Variable(std::nullptr_t) : expr{nullptr} {}
|
2024-06-21 11:14:19 -07:00
|
|
|
|
2025-12-12 19:40:43 -08:00
|
|
|
/// Constructs a Variable from a scalar type.
|
|
|
|
|
///
|
2026-05-29 14:59:39 -07:00
|
|
|
@@ -101,7 +101,7 @@ class Variable : public SleipnirBase {
|
2025-12-12 19:40:43 -08:00
|
|
|
/// Constructs a Variable pointing to the specified expression.
|
|
|
|
|
///
|
|
|
|
|
/// @param expr The autodiff variable.
|
2025-12-01 12:51:28 -08:00
|
|
|
- explicit constexpr Variable(detail::ExpressionPtr<Scalar>&& expr)
|
|
|
|
|
+ explicit Variable(detail::ExpressionPtr<Scalar>&& expr)
|
|
|
|
|
: expr{std::move(expr)} {}
|
2024-06-21 11:14:19 -07:00
|
|
|
|
2025-12-12 19:40:43 -08:00
|
|
|
/// Assignment operator for scalar.
|