Skip to content

Commit

Permalink
Remove DLL exports from Expression (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored Dec 15, 2024
1 parent 6683ad5 commit 7e5be71
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 59 deletions.
92 changes: 38 additions & 54 deletions include/sleipnir/autodiff/Expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "sleipnir/autodiff/ExpressionType.hpp"
#include "sleipnir/util/IntrusiveSharedPtr.hpp"
#include "sleipnir/util/Pool.hpp"
#include "sleipnir/util/SymbolExports.hpp"
#include "sleipnir/util/small_vector.hpp"

namespace sleipnir::detail {
Expand All @@ -27,7 +26,7 @@ inline constexpr bool kUsePoolAllocator = false;
inline constexpr bool kUsePoolAllocator = true;
#endif

struct SLEIPNIR_DLLEXPORT Expression;
struct Expression;

inline constexpr void IntrusiveSharedPtrIncRefCount(Expression* expr);
inline constexpr void IntrusiveSharedPtrDecRefCount(Expression* expr);
Expand Down Expand Up @@ -56,7 +55,7 @@ static ExpressionPtr MakeExpressionPtr(Args&&... args) {
/**
* An autodiff expression node.
*/
struct SLEIPNIR_DLLEXPORT Expression {
struct Expression {
/**
* Binary function taking two doubles and returning a double.
*/
Expand Down Expand Up @@ -201,8 +200,8 @@ struct SLEIPNIR_DLLEXPORT Expression {
* @param lhs Operator left-hand side.
* @param rhs Operator right-hand side.
*/
friend SLEIPNIR_DLLEXPORT ExpressionPtr operator*(const ExpressionPtr& lhs,
const ExpressionPtr& rhs) {
friend ExpressionPtr operator*(const ExpressionPtr& lhs,
const ExpressionPtr& rhs) {
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -256,8 +255,8 @@ struct SLEIPNIR_DLLEXPORT Expression {
* @param lhs Operator left-hand side.
* @param rhs Operator right-hand side.
*/
friend SLEIPNIR_DLLEXPORT ExpressionPtr operator/(const ExpressionPtr& lhs,
const ExpressionPtr& rhs) {
friend ExpressionPtr operator/(const ExpressionPtr& lhs,
const ExpressionPtr& rhs) {
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -304,8 +303,8 @@ struct SLEIPNIR_DLLEXPORT Expression {
* @param lhs Operator left-hand side.
* @param rhs Operator right-hand side.
*/
friend SLEIPNIR_DLLEXPORT ExpressionPtr operator+(const ExpressionPtr& lhs,
const ExpressionPtr& rhs) {
friend ExpressionPtr operator+(const ExpressionPtr& lhs,
const ExpressionPtr& rhs) {
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -338,8 +337,8 @@ struct SLEIPNIR_DLLEXPORT Expression {
* @param lhs Operator left-hand side.
* @param rhs Operator right-hand side.
*/
friend SLEIPNIR_DLLEXPORT ExpressionPtr operator-(const ExpressionPtr& lhs,
const ExpressionPtr& rhs) {
friend ExpressionPtr operator-(const ExpressionPtr& lhs,
const ExpressionPtr& rhs) {
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -376,7 +375,7 @@ struct SLEIPNIR_DLLEXPORT Expression {
*
* @param lhs Operand of unary minus.
*/
friend SLEIPNIR_DLLEXPORT ExpressionPtr operator-(const ExpressionPtr& lhs) {
friend ExpressionPtr operator-(const ExpressionPtr& lhs) {
using enum ExpressionType;

// Prune expression
Expand All @@ -403,15 +402,13 @@ struct SLEIPNIR_DLLEXPORT Expression {
*
* @param lhs Operand of unary plus.
*/
friend SLEIPNIR_DLLEXPORT ExpressionPtr operator+(const ExpressionPtr& lhs) {
return lhs;
}
friend ExpressionPtr operator+(const ExpressionPtr& lhs) { return lhs; }
};

SLEIPNIR_DLLEXPORT inline ExpressionPtr exp(const ExpressionPtr& x);
SLEIPNIR_DLLEXPORT inline ExpressionPtr sin(const ExpressionPtr& x);
SLEIPNIR_DLLEXPORT inline ExpressionPtr sinh(const ExpressionPtr& x);
SLEIPNIR_DLLEXPORT inline ExpressionPtr sqrt(const ExpressionPtr& x);
inline ExpressionPtr exp(const ExpressionPtr& x);
inline ExpressionPtr sin(const ExpressionPtr& x);
inline ExpressionPtr sinh(const ExpressionPtr& x);
inline ExpressionPtr sqrt(const ExpressionPtr& x);

/**
* Refcount increment for intrusive shared pointer.
Expand Down Expand Up @@ -467,8 +464,7 @@ inline constexpr void IntrusiveSharedPtrDecRefCount(Expression* expr) {
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr abs( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr abs(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -512,8 +508,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr abs( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr acos( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr acos(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -544,8 +539,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr acos( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr asin( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr asin(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -577,8 +571,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr asin( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr atan( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr atan(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -610,8 +603,8 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr atan( // NOLINT
* @param y The y argument.
* @param x The x argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr atan2( // NOLINT
const ExpressionPtr& y, const ExpressionPtr& x) {
inline ExpressionPtr atan2(const ExpressionPtr& y,
const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -651,8 +644,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr atan2( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr cos( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr cos(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -682,8 +674,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr cos( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr cosh( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr cosh(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -713,8 +704,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr cosh( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr erf( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr erf(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -748,8 +738,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr erf( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr exp( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr exp(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -780,8 +769,8 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr exp( // NOLINT
* @param x The x argument.
* @param y The y argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr hypot( // NOLINT
const ExpressionPtr& x, const ExpressionPtr& y) {
inline ExpressionPtr hypot(const ExpressionPtr& x,
const ExpressionPtr& y) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -820,8 +809,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr hypot( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr log( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr log(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand All @@ -848,8 +836,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr log( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr log10( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr log10(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -881,8 +868,8 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr log10( // NOLINT
* @param base The base.
* @param power The power.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr pow( // NOLINT
const ExpressionPtr& base, const ExpressionPtr& power) {
inline ExpressionPtr pow(const ExpressionPtr& base,
const ExpressionPtr& power) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -944,7 +931,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr pow( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr sign(const ExpressionPtr& x) {
inline ExpressionPtr sign(const ExpressionPtr& x) {
using enum ExpressionType;

// Evaluate constant
Expand Down Expand Up @@ -983,8 +970,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr sign(const ExpressionPtr& x) {
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr sin( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr sin(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -1015,7 +1001,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr sin( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr sinh(const ExpressionPtr& x) {
inline ExpressionPtr sinh(const ExpressionPtr& x) {
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -1046,8 +1032,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr sinh(const ExpressionPtr& x) {
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr sqrt( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr sqrt(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Evaluate constant
Expand Down Expand Up @@ -1080,8 +1065,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr sqrt( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr tan( // NOLINT
const ExpressionPtr& x) {
inline ExpressionPtr tan(const ExpressionPtr& x) { // NOLINT
using enum ExpressionType;

// Prune expression
Expand Down Expand Up @@ -1113,7 +1097,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr tan( // NOLINT
*
* @param x The argument.
*/
SLEIPNIR_DLLEXPORT inline ExpressionPtr tanh(const ExpressionPtr& x) {
inline ExpressionPtr tanh(const ExpressionPtr& x) {
using enum ExpressionType;

// Prune expression
Expand Down
3 changes: 1 addition & 2 deletions include/sleipnir/autodiff/ExpressionGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "sleipnir/autodiff/Expression.hpp"
#include "sleipnir/util/FunctionRef.hpp"
#include "sleipnir/util/SymbolExports.hpp"
#include "sleipnir/util/small_vector.hpp"

namespace sleipnir::detail {
Expand All @@ -15,7 +14,7 @@ namespace sleipnir::detail {
* This class is an adaptor type that performs value updates of an expression's
* computational graph in a way that skips duplicates.
*/
class SLEIPNIR_DLLEXPORT ExpressionGraph {
class ExpressionGraph {
public:
/**
* Generates the deduplicated computational graph for the given expression.
Expand Down
4 changes: 1 addition & 3 deletions include/sleipnir/autodiff/Profiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

#include <chrono>

#include "sleipnir/util/SymbolExports.hpp"

namespace sleipnir {

/**
* Records the number of profiler measurements (start/stop pairs) and the
* average duration between each start and stop call.
*/
class SLEIPNIR_DLLEXPORT Profiler {
class Profiler {
public:
/**
* Tell the profiler to start measuring setup time.
Expand Down

0 comments on commit 7e5be71

Please sign in to comment.