@@ -112,14 +112,36 @@ end
112
112
113
113
function test_functions_on_trees (:: Type{T} , operators) where {T}
114
114
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]
116
120
x = Node (T1; feature= 1 )
117
121
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)
123
145
end
124
146
tree = convert (Node{T}, tree)
125
147
for preserve_topology in [true , false ]
174
196
""" `mode=:precompile` will use `@precompile_*` directives; `mode=:compile` runs."""
175
197
function do_precompilation (; mode= :precompile )
176
198
@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 ]
180
202
types = [Float32, Float64]
181
203
@maybe_precompile_all_calls mode begin
182
204
test_all_combinations (;
@@ -192,7 +214,7 @@ function do_precompilation(; mode=:precompile)
192
214
define_helper_functions= false ,
193
215
)
194
216
# Want to precompile all above calls.
195
- types = [Float16, Float32, Float64]
217
+ types = [Float32, Float64]
196
218
for T in types
197
219
@maybe_precompile_all_calls mode begin
198
220
test_functions_on_trees (T, operators)
0 commit comments