Skip to content

Commit 1492c0e

Browse files
authored
Merge pull request #18 from SymbolicML/reduce-precompilation
Reduce precompilation
2 parents 03ee2c5 + 6cd8107 commit 1492c0e

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

src/precompile.jl

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,36 @@ end
112112

113113
function test_functions_on_trees(::Type{T}, operators) where {T}
114114
local x, c, tree
115-
for T1 in [Float16, Float32, Float64]
115+
num_unaops = length(operators.unaops)
116+
num_binops = length(operators.binops)
117+
@assert num_unaops > 0 && num_binops > 0
118+
119+
for T1 in [Float32, Float64]
116120
x = Node(T1; feature=1)
117121
c = Node(T1; val=T1(1.0))
118-
tree = Node(
119-
2,
120-
Node(1, Node(1, Node(2, x, c), Node(3, c, Node(1, x)))),
121-
Node(3, Node(1, Node(4, x, x))),
122-
)
122+
123+
i_una = 1
124+
i_bin = 1
125+
126+
# Here, we just cycle through the operators and build
127+
# a more complex expression.
128+
a1 = Node(i_una, x)
129+
i_una = (i_una % num_unaops) + 1
130+
a2 = Node(i_bin, c, a1)
131+
i_bin = (i_bin % num_binops) + 1
132+
a3 = Node(i_bin, x, c)
133+
i_bin = (i_bin % num_binops) + 1
134+
a4 = Node(i_bin, a3, a2)
135+
i_bin = (i_bin % num_binops) + 1
136+
a5 = Node(i_bin, x, x)
137+
i_bin = (i_bin % num_binops) + 1
138+
a6 = Node(i_una, a5)
139+
i_una = (i_una % num_unaops) + 1
140+
a7 = Node(i_una, a6)
141+
i_una = (i_una % num_unaops) + 1
142+
a8 = Node(i_una, a4)
143+
i_una = (i_una % num_unaops) + 1
144+
tree = Node(i_bin, a8, a7)
123145
end
124146
tree = convert(Node{T}, tree)
125147
for preserve_topology in [true, false]
@@ -174,9 +196,9 @@ end
174196
"""`mode=:precompile` will use `@precompile_*` directives; `mode=:compile` runs."""
175197
function do_precompilation(; mode=:precompile)
176198
@maybe_precompile_setup mode begin
177-
binary_operators = [[+, -, *, /, ^]]
178-
unary_operators = [[sin, cos, exp, log, sqrt, abs]]
179-
turbo = [true, false]
199+
binary_operators = [[+, -, *, /]]
200+
unary_operators = [[sin, cos]]
201+
turbo = [false]
180202
types = [Float32, Float64]
181203
@maybe_precompile_all_calls mode begin
182204
test_all_combinations(;
@@ -192,7 +214,7 @@ function do_precompilation(; mode=:precompile)
192214
define_helper_functions=false,
193215
)
194216
# Want to precompile all above calls.
195-
types = [Float16, Float32, Float64]
217+
types = [Float32, Float64]
196218
for T in types
197219
@maybe_precompile_all_calls mode begin
198220
test_functions_on_trees(T, operators)

0 commit comments

Comments
 (0)