@@ -2,6 +2,7 @@ module DynamicExpressionsLoopVectorizationExt
2
2
3
3
using LoopVectorization: @turbo
4
4
using DynamicExpressions: AbstractExpressionNode
5
+ using DynamicExpressions. NodeModule: get_child
5
6
using DynamicExpressions. UtilsModule: ResultOk
6
7
using DynamicExpressions. EvaluateModule:
7
8
@return_on_nonfinite_val , EvalOptions, get_array, get_feature_array, get_filled_array
@@ -39,30 +40,31 @@ function deg1_l2_ll0_lr0_eval(
39
40
op_l:: F2 ,
40
41
eval_options:: EvalOptions{true} ,
41
42
) where {T<: Number ,F,F2}
42
- if tree. l. l. constant && tree. l. r. constant
43
- val_ll = tree. l. l. val
44
- val_lr = tree. l. r. val
43
+ if get_child (get_child (tree, 1 ), 1 ). constant &&
44
+ get_child (get_child (tree, 1 ), 2 ). constant
45
+ val_ll = get_child (get_child (tree, 1 ), 1 ). val
46
+ val_lr = get_child (get_child (tree, 1 ), 2 ). val
45
47
@return_on_nonfinite_val (eval_options, val_ll, cX)
46
48
@return_on_nonfinite_val (eval_options, val_lr, cX)
47
49
x_l = op_l (val_ll, val_lr):: T
48
50
@return_on_nonfinite_val (eval_options, x_l, cX)
49
51
x = op (x_l):: T
50
52
@return_on_nonfinite_val (eval_options, x, cX)
51
53
return ResultOk (get_filled_array (eval_options. buffer, x, cX, axes (cX, 2 )), true )
52
- elseif tree. l . l . constant
53
- val_ll = tree. l . l . val
54
+ elseif get_child ( get_child ( tree, 1 ), 1 ) . constant
55
+ val_ll = get_child ( get_child ( tree, 1 ), 1 ) . val
54
56
@return_on_nonfinite_val (eval_options, val_ll, cX)
55
- feature_lr = tree. l . r . feature
57
+ feature_lr = get_child ( get_child ( tree, 1 ), 2 ) . feature
56
58
cumulator = get_array (eval_options. buffer, cX, axes (cX, 2 ))
57
59
@turbo for j in axes (cX, 2 )
58
60
x_l = op_l (val_ll, cX[feature_lr, j])
59
61
x = op (x_l)
60
62
cumulator[j] = x
61
63
end
62
64
return ResultOk (cumulator, true )
63
- elseif tree. l . r . constant
64
- feature_ll = tree. l . l . feature
65
- val_lr = tree. l . r . val
65
+ elseif get_child ( get_child ( tree, 1 ), 2 ) . constant
66
+ feature_ll = get_child ( get_child ( tree, 1 ), 1 ) . feature
67
+ val_lr = get_child ( get_child ( tree, 1 ), 2 ) . val
66
68
@return_on_nonfinite_val (eval_options, val_lr, cX)
67
69
cumulator = get_array (eval_options. buffer, cX, axes (cX, 2 ))
68
70
@turbo for j in axes (cX, 2 )
@@ -72,8 +74,8 @@ function deg1_l2_ll0_lr0_eval(
72
74
end
73
75
return ResultOk (cumulator, true )
74
76
else
75
- feature_ll = tree. l . l . feature
76
- feature_lr = tree. l . r . feature
77
+ feature_ll = get_child ( get_child ( tree, 1 ), 1 ) . feature
78
+ feature_lr = get_child ( get_child ( tree, 1 ), 2 ) . feature
77
79
cumulator = get_array (eval_options. buffer, cX, axes (cX, 2 ))
78
80
@turbo for j in axes (cX, 2 )
79
81
x_l = op_l (cX[feature_ll, j], cX[feature_lr, j])
@@ -91,16 +93,16 @@ function deg1_l1_ll0_eval(
91
93
op_l:: F2 ,
92
94
eval_options:: EvalOptions{true} ,
93
95
) where {T<: Number ,F,F2}
94
- if tree. l . l . constant
95
- val_ll = tree. l . l . val
96
+ if get_child ( get_child ( tree, 1 ), 1 ) . constant
97
+ val_ll = get_child ( get_child ( tree, 1 ), 1 ) . val
96
98
@return_on_nonfinite_val (eval_options, val_ll, cX)
97
99
x_l = op_l (val_ll):: T
98
100
@return_on_nonfinite_val (eval_options, x_l, cX)
99
101
x = op (x_l):: T
100
102
@return_on_nonfinite_val (eval_options, x, cX)
101
103
return ResultOk (get_filled_array (eval_options. buffer, x, cX, axes (cX, 2 )), true )
102
104
else
103
- feature_ll = tree. l . l . feature
105
+ feature_ll = get_child ( get_child ( tree, 1 ), 1 ) . feature
104
106
cumulator = get_array (eval_options. buffer, cX, axes (cX, 2 ))
105
107
@turbo for j in axes (cX, 2 )
106
108
x_l = op_l (cX[feature_ll, j])
@@ -117,28 +119,28 @@ function deg2_l0_r0_eval(
117
119
op:: F ,
118
120
eval_options:: EvalOptions{true} ,
119
121
) where {T<: Number ,F}
120
- if tree. l . constant && tree. r . constant
121
- val_l = tree. l . val
122
+ if get_child ( tree, 1 ) . constant && get_child ( tree, 2 ) . constant
123
+ val_l = get_child ( tree, 1 ) . val
122
124
@return_on_nonfinite_val (eval_options, val_l, cX)
123
- val_r = tree. r . val
125
+ val_r = get_child ( tree, 2 ) . val
124
126
@return_on_nonfinite_val (eval_options, val_r, cX)
125
127
x = op (val_l, val_r):: T
126
128
@return_on_nonfinite_val (eval_options, x, cX)
127
129
return ResultOk (get_filled_array (eval_options. buffer, x, cX, axes (cX, 2 )), true )
128
- elseif tree. l . constant
130
+ elseif get_child ( tree, 1 ) . constant
129
131
cumulator = get_array (eval_options. buffer, cX, axes (cX, 2 ))
130
- val_l = tree. l . val
132
+ val_l = get_child ( tree, 1 ) . val
131
133
@return_on_nonfinite_val (eval_options, val_l, cX)
132
- feature_r = tree. r . feature
134
+ feature_r = get_child ( tree, 2 ) . feature
133
135
@turbo for j in axes (cX, 2 )
134
136
x = op (val_l, cX[feature_r, j])
135
137
cumulator[j] = x
136
138
end
137
139
return ResultOk (cumulator, true )
138
- elseif tree. r . constant
140
+ elseif get_child ( tree, 2 ) . constant
139
141
cumulator = get_array (eval_options. buffer, cX, axes (cX, 2 ))
140
- feature_l = tree. l . feature
141
- val_r = tree. r . val
142
+ feature_l = get_child ( tree, 1 ) . feature
143
+ val_r = get_child ( tree, 2 ) . val
142
144
@return_on_nonfinite_val (eval_options, val_r, cX)
143
145
@turbo for j in axes (cX, 2 )
144
146
x = op (cX[feature_l, j], val_r)
@@ -147,8 +149,8 @@ function deg2_l0_r0_eval(
147
149
return ResultOk (cumulator, true )
148
150
else
149
151
cumulator = get_array (eval_options. buffer, cX, axes (cX, 2 ))
150
- feature_l = tree. l . feature
151
- feature_r = tree. r . feature
152
+ feature_l = get_child ( tree, 1 ) . feature
153
+ feature_r = get_child ( tree, 2 ) . feature
152
154
@turbo for j in axes (cX, 2 )
153
155
x = op (cX[feature_l, j], cX[feature_r, j])
154
156
cumulator[j] = x
@@ -165,16 +167,16 @@ function deg2_l0_eval(
165
167
op:: F ,
166
168
eval_options:: EvalOptions{true} ,
167
169
) where {T<: Number ,F}
168
- if tree. l . constant
169
- val = tree. l . val
170
+ if get_child ( tree, 1 ) . constant
171
+ val = get_child ( tree, 1 ) . val
170
172
@return_on_nonfinite_val (eval_options, val, cX)
171
173
@turbo for j in eachindex (cumulator)
172
174
x = op (val, cumulator[j])
173
175
cumulator[j] = x
174
176
end
175
177
return ResultOk (cumulator, true )
176
178
else
177
- feature = tree. l . feature
179
+ feature = get_child ( tree, 1 ) . feature
178
180
@turbo for j in eachindex (cumulator)
179
181
x = op (cX[feature, j], cumulator[j])
180
182
cumulator[j] = x
@@ -190,16 +192,16 @@ function deg2_r0_eval(
190
192
op:: F ,
191
193
eval_options:: EvalOptions{true} ,
192
194
) where {T<: Number ,F}
193
- if tree. r . constant
194
- val = tree. r . val
195
+ if get_child ( tree, 2 ) . constant
196
+ val = get_child ( tree, 2 ) . val
195
197
@return_on_nonfinite_val (eval_options, val, cX)
196
198
@turbo for j in eachindex (cumulator)
197
199
x = op (cumulator[j], val)
198
200
cumulator[j] = x
199
201
end
200
202
return ResultOk (cumulator, true )
201
203
else
202
- feature = tree. r . feature
204
+ feature = get_child ( tree, 2 ) . feature
203
205
@turbo for j in eachindex (cumulator)
204
206
x = op (cumulator[j], cX[feature, j])
205
207
cumulator[j] = x
0 commit comments