Skip to content

Commit 5de3a49

Browse files
committed
refactor: ignore derivatives to speed up derivatives
1 parent fc2497b commit 5de3a49

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/DynamicExpressions.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import .ParseModule: parse_leaf
7676

7777
@stable default_mode = "disable" begin
7878
include("Interfaces.jl")
79+
include("NonDifferentiableDeclarations.jl")
7980
include("PatchMethods.jl")
8081
end
8182

src/Expression.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
module ExpressionModule
33

44
using DispatchDoctor: @unstable
5+
using ChainRulesCore: @ignore_derivatives
6+
57
using ..NodeModule: AbstractExpressionNode, Node
68
using ..OperatorEnumModule: AbstractOperatorEnum, OperatorEnum
79
using ..UtilsModule: Undefined
@@ -65,7 +67,7 @@ expression tree (like `Node`) along with associated metadata for evaluation and
6567
6668
- `tree::N`: The root node of the raw expression tree.
6769
- `metadata::Metadata{D}`: A named tuple of settings for the expression,
68-
such as the operators and variable names.
70+
such as the operators and variable names.
6971
7072
# Constructors
7173
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module NonDifferentiableDeclarationsModule
2+
3+
using ChainRulesCore: @non_differentiable
4+
import ..NodeUtilsModule: tree_mapreduce
5+
import ..ExpressionModule: get_operators, get_variable_names, _validate_input
6+
7+
@non_differentiable tree_mapreduce(args...)
8+
@non_differentiable get_operators(ex, operators)
9+
@non_differentiable get_variable_names(ex, variable_names)
10+
@non_differentiable _validate_input(ex, X, operators)
11+
12+
end

0 commit comments

Comments
 (0)