@@ -2,14 +2,17 @@ module AsArrayModule
2
2
3
3
using .. NodeModule: AbstractExpressionNode, tree_mapreduce, count_nodes
4
4
5
+ function as_array (
6
+ :: Type{I} , trees:: N ; buffer= nothing
7
+ ) where {T,N<: AbstractExpressionNode{T} ,I}
8
+ return as_array (I, (trees,); buffer= buffer)
9
+ end
10
+
5
11
function as_array (
6
12
:: Type{I} ,
7
- trees:: Union{N, Tuple{N,Vararg{N}},AbstractVector{N}} ;
13
+ trees:: Union{Tuple{N,Vararg{N}},AbstractVector{N}} ;
8
14
buffer:: Union{AbstractArray,Nothing} = nothing ,
9
15
) where {T,N<: AbstractExpressionNode{T} ,I}
10
- if trees isa N
11
- return as_array (I, (trees,); buffer= buffer)
12
- end
13
16
each_num_nodes = (t -> count_nodes (t; break_sharing= Val (true ))). (trees)
14
17
num_nodes = sum (each_num_nodes)
15
18
@@ -25,7 +28,7 @@ function as_array(
25
28
val = Array {T} (undef, num_nodes)
26
29
27
30
# # Views of the same matrix:
28
- buffer = buffer === nothing ? Array {I} (undef, 8 , num_nodes) : buffer
31
+ buffer = @something ( buffer, Array {I} (undef, 8 , num_nodes))
29
32
degree = @view buffer[1 , :]
30
33
feature = @view buffer[2 , :]
31
34
op = @view buffer[3 , :]
0 commit comments