From 65ee090924a2db692440e33216c094a2428216fd Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Thu, 16 May 2024 17:39:54 -0400 Subject: [PATCH 01/22] add heuristic loop order --- src/scheduler/optimize.jl | 123 +++++++++++++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 2 deletions(-) diff --git a/src/scheduler/optimize.jl b/src/scheduler/optimize.jl index ebfb34928..85dc8a343 100644 --- a/src/scheduler/optimize.jl +++ b/src/scheduler/optimize.jl @@ -157,10 +157,10 @@ function propagate_transpose_queries_impl(node, productions, bindings) if lhs in productions query(lhs, rhs) else - if @capture rhs reorder(relabel(~rhs::isalias, ~idxs_1...), ~idxs_2...) + if @capture rhs reorder(relabel(~tns::isalias, ~idxs_1...), ~idxs_2...) bindings[lhs] = rhs plan() - elseif @capture rhs relabel(~rhs::isalias, ~idxs_1...) + elseif @capture rhs relabel(~tns::isalias, ~idxs_1...) bindings[lhs] = rhs plan() elseif isalias(rhs) @@ -391,6 +391,125 @@ function normalize_names(ex) Rewrite(Postwalk(@rule ~a::isalias => alias(normname(a.name))))(ex) end +function toposort(perms::Vector{Vector{T}}) where T + graph = Dict{T, Set{T}}() + for perm in perms + i = nothing + for j in perm + if i != nothing + push!(get!(graph, i, Set{T}()), j) + end + i = j + end + end + #https://rosettacode.org/wiki/Topological_sort#Julia + for (k, v) in graph + delete!(v, k) + end + extraitems = setdiff(reduce(union, values(graph)), keys(graph)) + for item in extraitems + graph[item] = Set{T}() + end + rst = Vector{T}() + while true + ordered = Set(item for (item, dep) in graph if isempty(dep)) + if isempty(ordered) break end + append!(rst, ordered) + graph = Dict{T,Set{T}}(item => setdiff(dep, ordered) for (item, dep) in graph if item ∉ ordered) + end + if isempty(graph) + return rst + else + # a cyclic dependency exists amongst $(keys(graph)) + return nothing + end +end + +function heuristic_loop_order(node) + perms = Vector{LogicNode}[] + for node in PostOrderDFS(node) + if @capture node relabel(~arg, ~idxs...) + push!(perms, idxs) + end + end + sort!(perms, by=length) + res = something(toposort(perms), getfields(node)) + if mapreduce(max, length, perms, init = 0) < length(unique(reduce(vcat, perms))) + counts = Dict() + for perm in perms + for idx in perm + counts[idx] = get(counts, idx, 0) + 1 + end + end + sort!(res, by=idx -> counts[idx] == 1, alg=Base.MergeSort) + end + return res +end + +""" +set_loop_order(root) + +Heuristically chooses a total order for all loops in the program by inserting +`reorder` statments inside reformat, query, and aggregate nodes. + +Accepts programs of the form: +``` + REORDER := reorder(relabel(ALIAS, FIELD...), FIELD...) + ACCESS := reorder(relabel(ALIAS, idxs_1::FIELD...), idxs_2::FIELD...) where issubsequence(idxs_1, idxs_2) + POINTWISE := ACCESS | mapjoin(IMMEDIATE, POINTWISE...) | reorder(IMMEDIATE, FIELD...) | IMMEDIATE + MAPREDUCE := POINTWISE | aggregate(IMMEDIATE, IMMEDIATE, POINTWISE, FIELD...) + TABLE := table(IMMEDIATE, FIELD...) +COMPUTE_QUERY := query(ALIAS, reformat(IMMEDIATE, arg::(REORDER | MAPREDUCE))) + INPUT_QUERY := query(ALIAS, TABLE) + STEP := COMPUTE_QUERY | INPUT_QUERY + ROOT := PLAN(STEP..., produces(ALIAS...)) +``` +""" +function set_loop_order(node, perms = Dict(), reps = Dict()) + if @capture node plan(~stmts...) + stmts = map(stmts) do stmt + set_loop_order(stmt, fields) + end + plan(stmts...) + elseif @capture node query(~lhs, reformat(~tns, ~rhs::isalias)) + rhs_2 = perms[rhs] + perms[lhs] = lhs + reps[lhs] = SuitableRep(reps)(rhs_2) + query(lhs, reformat(tns, rhs_2)) + elseif @capture node query(~lhs, reformat(~tns, ~rhs)) + arg = alias(gensym(:A)) + set_loop_order(plan( + query(A, rhs), + query(lhs, reformat(tns, A)) + ), perms, reps) + elseif @capture node query(~lhs, table(~tns, ~idxs...)) + reps[lhs] = SuitableRep(reps)(node.rhs) + perms[lhs] = lhs + node + elseif @capture node query(~lhs, aggregate(~op, ~init, ~arg, ~idxs...)) + arg = push_fields(Rewrite(Postwalk(tns -> get(perms, tns, tns)))(arg)) + idxs_2 = heuristic_loop_order(arg) + rhs_2 = aggregate(op, init, reorder(arg, idxs_2...), idxs...) + reps[lhs] = SuitableRep(reps)(rhs_2) + perms[lhs] = reorder(relabel(lhs, getfields(rhs_2)), getfields(node.rhs)) + query(lhs, rhs) + elseif @capture node query(~lhs, reorder(relabel(~tns::isalias, ~idxs_1...), ~idxs_2...)) + tns = get(perms, tns, tns) + reps[lhs] = SuitableRep(reps)(node.rhs) + perm[lhs] = lhs + elseif @capture node query(~lhs, ~rhs) + #assuming rhs is a bunch of mapjoins + arg = push_fields(Rewrite(Postwalk(tns -> get(perms, tns, tns)))(arg)) + idxs = heuristic_pointwise_loop_order(rhs) + rhs_2 = reorder(rhs, idxs...) + reps[lhs] = SuitableRep(reps)(rhs_2) + perms[lhs] = reorder(relabel(lhs, idxs), getfields(rhs)) + query(lhs, rhs_2) + else + throw(ArgumentError("Unrecognized program in set_loop_order")) + end +end + function optimize(prgm) #deduplicate and lift inline subqueries to regular queries prgm = lift_subqueries(prgm) From 0aab9f9df1aa3e9b2ea8776bfddf9ad50cc48f7f Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Thu, 16 May 2024 18:26:16 -0400 Subject: [PATCH 02/22] fix so that it works --- src/scheduler/optimize.jl | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/scheduler/optimize.jl b/src/scheduler/optimize.jl index 85dc8a343..b0e2c1519 100644 --- a/src/scheduler/optimize.jl +++ b/src/scheduler/optimize.jl @@ -418,7 +418,7 @@ function toposort(perms::Vector{Vector{T}}) where T graph = Dict{T,Set{T}}(item => setdiff(dep, ordered) for (item, dep) in graph if item ∉ ordered) end if isempty(graph) - return rst + return reverse(rst) else # a cyclic dependency exists amongst $(keys(graph)) return nothing @@ -434,7 +434,7 @@ function heuristic_loop_order(node) end sort!(perms, by=length) res = something(toposort(perms), getfields(node)) - if mapreduce(max, length, perms, init = 0) < length(unique(reduce(vcat, perms))) + if mapreduce(length, max, perms, init = 0) < length(unique(reduce(vcat, perms))) counts = Dict() for perm in perms for idx in perm @@ -468,7 +468,7 @@ COMPUTE_QUERY := query(ALIAS, reformat(IMMEDIATE, arg::(REORDER | MAPREDUCE))) function set_loop_order(node, perms = Dict(), reps = Dict()) if @capture node plan(~stmts...) stmts = map(stmts) do stmt - set_loop_order(stmt, fields) + set_loop_order(stmt, perms, reps) end plan(stmts...) elseif @capture node query(~lhs, reformat(~tns, ~rhs::isalias)) @@ -492,11 +492,12 @@ function set_loop_order(node, perms = Dict(), reps = Dict()) rhs_2 = aggregate(op, init, reorder(arg, idxs_2...), idxs...) reps[lhs] = SuitableRep(reps)(rhs_2) perms[lhs] = reorder(relabel(lhs, getfields(rhs_2)), getfields(node.rhs)) - query(lhs, rhs) + query(lhs, rhs_2) elseif @capture node query(~lhs, reorder(relabel(~tns::isalias, ~idxs_1...), ~idxs_2...)) tns = get(perms, tns, tns) reps[lhs] = SuitableRep(reps)(node.rhs) - perm[lhs] = lhs + perms[lhs] = lhs + node elseif @capture node query(~lhs, ~rhs) #assuming rhs is a bunch of mapjoins arg = push_fields(Rewrite(Postwalk(tns -> get(perms, tns, tns)))(arg)) @@ -505,6 +506,8 @@ function set_loop_order(node, perms = Dict(), reps = Dict()) reps[lhs] = SuitableRep(reps)(rhs_2) perms[lhs] = reorder(relabel(lhs, idxs), getfields(rhs)) query(lhs, rhs_2) + elseif @capture node produces(~args...) + push_fields(Rewrite(Postwalk(tns -> get(perms, tns, tns)))(node)) else throw(ArgumentError("Unrecognized program in set_loop_order")) end @@ -537,6 +540,9 @@ function optimize(prgm) #These steps assign a global loop order to each statement. prgm = propagate_fields(prgm) + display(prgm) + display(set_loop_order(prgm)) + prgm = push_fields(prgm) prgm = lift_fields(prgm) prgm = push_fields(prgm) From 035325f3c35650151a088c36ed44a5e47752cf99 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Thu, 16 May 2024 19:34:48 -0400 Subject: [PATCH 03/22] good progress --- src/interface/traits.jl | 9 ++-- src/scheduler/LogicCompiler.jl | 12 ++++- src/scheduler/LogicInterpreter.jl | 12 ++++- src/scheduler/optimize.jl | 77 +++++++++++++++++-------------- 4 files changed, 71 insertions(+), 39 deletions(-) diff --git a/src/interface/traits.jl b/src/interface/traits.jl index 12d5096ad..325d0cd80 100644 --- a/src/interface/traits.jl +++ b/src/interface/traits.jl @@ -14,6 +14,7 @@ Finch.finch_leaf(x::SparseData) = virtual(x) Base.ndims(fbr::SparseData) = 1 + ndims(fbr.lvl) fill_value(fbr::SparseData) = fill_value(fbr.lvl) Base.eltype(fbr::SparseData) = eltype(fbr.lvl) +is_concordant_rep(fbr::SparseData) = true """ RepeatData(lvl) @@ -29,6 +30,7 @@ Finch.finch_leaf(x::RepeatData) = virtual(x) Base.ndims(fbr::RepeatData) = 1 + ndims(fbr.lvl) fill_value(fbr::RepeatData) = fill_value(fbr.lvl) Base.eltype(fbr::RepeatData) = eltype(fbr.lvl) +is_concordant_rep(fbr::RepeatData) = true """ DenseData(lvl) @@ -40,9 +42,9 @@ struct DenseData end Finch.finch_leaf(x::DenseData) = virtual(x) fill_value(fbr::DenseData) = fill_value(fbr.lvl) - Base.ndims(fbr::DenseData) = 1 + ndims(fbr.lvl) Base.eltype(fbr::DenseData) = eltype(fbr.lvl) +is_concordant_rep(fbr::DenseData) = is_concordant_rep(fbr.lvl) """ ExtrudeData(lvl) @@ -56,6 +58,7 @@ Finch.finch_leaf(x::ExtrudeData) = virtual(x) fill_value(fbr::ExtrudeData) = fill_value(fbr.lvl) Base.ndims(fbr::ExtrudeData) = 1 + ndims(fbr.lvl) Base.eltype(fbr::ExtrudeData) = eltype(fbr.lvl) +is_concordant_rep(fbr::ExtrudeData) = is_concordant_rep(fbr.lvl) """ HollowData(lvl) @@ -67,9 +70,9 @@ struct HollowData end Finch.finch_leaf(x::HollowData) = virtual(x) fill_value(fbr::HollowData) = fill_value(fbr.lvl) - Base.ndims(fbr::HollowData) = ndims(fbr.lvl) Base.eltype(fbr::HollowData) = eltype(fbr.lvl) +is_concordant_rep(fbr::HollowData) = true """ ElementData(fill_value, eltype) @@ -82,9 +85,9 @@ struct ElementData end Finch.finch_leaf(x::ElementData) = virtual(x) fill_value(fbr::ElementData) = fbr.fill_value - Base.ndims(fbr::ElementData) = 0 Base.eltype(fbr::ElementData) = fbr.eltype +is_concordant_rep(fbr::ElementData) = false """ data_rep(tns) diff --git a/src/scheduler/LogicCompiler.jl b/src/scheduler/LogicCompiler.jl index 81c92ce5f..3b7e570f2 100644 --- a/src/scheduler/LogicCompiler.jl +++ b/src/scheduler/LogicCompiler.jl @@ -143,7 +143,17 @@ function (ctx::LogicLowerer)(ex) end end elseif @capture ex produces(~args...) - return :(return ($(map(arg -> arg.name, args)...),)) + return :(return ($(map(args) do arg + if @capture(arg, reorder(relabel(~tns::isalias, ~idxs_1...), ~idxs_2...)) && Set(idxs_1) == Set(idxs_2) + :(swizzle($(tns.name), $([findfirst(isequal(idx), idxs_2) for idx in idxs_1]...))) + elseif @capture(arg, reorder(~tns::isalias, ~idxs...)) + arg.name + elseif isalias(arg) + arg.name + else + error("Unrecognized logic: $(arg)") + end + end...),)) elseif @capture ex plan(~bodies...) Expr(:block, map(ctx, bodies)...) else diff --git a/src/scheduler/LogicInterpreter.jl b/src/scheduler/LogicInterpreter.jl index f7f6889e8..672e66ecc 100644 --- a/src/scheduler/LogicInterpreter.jl +++ b/src/scheduler/LogicInterpreter.jl @@ -87,7 +87,17 @@ function (ctx::LogicMachine)(ex) end execute(body, mode = ctx.mode).res elseif @capture ex produces(~args...) - return map(arg -> ctx.scope[arg], args) + return map(args) do arg + if @capture(arg, reorder(relabel(~tns::isalias, ~idxs_1...), ~idxs_2...)) && Set(idxs_1) == Set(idxs_2) + return swizzle(ctx.scope[arg], [findfirst(isequal(idx), idxs_2) for idx in idxs_1]...) + elseif @capture(arg, reorder(~tns::isalias, ~idxs...)) + ctx.scope[arg] + elseif isalias(arg) + ctx.scope[arg] + else + error("Unrecognized logic: $(arg)") + end + end elseif @capture ex plan(~head) ctx(head) elseif @capture ex plan(~head, ~tail...) diff --git a/src/scheduler/optimize.jl b/src/scheduler/optimize.jl index b0e2c1519..b34aedf9e 100644 --- a/src/scheduler/optimize.jl +++ b/src/scheduler/optimize.jl @@ -1,5 +1,6 @@ flatten_plans = Rewrite(Postwalk(Fixpoint(Chain([ - (@rule plan(~a1..., plan(~b...), ~a2...) => plan(a1..., b..., a2...)), + (@rule plan(~s1..., plan(~s2...), ~s3...) => plan(s1, s2, s3)), + (@rule plan(~s1..., produces(~p...), ~s2...) => plan(s1, produces(p))), ])))) isolate_aggregates = Rewrite(Postwalk( @@ -138,40 +139,36 @@ Accepts programs of the form: INPUT_QUERY := query(ALIAS, TABLE) COMPUTE_QUERY := query(ALIAS, reformat(IMMEDIATE, MAPREDUCE)) | query(ALIAS, MAPREDUCE)) PLAN := plan(STEP...) - STEP := COMPUTE_QUERY | INPUT_QUERY | PLAN | produces(ALIAS...) + STEP := COMPUTE_QUERY | INPUT_QUERY | PLAN | produces((ALIAS | ACCESS)...) ROOT := STEP ``` """ function propagate_transpose_queries(root::LogicNode) - return propagate_transpose_queries_impl(root, getproductions(root), Dict{LogicNode, LogicNode}()) + return propagate_transpose_queries_impl(root, Dict{LogicNode, LogicNode}()) end -function propagate_transpose_queries_impl(node, productions, bindings) +function propagate_transpose_queries_impl(node, bindings) if @capture node plan(~stmts...) stmts = map(stmts) do stmt - propagate_transpose_queries_impl(stmt, productions, bindings) + propagate_transpose_queries_impl(stmt, bindings) end plan(stmts...) elseif @capture node query(~lhs, ~rhs) rhs = push_fields(Rewrite(Postwalk((node) -> get(bindings, node, node)))(rhs)) - if lhs in productions - query(lhs, rhs) + if @capture rhs reorder(relabel(~tns::isalias, ~idxs_1...), ~idxs_2...) + bindings[lhs] = rhs + plan() + elseif @capture rhs relabel(~tns::isalias, ~idxs_1...) + bindings[lhs] = rhs + plan() + elseif isalias(rhs) + bindings[lhs] = rhs + plan() else - if @capture rhs reorder(relabel(~tns::isalias, ~idxs_1...), ~idxs_2...) - bindings[lhs] = rhs - plan() - elseif @capture rhs relabel(~tns::isalias, ~idxs_1...) - bindings[lhs] = rhs - plan() - elseif isalias(rhs) - bindings[lhs] = rhs - plan() - else - query(lhs, rhs) - end + query(lhs, rhs) end elseif @capture node produces(~args...) - node + push_fields(Rewrite(Postwalk((node) -> get(bindings, node, node)))(node)) else throw(ArgumentError("Unrecognized program in propagate_transpose_queries")) end @@ -253,7 +250,7 @@ Accepts a program of the following form: IMMEDIATE COMPUTE_QUERY := query(ALIAS, COMPUTE) INPUT_QUERY := query(ALIAS, TABLE) - STEP := COMPUTE_QUERY | INPUT_QUERY | produces(ALIAS...) + STEP := COMPUTE_QUERY | INPUT_QUERY | produces((ALIAS | ACCESS)...) ROOT := PLAN(STEP...) ``` @@ -269,6 +266,10 @@ function concordize(root) needed_swizzles = Dict() spc = Namespace() map(node->freshen(spc, node.name), unique(filter(Or(isfield, isalias), collect(PostOrderDFS(root))))) + #Exempt productions from swizzling + root = flatten_plans(root) + @assert @capture root plan(~s..., produces(~p...)) + root = plan(s) #Collect the needed swizzles root = Rewrite(Postwalk( @rule reorder(relabel(~a::isalias, ~idxs_1...), ~idxs_2...) => begin @@ -292,7 +293,7 @@ function concordize(root) end end), ])))(root) - root = flatten_plans(root) + root = flatten_plans(plan(root, produces(p))) end drop_noisy_reorders = Rewrite(Postwalk( @@ -406,7 +407,7 @@ function toposort(perms::Vector{Vector{T}}) where T for (k, v) in graph delete!(v, k) end - extraitems = setdiff(reduce(union, values(graph)), keys(graph)) + extraitems = setdiff(reduce(union, values(graph), init=Set()), keys(graph)) for item in extraitems graph[item] = Set{T}() end @@ -425,14 +426,16 @@ function toposort(perms::Vector{Vector{T}}) where T end end -function heuristic_loop_order(node) +function heuristic_loop_order(node, reps) perms = Vector{LogicNode}[] for node in PostOrderDFS(node) - if @capture node relabel(~arg, ~idxs...) - push!(perms, idxs) + if @capture node reorder(relabel(~arg, ~idxs...), ~idxs_2...) + push!(perms, intersect(idxs, idxs_2)) end end - sort!(perms, by=length) + for idx in getfields(node) + push!(perms, [idx]) + end res = something(toposort(perms), getfields(node)) if mapreduce(length, max, perms, init = 0) < length(unique(reduce(vcat, perms))) counts = Dict() @@ -488,9 +491,12 @@ function set_loop_order(node, perms = Dict(), reps = Dict()) node elseif @capture node query(~lhs, aggregate(~op, ~init, ~arg, ~idxs...)) arg = push_fields(Rewrite(Postwalk(tns -> get(perms, tns, tns)))(arg)) - idxs_2 = heuristic_loop_order(arg) + idxs_2 = heuristic_loop_order(arg, reps) rhs_2 = aggregate(op, init, reorder(arg, idxs_2...), idxs...) reps[lhs] = SuitableRep(reps)(rhs_2) + println(node.rhs) + println(rhs_2) + println() perms[lhs] = reorder(relabel(lhs, getfields(rhs_2)), getfields(node.rhs)) query(lhs, rhs_2) elseif @capture node query(~lhs, reorder(relabel(~tns::isalias, ~idxs_1...), ~idxs_2...)) @@ -500,14 +506,14 @@ function set_loop_order(node, perms = Dict(), reps = Dict()) node elseif @capture node query(~lhs, ~rhs) #assuming rhs is a bunch of mapjoins - arg = push_fields(Rewrite(Postwalk(tns -> get(perms, tns, tns)))(arg)) - idxs = heuristic_pointwise_loop_order(rhs) + rhs = push_fields(Rewrite(Postwalk(tns -> get(perms, tns, tns)))(rhs)) + idxs = heuristic_loop_order(rhs, reps) rhs_2 = reorder(rhs, idxs...) reps[lhs] = SuitableRep(reps)(rhs_2) perms[lhs] = reorder(relabel(lhs, idxs), getfields(rhs)) query(lhs, rhs_2) elseif @capture node produces(~args...) - push_fields(Rewrite(Postwalk(tns -> get(perms, tns, tns)))(node)) + Rewrite(Postwalk(tns -> get(perms, tns, tns)))(node) else throw(ArgumentError("Unrecognized program in set_loop_order")) end @@ -539,12 +545,15 @@ function optimize(prgm) #These steps assign a global loop order to each statement. prgm = propagate_fields(prgm) + prgm = push_fields(prgm) + prgm = lift_fields(prgm) + prgm = push_fields(prgm) + prgm = propagate_transpose_queries(prgm) + display(prgm) + prgm = set_loop_order(prgm) display(prgm) - display(set_loop_order(prgm)) - prgm = push_fields(prgm) - prgm = lift_fields(prgm) prgm = push_fields(prgm) #After we have a global loop order, we concordize the program From faa9d4390b0143a9c111b6eb38e0c21893a62cd5 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Fri, 17 May 2024 14:18:27 -0400 Subject: [PATCH 04/22] slight improvement, but puts expanding/squeezing swizzles in the output --- src/scheduler/optimize.jl | 66 ++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/src/scheduler/optimize.jl b/src/scheduler/optimize.jl index b34aedf9e..79e61d7f4 100644 --- a/src/scheduler/optimize.jl +++ b/src/scheduler/optimize.jl @@ -392,60 +392,54 @@ function normalize_names(ex) Rewrite(Postwalk(@rule ~a::isalias => alias(normname(a.name))))(ex) end -function toposort(perms::Vector{Vector{T}}) where T - graph = Dict{T, Set{T}}() - for perm in perms - i = nothing - for j in perm - if i != nothing - push!(get!(graph, i, Set{T}()), j) +function toposort(chains::Vector{Vector{T}}) where T + chains = filter(!isempty, deepcopy(chains)) + parents = Dict{T, Int}(map(chain -> first(chain) => 0, chains)) + for chain in chains, u in chain[2:end] + parents[u] += 1 + end + roots = filter(u -> parents[u] == 0, keys(parents)) + perm = [] + while !isempty(parents) + isempty(roots) && return nothing + push!(perm, pop!(roots)) + for chain in chains + if !isempty(chain) && first(chain) == last(perm) + popfirst!(chain) + if !isempty(chain) + parents[first(chain)] -= 1 + if parents[first(chain)] == 0 + push!(roots, first(chain)) + end + end end - i = j end + pop!(parents, last(perm)) end - #https://rosettacode.org/wiki/Topological_sort#Julia - for (k, v) in graph - delete!(v, k) - end - extraitems = setdiff(reduce(union, values(graph), init=Set()), keys(graph)) - for item in extraitems - graph[item] = Set{T}() - end - rst = Vector{T}() - while true - ordered = Set(item for (item, dep) in graph if isempty(dep)) - if isempty(ordered) break end - append!(rst, ordered) - graph = Dict{T,Set{T}}(item => setdiff(dep, ordered) for (item, dep) in graph if item ∉ ordered) - end - if isempty(graph) - return reverse(rst) - else - # a cyclic dependency exists amongst $(keys(graph)) - return nothing - end + return perm end function heuristic_loop_order(node, reps) - perms = Vector{LogicNode}[] + chains = Vector{LogicNode}[] for node in PostOrderDFS(node) if @capture node reorder(relabel(~arg, ~idxs...), ~idxs_2...) - push!(perms, intersect(idxs, idxs_2)) + push!(chains, intersect(idxs, idxs_2)) end end for idx in getfields(node) - push!(perms, [idx]) + push!(chains, [idx]) end - res = something(toposort(perms), getfields(node)) - if mapreduce(length, max, perms, init = 0) < length(unique(reduce(vcat, perms))) + res = something(toposort(chains), getfields(node)) + if mapreduce(length, max, chains, init = 0) < length(unique(reduce(vcat, chains))) counts = Dict() - for perm in perms - for idx in perm + for chain in chains + for idx in chain counts[idx] = get(counts, idx, 0) + 1 end end sort!(res, by=idx -> counts[idx] == 1, alg=Base.MergeSort) end + @info "Heuristic loop order" res getfields(node) return res end From bf593b84ab43692c37d80393534349bff7da3ed7 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Fri, 17 May 2024 14:36:43 -0400 Subject: [PATCH 05/22] clean up --- src/scheduler/optimize.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/scheduler/optimize.jl b/src/scheduler/optimize.jl index 79e61d7f4..da8e2a93b 100644 --- a/src/scheduler/optimize.jl +++ b/src/scheduler/optimize.jl @@ -439,7 +439,6 @@ function heuristic_loop_order(node, reps) end sort!(res, by=idx -> counts[idx] == 1, alg=Base.MergeSort) end - @info "Heuristic loop order" res getfields(node) return res end @@ -544,10 +543,7 @@ function optimize(prgm) prgm = push_fields(prgm) prgm = propagate_transpose_queries(prgm) - display(prgm) prgm = set_loop_order(prgm) - display(prgm) - prgm = push_fields(prgm) #After we have a global loop order, we concordize the program From 039328f1e9c1d710fd895b4ff4d134b3ecaa583f Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Fri, 17 May 2024 19:43:18 -0400 Subject: [PATCH 06/22] new scheduler just dropped --- src/FinchLogic/nodes.jl | 8 +- src/scheduler/LogicCompiler.jl | 4 +- src/scheduler/LogicInterpreter.jl | 4 +- src/scheduler/optimize.jl | 38 ++++++--- test/reference64/interface/asmd.txt | 98 ++---------------------- test/reference64/interface/broadcast.txt | 24 +----- test/reference64/interface/reduce.txt | 29 ++----- test/test_interface.jl | 2 +- 8 files changed, 57 insertions(+), 150 deletions(-) diff --git a/src/FinchLogic/nodes.jl b/src/FinchLogic/nodes.jl index 8579f6d03..79c624f05 100644 --- a/src/FinchLogic/nodes.jl +++ b/src/FinchLogic/nodes.jl @@ -450,7 +450,13 @@ end function getproductions(node::LogicNode) for node in PostOrderDFS(node) if node.kind == produces - return node.args + res = [] + for arg in PostOrderDFS(node) + if isalias(arg) + push!(res, arg) + end + end + return res end end return [] diff --git a/src/scheduler/LogicCompiler.jl b/src/scheduler/LogicCompiler.jl index 3b7e570f2..f0b0c7963 100644 --- a/src/scheduler/LogicCompiler.jl +++ b/src/scheduler/LogicCompiler.jl @@ -145,9 +145,9 @@ function (ctx::LogicLowerer)(ex) elseif @capture ex produces(~args...) return :(return ($(map(args) do arg if @capture(arg, reorder(relabel(~tns::isalias, ~idxs_1...), ~idxs_2...)) && Set(idxs_1) == Set(idxs_2) - :(swizzle($(tns.name), $([findfirst(isequal(idx), idxs_2) for idx in idxs_1]...))) + :(swizzle($(tns.name), $([findfirst(isequal(idx), idxs_1) for idx in idxs_2]...))) elseif @capture(arg, reorder(~tns::isalias, ~idxs...)) - arg.name + tns.name elseif isalias(arg) arg.name else diff --git a/src/scheduler/LogicInterpreter.jl b/src/scheduler/LogicInterpreter.jl index 672e66ecc..b9497775b 100644 --- a/src/scheduler/LogicInterpreter.jl +++ b/src/scheduler/LogicInterpreter.jl @@ -89,9 +89,9 @@ function (ctx::LogicMachine)(ex) elseif @capture ex produces(~args...) return map(args) do arg if @capture(arg, reorder(relabel(~tns::isalias, ~idxs_1...), ~idxs_2...)) && Set(idxs_1) == Set(idxs_2) - return swizzle(ctx.scope[arg], [findfirst(isequal(idx), idxs_2) for idx in idxs_1]...) + return swizzle(ctx.scope[tns], [findfirst(isequal(idx), idxs_1) for idx in idxs_2]...) elseif @capture(arg, reorder(~tns::isalias, ~idxs...)) - ctx.scope[arg] + ctx.scope[tns] elseif isalias(arg) ctx.scope[arg] else diff --git a/src/scheduler/optimize.jl b/src/scheduler/optimize.jl index da8e2a93b..58fb89752 100644 --- a/src/scheduler/optimize.jl +++ b/src/scheduler/optimize.jl @@ -143,14 +143,10 @@ COMPUTE_QUERY := query(ALIAS, reformat(IMMEDIATE, MAPREDUCE)) | query(ALIAS, MAP ROOT := STEP ``` """ -function propagate_transpose_queries(root::LogicNode) - return propagate_transpose_queries_impl(root, Dict{LogicNode, LogicNode}()) -end - -function propagate_transpose_queries_impl(node, bindings) +function propagate_transpose_queries(node, bindings = Dict{LogicNode, LogicNode}()) if @capture node plan(~stmts...) stmts = map(stmts) do stmt - propagate_transpose_queries_impl(stmt, bindings) + propagate_transpose_queries(stmt, bindings) end plan(stmts...) elseif @capture node query(~lhs, ~rhs) @@ -174,6 +170,29 @@ function propagate_transpose_queries_impl(node, bindings) end end +""" +materialize_squeeze_expand_productions(root) + +Makes separate kernels for squeeze and expand operations in produces statements, +since swizzle does not support this. +""" +function materialize_squeeze_expand_productions(root) + Rewrite(Postwalk(@rule produces(~args...) => begin + preamble = [] + args_2 = map(args) do arg + if (@capture arg reorder(relabel(~tns::isalias, ~idxs_1...), ~idxs_2...)) && Set(idxs_1) != Set(idxs_2) + tns_2 = alias(gensym(:A)) + idxs_3 = withsubsequence(intersect(idxs_1, idxs_2), idxs_2) + push!(preamble, query(tns_2, reorder(relabel(tns, idxs_1), idxs_3))) + reorder(relabel(tns_2, idxs_3), idxs_2) + else + arg + end + end + plan(preamble, produces(args_2)) + end))(root) +end + function propagate_copy_queries(root) copies = Dict() for node in PostOrderDFS(root) @@ -487,9 +506,6 @@ function set_loop_order(node, perms = Dict(), reps = Dict()) idxs_2 = heuristic_loop_order(arg, reps) rhs_2 = aggregate(op, init, reorder(arg, idxs_2...), idxs...) reps[lhs] = SuitableRep(reps)(rhs_2) - println(node.rhs) - println(rhs_2) - println() perms[lhs] = reorder(relabel(lhs, getfields(rhs_2)), getfields(node.rhs)) query(lhs, rhs_2) elseif @capture node query(~lhs, reorder(relabel(~tns::isalias, ~idxs_1...), ~idxs_2...)) @@ -549,10 +565,14 @@ function optimize(prgm) #After we have a global loop order, we concordize the program prgm = concordize(prgm) + prgm = materialize_squeeze_expand_productions(prgm) + prgm = propagate_copy_queries(prgm) + #Add reformat statements where there aren't any prgm = propagate_into_reformats(prgm) prgm = propagate_copy_queries(prgm) + #Normalize names for caching prgm = normalize_names(prgm) end diff --git a/test/reference64/interface/asmd.txt b/test/reference64/interface/asmd.txt index 1c0fdc50b..1d81455b3 100644 --- a/test/reference64/interface/asmd.txt +++ b/test/reference64/interface/asmd.txt @@ -11,101 +11,17 @@ Dense [:,1:3] └─ [3]: 5.5 julia> A + 1 -Dense [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.1 -│ ├─ [3]: 3.2 -│ └─ [4]: 4.3 -├─ [:, 2]: Dense [1:4] -│ ├─ [1]: 1.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 1.0 -└─ [:, 3]: Dense [1:4] - ├─ [1]: 5.4 - ├─ [2]: 1.0 - ├─ [3]: 6.5 - └─ [4]: 1.0 - +SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{1.0, Float64, Int64}([1.0, 2.1, 3.2, 4.3, 1.0, 1.0, 1.0, 1.0, 5.4, 1.0, 6.5, 1.0]), 4), 3)), (1, 2)) julia> 1 + A -Dense [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.1 -│ ├─ [3]: 3.2 -│ └─ [4]: 4.3 -├─ [:, 2]: Dense [1:4] -│ ├─ [1]: 1.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 1.0 -└─ [:, 3]: Dense [1:4] - ├─ [1]: 5.4 - ├─ [2]: 1.0 - ├─ [3]: 6.5 - └─ [4]: 1.0 - +SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{1.0, Float64, Int64}([1.0, 2.1, 3.2, 4.3, 1.0, 1.0, 1.0, 1.0, 5.4, 1.0, 6.5, 1.0]), 4), 3)), (1, 2)) julia> A + A -Dense [:,1:3] -├─ [:, 1]: Sparse (0.0) [1:4] -│ ├─ [2]: 2.2 -│ ├─ [3]: 4.4 -│ └─ [4]: 6.6 -├─ [:, 2]: Sparse (0.0) [1:4] -└─ [:, 3]: Sparse (0.0) [1:4] - ├─ [1]: 8.8 - └─ [3]: 11.0 - +SwizzleArray(Tensor(Dense{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([2.2, 4.4, 6.6, 8.8, 11.0]), 4, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (3, 1) => 4, (3, 3) => 5, (1, 3) => 2, (1, 4) => 3))), 3)), (1, 2)) julia> 2A -Dense [:,1:3] -├─ [:, 1]: Sparse (0.0) [1:4] -│ ├─ [2]: 2.2 -│ ├─ [3]: 4.4 -│ └─ [4]: 6.6 -├─ [:, 2]: Sparse (0.0) [1:4] -└─ [:, 3]: Sparse (0.0) [1:4] - ├─ [1]: 8.8 - └─ [3]: 11.0 - +SwizzleArray(Tensor(Dense{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([2.2, 4.4, 6.6, 8.8, 11.0]), 4, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (3, 1) => 4, (3, 3) => 5, (1, 3) => 2, (1, 4) => 3))), 3)), (1, 2)) julia> A * 3 -Dense [:,1:3] -├─ [:, 1]: Sparse (0.0) [1:4] -│ ├─ [2]: 3.3 -│ ├─ [3]: 6.6 -│ └─ [4]: 9.9 -├─ [:, 2]: Sparse (0.0) [1:4] -└─ [:, 3]: Sparse (0.0) [1:4] - ├─ [1]: 13.2 - └─ [3]: 16.5 - +SwizzleArray(Tensor(Dense{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([3.3000000000000003, 6.6000000000000005, 9.899999999999999, 13.200000000000001, 16.5]), 4, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (3, 1) => 4, (3, 3) => 5, (1, 3) => 2, (1, 4) => 3))), 3)), (1, 2)) julia> A / 3 -Dense [:,1:3] -├─ [:, 1]: Sparse (0.0) [1:4] -│ ├─ [2]: 0.366667 -│ ├─ [3]: 0.733333 -│ └─ [4]: 1.1 -├─ [:, 2]: Sparse (0.0) [1:4] -└─ [:, 3]: Sparse (0.0) [1:4] - ├─ [1]: 1.46667 - └─ [3]: 1.83333 - +SwizzleArray(Tensor(Dense{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([0.3666666666666667, 0.7333333333333334, 1.0999999999999999, 1.4666666666666668, 1.8333333333333333]), 4, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (3, 1) => 4, (3, 3) => 5, (1, 3) => 2, (1, 4) => 3))), 3)), (1, 2)) julia> 3 / A -Dense [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: Inf -│ ├─ [2]: 2.72727 -│ ├─ [3]: 1.36364 -│ └─ [4]: 0.909091 -├─ [:, 2]: Dense [1:4] -│ ├─ [1]: Inf -│ ├─ [2]: Inf -│ ├─ [3]: Inf -│ └─ [4]: Inf -└─ [:, 3]: Dense [1:4] - ├─ [1]: 0.681818 - ├─ [2]: Inf - ├─ [3]: 0.545455 - └─ [4]: Inf - +SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{Inf, Float64, Int64}([Inf, 2.727272727272727, 1.3636363636363635, 0.9090909090909092, Inf, Inf, Inf, Inf, 0.6818181818181818, Inf, 0.5454545454545454, Inf]), 4), 3)), (1, 2)) diff --git a/test/reference64/interface/broadcast.txt b/test/reference64/interface/broadcast.txt index b5816d94f..63730de63 100644 --- a/test/reference64/interface/broadcast.txt +++ b/test/reference64/interface/broadcast.txt @@ -19,7 +19,7 @@ julia> B = [1, 2, 3, 4] julia> C = A .+ B julia> AsArray(C) -4×3 Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}: +4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}: 1.0 1.0 5.4 3.1 2.0 2.0 5.2 3.0 8.5 @@ -27,31 +27,15 @@ julia> AsArray(C) julia> D = A .* B julia> AsArray(D) -4×3 Tensor{DenseLevel{Int64, SparseLevel{Int64, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}: +4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int64, SparseLevel{Int64, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}: 0.0 0.0 4.4 2.2 0.0 0.0 6.6 0.0 16.5 13.2 0.0 0.0 julia> E = ifelse.(A .== 0, 1, 2) -Dense [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: 1 -│ ├─ [2]: 2 -│ ├─ [3]: 2 -│ └─ [4]: 2 -├─ [:, 2]: Dense [1:4] -│ ├─ [1]: 1 -│ ├─ [2]: 1 -│ ├─ [3]: 1 -│ └─ [4]: 1 -└─ [:, 3]: Dense [1:4] - ├─ [1]: 2 - ├─ [2]: 1 - ├─ [3]: 2 - └─ [4]: 1 - +SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{1, Int64, Int64}([1, 2, 2, 2, 1, 1, 1, 1, 2, 1, 2, 1]), 4), 3)), (1, 2)) julia> AsArray(E) -4×3 Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{1, Int64, Int64, Vector{Int64}}}}}: +4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{1, Int64, Int64, Vector{Int64}}}}}}: 1 1 2 2 1 1 2 1 2 diff --git a/test/reference64/interface/reduce.txt b/test/reference64/interface/reduce.txt index a73a2e6a2..c26e5b1ae 100644 --- a/test/reference64/interface/reduce.txt +++ b/test/reference64/interface/reduce.txt @@ -11,34 +11,15 @@ Dense [:,1:3] └─ [3]: 5.5 julia> reduce(+, A, dims = (1,)) -Dense [1:3] -├─ [1]: 6.6 -├─ [2]: 0.0 -└─ [3]: 9.9 - +SwizzleArray(Tensor(Dense{Int64}(Element{0.0, Float64, Int64}([6.6, 0.0, 9.9]), 3)), (1,)) julia> reduce(+, A, dims = 1) -Dense [1:3] -├─ [1]: 6.6 -├─ [2]: 0.0 -└─ [3]: 9.9 - +SwizzleArray(Tensor(Dense{Int64}(Element{0.0, Float64, Int64}([6.6, 0.0, 9.9]), 3)), (1,)) julia> reduce(+, A, dims = (2,)) -Sparse (0.0) [1:4] -├─ [1]: 4.4 -├─ [2]: 1.1 -├─ [3]: 7.7 -└─ [4]: 3.3 - +SwizzleArray(Tensor(Sparse{Int64}(Element{0.0, Float64, Int64}([1.1, 7.7, 3.3, 4.4]), 4, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 5], [1, 2, 3, 4], [4, 1, 2, 3], Dict((1, 2) => 1, (1, 1) => 4, (1, 3) => 2, (1, 4) => 3)))), (1,)) julia> reduce(+, A, dims = 2) -Sparse (0.0) [1:4] -├─ [1]: 4.4 -├─ [2]: 1.1 -├─ [3]: 7.7 -└─ [4]: 3.3 - +SwizzleArray(Tensor(Sparse{Int64}(Element{0.0, Float64, Int64}([1.1, 7.7, 3.3, 4.4]), 4, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 5], [1, 2, 3, 4], [4, 1, 2, 3], Dict((1, 2) => 1, (1, 1) => 4, (1, 3) => 2, (1, 4) => 3)))), (1,)) julia> reduce(+, A, dims = (1, 2)) -16.5 - +SwizzleArray(Tensor(Element{0.0, Float64, Int64}([16.5])), ()) julia> reduce(+, A, dims = (:)) 16.5 diff --git a/test/test_interface.jl b/test/test_interface.jl index 82299e581..d4c4c5385 100644 --- a/test/test_interface.jl +++ b/test/test_interface.jl @@ -4,7 +4,7 @@ using Finch: AsArray @info "Testing Finch Interface" - for scheduler in [Finch.default_scheduler(), Finch.DefaultLogicOptimizer(Finch.LogicInterpreter())] + for scheduler in [Finch.default_scheduler(verbose=true), Finch.DefaultLogicOptimizer(Finch.LogicInterpreter())] Finch.with_scheduler(scheduler) do @info "Testing $scheduler" From 7588141f0d25f1cd57b69f2a517fb38bdd4f489f Mon Sep 17 00:00:00 2001 From: Willow Bot Date: Sat, 18 May 2024 00:14:42 +0000 Subject: [PATCH 07/22] Regenerate test output --- docs/src/guides/array_api.md | 76 +++------------------------------ docs/src/guides/sparse_utils.md | 34 +-------------- 2 files changed, 7 insertions(+), 103 deletions(-) diff --git a/docs/src/guides/array_api.md b/docs/src/guides/array_api.md index 4d5e0527b..6d3534a74 100644 --- a/docs/src/guides/array_api.md +++ b/docs/src/guides/array_api.md @@ -16,67 +16,13 @@ SparseCOO{2} (0.0) [:,1:6] └─ [2, 5]: 3.0 julia> A + 0 -Dense [:,1:6] -├─ [:, 1]: Dense [1:3] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ └─ [3]: 0.0 -├─ [:, 2]: Dense [1:3] -│ ├─ [1]: 1.0 -│ ├─ [2]: 0.0 -│ └─ [3]: 0.0 -├─ [:, 3]: Dense [1:3] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ └─ [3]: 0.0 -├─ [:, 4]: Dense [1:3] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ └─ [3]: 0.0 -├─ [:, 5]: Dense [1:3] -│ ├─ [1]: 0.0 -│ ├─ [2]: 3.0 -│ └─ [3]: 0.0 -└─ [:, 6]: Dense [1:3] - ├─ [1]: 0.0 - ├─ [2]: 0.0 - └─ [3]: 0.0 +SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{0.0, Float64, Int64}([0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0]), 3), 6)), (1, 2)) julia> A + 1 -Dense [:,1:6] -├─ [:, 1]: Dense [1:3] -│ ├─ [1]: 1.0 -│ ├─ [2]: 1.0 -│ └─ [3]: 1.0 -├─ [:, 2]: Dense [1:3] -│ ├─ [1]: 2.0 -│ ├─ [2]: 1.0 -│ └─ [3]: 1.0 -├─ [:, 3]: Dense [1:3] -│ ├─ [1]: 1.0 -│ ├─ [2]: 1.0 -│ └─ [3]: 1.0 -├─ [:, 4]: Dense [1:3] -│ ├─ [1]: 3.0 -│ ├─ [2]: 1.0 -│ └─ [3]: 1.0 -├─ [:, 5]: Dense [1:3] -│ ├─ [1]: 1.0 -│ ├─ [2]: 4.0 -│ └─ [3]: 1.0 -└─ [:, 6]: Dense [1:3] - ├─ [1]: 1.0 - ├─ [2]: 1.0 - └─ [3]: 1.0 +SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{1.0, Float64, Int64}([1.0, 1.0, 1.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 4.0, 1.0, 1.0, 1.0, 1.0]), 3), 6)), (1, 2)) julia> B = A .* 2 -Sparse (0.0) [:,1:6] -├─ [:, 2]: Sparse (0.0) [1:3] -│ └─ [1]: 2.0 -├─ [:, 4]: Sparse (0.0) [1:3] -│ └─ [1]: 4.0 -└─ [:, 5]: Sparse (0.0) [1:3] - └─ [2]: 6.0 +SwizzleArray(Tensor(Sparse{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([2.0, 4.0, 6.0]), 3, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 2, 3, 4], [1, 1, 2], [1, 2, 3], Dict((3, 2) => 3, (1, 1) => 1, (2, 1) => 2))), 6, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4], [2, 4, 5], [1, 2, 3], Dict((1, 2) => 1, (1, 4) => 2, (1, 5) => 3)))), (1, 2)) julia> B[1:2, 1:2] Sparse (0.0) [:,1:2] @@ -84,13 +30,7 @@ Sparse (0.0) [:,1:2] └─ [1]: 2.0 julia> map(x -> x^2, B) -Sparse (0.0) [:,1:6] -├─ [:, 2]: Sparse (0.0) [1:3] -│ └─ [1]: 4.0 -├─ [:, 4]: Sparse (0.0) [1:3] -│ └─ [1]: 16.0 -└─ [:, 5]: Sparse (0.0) [1:3] - └─ [2]: 36.0 +SwizzleArray(Tensor(Sparse{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([4.0, 16.0, 36.0]), 3, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 2, 3, 4], [1, 1, 2], [1, 2, 3], Dict((3, 2) => 3, (1, 1) => 1, (2, 1) => 2))), 6, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4], [2, 4, 5], [1, 2, 3], Dict((1, 2) => 1, (1, 4) => 2, (1, 5) => 3)))), (1, 2)) ``` # Array Fusion @@ -110,13 +50,7 @@ julia> D = lazy(B); julia> E = (C .+ D)/2; julia> compute(E) -Sparse (0.0) [:,1:6] -├─ [:, 2]: Sparse (0.0) [1:3] -│ └─ [1]: 1.5 -├─ [:, 4]: Sparse (0.0) [1:3] -│ └─ [1]: 3.0 -└─ [:, 5]: Sparse (0.0) [1:3] - └─ [2]: 4.5 +SwizzleArray(Tensor(Sparse{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([1.5, 3.0, 4.5]), 3, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 2, 3, 4], [1, 1, 2], [1, 2, 3], Dict((3, 2) => 3, (1, 1) => 1, (2, 1) => 2))), 6, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4], [2, 4, 5], [1, 2, 3], Dict((1, 2) => 1, (1, 4) => 2, (1, 5) => 3)))), (1, 2)) ``` diff --git a/docs/src/guides/sparse_utils.md b/docs/src/guides/sparse_utils.md index 07d174b5e..5020fc2b8 100644 --- a/docs/src/guides/sparse_utils.md +++ b/docs/src/guides/sparse_utils.md @@ -27,31 +27,7 @@ SparseCOO{2} (0.0) [:,1:6] └─ [2, 5]: 3.0 julia> min.(A, -1) -Dense [:,1:6] -├─ [:, 1]: Dense [1:3] -│ ├─ [1]: -1.0 -│ ├─ [2]: -1.0 -│ └─ [3]: -1.0 -├─ [:, 2]: Dense [1:3] -│ ├─ [1]: -1.0 -│ ├─ [2]: -1.0 -│ └─ [3]: -1.0 -├─ [:, 3]: Dense [1:3] -│ ├─ [1]: -1.0 -│ ├─ [2]: -1.0 -│ └─ [3]: -1.0 -├─ [:, 4]: Dense [1:3] -│ ├─ [1]: -1.0 -│ ├─ [2]: -1.0 -│ └─ [3]: -1.0 -├─ [:, 5]: Dense [1:3] -│ ├─ [1]: -1.0 -│ ├─ [2]: -1.0 -│ └─ [3]: -1.0 -└─ [:, 6]: Dense [1:3] - ├─ [1]: -1.0 - ├─ [2]: -1.0 - └─ [3]: -1.0 +SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{-1.0, Float64, Int64}([-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]), 3), 6)), (1, 2)) julia> fill_value(A) 0.0 @@ -63,13 +39,7 @@ SparseCOO{2} (-Inf) [:,1:6] └─ [2, 5]: 3.0 julia> min.(B, -1) -Sparse (-Inf) [:,1:6] -├─ [:, 2]: Sparse (-Inf) [1:3] -│ └─ [1]: -1.0 -├─ [:, 4]: Sparse (-Inf) [1:3] -│ └─ [1]: -1.0 -└─ [:, 5]: Sparse (-Inf) [1:3] - └─ [2]: -1.0 +SwizzleArray(Tensor(Sparse{Int64}(Sparse{Int64}(Element{-Inf, Float64, Int64}([-1.0, -1.0, -1.0]), 3, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 2, 3, 4], [1, 1, 2], [1, 2, 3], Dict((3, 2) => 3, (1, 1) => 1, (2, 1) => 2))), 6, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4], [2, 4, 5], [1, 2, 3], Dict((1, 2) => 1, (1, 4) => 2, (1, 5) => 3)))), (1, 2)) julia> countstored(A) 3 From 6c215f9a62878579ae582c4f2277e9822bca696c Mon Sep 17 00:00:00 2001 From: Willow Bot Date: Sat, 18 May 2024 00:25:46 +0000 Subject: [PATCH 08/22] Regenerate test output --- test/reference32/interface/asmd.txt | 98 ++---------------------- test/reference32/interface/broadcast.txt | 24 +----- test/reference32/interface/reduce.txt | 29 ++----- 3 files changed, 16 insertions(+), 135 deletions(-) diff --git a/test/reference32/interface/asmd.txt b/test/reference32/interface/asmd.txt index 1c0fdc50b..0d56d01af 100644 --- a/test/reference32/interface/asmd.txt +++ b/test/reference32/interface/asmd.txt @@ -11,101 +11,17 @@ Dense [:,1:3] └─ [3]: 5.5 julia> A + 1 -Dense [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.1 -│ ├─ [3]: 3.2 -│ └─ [4]: 4.3 -├─ [:, 2]: Dense [1:4] -│ ├─ [1]: 1.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 1.0 -└─ [:, 3]: Dense [1:4] - ├─ [1]: 5.4 - ├─ [2]: 1.0 - ├─ [3]: 6.5 - └─ [4]: 1.0 - +SwizzleArray(Tensor(Dense{Int32}(Dense{Int32}(Element{1.0, Float64, Int32}([1.0, 2.1, 3.2, 4.3, 1.0, 1.0, 1.0, 1.0, 5.4, 1.0, 6.5, 1.0]), 4), 3)), (1, 2)) julia> 1 + A -Dense [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.1 -│ ├─ [3]: 3.2 -│ └─ [4]: 4.3 -├─ [:, 2]: Dense [1:4] -│ ├─ [1]: 1.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 1.0 -└─ [:, 3]: Dense [1:4] - ├─ [1]: 5.4 - ├─ [2]: 1.0 - ├─ [3]: 6.5 - └─ [4]: 1.0 - +SwizzleArray(Tensor(Dense{Int32}(Dense{Int32}(Element{1.0, Float64, Int32}([1.0, 2.1, 3.2, 4.3, 1.0, 1.0, 1.0, 1.0, 5.4, 1.0, 6.5, 1.0]), 4), 3)), (1, 2)) julia> A + A -Dense [:,1:3] -├─ [:, 1]: Sparse (0.0) [1:4] -│ ├─ [2]: 2.2 -│ ├─ [3]: 4.4 -│ └─ [4]: 6.6 -├─ [:, 2]: Sparse (0.0) [1:4] -└─ [:, 3]: Sparse (0.0) [1:4] - ├─ [1]: 8.8 - └─ [3]: 11.0 - +SwizzleArray(Tensor(Dense{Int32}(Sparse{Int32}(Element{0.0, Float64, Int32}([2.2, 4.4, 6.6, 8.8, 11.0]), 4, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (1, 4) => 3, (1, 3) => 2, (3, 1) => 4, (3, 3) => 5))), 3)), (1, 2)) julia> 2A -Dense [:,1:3] -├─ [:, 1]: Sparse (0.0) [1:4] -│ ├─ [2]: 2.2 -│ ├─ [3]: 4.4 -│ └─ [4]: 6.6 -├─ [:, 2]: Sparse (0.0) [1:4] -└─ [:, 3]: Sparse (0.0) [1:4] - ├─ [1]: 8.8 - └─ [3]: 11.0 - +SwizzleArray(Tensor(Dense{Int32}(Sparse{Int32}(Element{0.0, Float64, Int32}([2.2, 4.4, 6.6, 8.8, 11.0]), 4, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (1, 4) => 3, (1, 3) => 2, (3, 1) => 4, (3, 3) => 5))), 3)), (1, 2)) julia> A * 3 -Dense [:,1:3] -├─ [:, 1]: Sparse (0.0) [1:4] -│ ├─ [2]: 3.3 -│ ├─ [3]: 6.6 -│ └─ [4]: 9.9 -├─ [:, 2]: Sparse (0.0) [1:4] -└─ [:, 3]: Sparse (0.0) [1:4] - ├─ [1]: 13.2 - └─ [3]: 16.5 - +SwizzleArray(Tensor(Dense{Int32}(Sparse{Int32}(Element{0.0, Float64, Int32}([3.3000000000000003, 6.6000000000000005, 9.899999999999999, 13.200000000000001, 16.5]), 4, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (1, 4) => 3, (1, 3) => 2, (3, 1) => 4, (3, 3) => 5))), 3)), (1, 2)) julia> A / 3 -Dense [:,1:3] -├─ [:, 1]: Sparse (0.0) [1:4] -│ ├─ [2]: 0.366667 -│ ├─ [3]: 0.733333 -│ └─ [4]: 1.1 -├─ [:, 2]: Sparse (0.0) [1:4] -└─ [:, 3]: Sparse (0.0) [1:4] - ├─ [1]: 1.46667 - └─ [3]: 1.83333 - +SwizzleArray(Tensor(Dense{Int32}(Sparse{Int32}(Element{0.0, Float64, Int32}([0.3666666666666667, 0.7333333333333334, 1.0999999999999999, 1.4666666666666668, 1.8333333333333333]), 4, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (1, 4) => 3, (1, 3) => 2, (3, 1) => 4, (3, 3) => 5))), 3)), (1, 2)) julia> 3 / A -Dense [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: Inf -│ ├─ [2]: 2.72727 -│ ├─ [3]: 1.36364 -│ └─ [4]: 0.909091 -├─ [:, 2]: Dense [1:4] -│ ├─ [1]: Inf -│ ├─ [2]: Inf -│ ├─ [3]: Inf -│ └─ [4]: Inf -└─ [:, 3]: Dense [1:4] - ├─ [1]: 0.681818 - ├─ [2]: Inf - ├─ [3]: 0.545455 - └─ [4]: Inf - +SwizzleArray(Tensor(Dense{Int32}(Dense{Int32}(Element{Inf, Float64, Int32}([Inf, 2.727272727272727, 1.3636363636363635, 0.9090909090909092, Inf, Inf, Inf, Inf, 0.6818181818181818, Inf, 0.5454545454545454, Inf]), 4), 3)), (1, 2)) diff --git a/test/reference32/interface/broadcast.txt b/test/reference32/interface/broadcast.txt index f068ee65e..c18dbdd12 100644 --- a/test/reference32/interface/broadcast.txt +++ b/test/reference32/interface/broadcast.txt @@ -19,7 +19,7 @@ julia> B = [1, 2, 3, 4] julia> C = A .+ B julia> AsArray(C) -4×3 Tensor{DenseLevel{Int32, DenseLevel{Int32, ElementLevel{0.0, Float64, Int32, Vector{Float64}}}}}: +4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int32, DenseLevel{Int32, ElementLevel{0.0, Float64, Int32, Vector{Float64}}}}}}: 1.0 1.0 5.4 3.1 2.0 2.0 5.2 3.0 8.5 @@ -27,31 +27,15 @@ julia> AsArray(C) julia> D = A .* B julia> AsArray(D) -4×3 Tensor{DenseLevel{Int32, SparseLevel{Int32, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}, ElementLevel{0.0, Float64, Int32, Vector{Float64}}}}}: +4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int32, SparseLevel{Int32, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}, ElementLevel{0.0, Float64, Int32, Vector{Float64}}}}}}: 0.0 0.0 4.4 2.2 0.0 0.0 6.6 0.0 16.5 13.2 0.0 0.0 julia> E = ifelse.(A .== 0, 1, 2) -Dense [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: 1 -│ ├─ [2]: 2 -│ ├─ [3]: 2 -│ └─ [4]: 2 -├─ [:, 2]: Dense [1:4] -│ ├─ [1]: 1 -│ ├─ [2]: 1 -│ ├─ [3]: 1 -│ └─ [4]: 1 -└─ [:, 3]: Dense [1:4] - ├─ [1]: 2 - ├─ [2]: 1 - ├─ [3]: 2 - └─ [4]: 1 - +SwizzleArray(Tensor(Dense{Int32}(Dense{Int32}(Element{1, Int32, Int32}([1, 2, 2, 2, 1, 1, 1, 1, 2, 1, 2, 1]), 4), 3)), (1, 2)) julia> AsArray(E) -4×3 Tensor{DenseLevel{Int32, DenseLevel{Int32, ElementLevel{1, Int32, Int32, Vector{Int32}}}}}: +4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int32, DenseLevel{Int32, ElementLevel{1, Int32, Int32, Vector{Int32}}}}}}: 1 1 2 2 1 1 2 1 2 diff --git a/test/reference32/interface/reduce.txt b/test/reference32/interface/reduce.txt index a73a2e6a2..f8e173df7 100644 --- a/test/reference32/interface/reduce.txt +++ b/test/reference32/interface/reduce.txt @@ -11,34 +11,15 @@ Dense [:,1:3] └─ [3]: 5.5 julia> reduce(+, A, dims = (1,)) -Dense [1:3] -├─ [1]: 6.6 -├─ [2]: 0.0 -└─ [3]: 9.9 - +SwizzleArray(Tensor(Dense{Int32}(Element{0.0, Float64, Int32}([6.6, 0.0, 9.9]), 3)), (1,)) julia> reduce(+, A, dims = 1) -Dense [1:3] -├─ [1]: 6.6 -├─ [2]: 0.0 -└─ [3]: 9.9 - +SwizzleArray(Tensor(Dense{Int32}(Element{0.0, Float64, Int32}([6.6, 0.0, 9.9]), 3)), (1,)) julia> reduce(+, A, dims = (2,)) -Sparse (0.0) [1:4] -├─ [1]: 4.4 -├─ [2]: 1.1 -├─ [3]: 7.7 -└─ [4]: 3.3 - +SwizzleArray(Tensor(Sparse{Int32}(Element{0.0, Float64, Int32}([1.1, 7.7, 3.3, 4.4]), 4, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}([1, 5], [1, 2, 3, 4], [4, 1, 2, 3], Dict((1, 2) => 1, (1, 4) => 3, (1, 3) => 2, (1, 1) => 4)))), (1,)) julia> reduce(+, A, dims = 2) -Sparse (0.0) [1:4] -├─ [1]: 4.4 -├─ [2]: 1.1 -├─ [3]: 7.7 -└─ [4]: 3.3 - +SwizzleArray(Tensor(Sparse{Int32}(Element{0.0, Float64, Int32}([1.1, 7.7, 3.3, 4.4]), 4, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}([1, 5], [1, 2, 3, 4], [4, 1, 2, 3], Dict((1, 2) => 1, (1, 4) => 3, (1, 3) => 2, (1, 1) => 4)))), (1,)) julia> reduce(+, A, dims = (1, 2)) -16.5 - +SwizzleArray(Tensor(Element{0.0, Float64, Int32}([16.5])), ()) julia> reduce(+, A, dims = (:)) 16.5 From fb6709ef9cd19b996185268bc4148f8c4219c86d Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Sat, 18 May 2024 10:21:14 -0400 Subject: [PATCH 09/22] prettier printing --- src/scheduler/optimize.jl | 6 +++++- src/tensors/combinators/offset.jl | 5 ----- src/tensors/fibers.jl | 29 +++++++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/scheduler/optimize.jl b/src/scheduler/optimize.jl index 58fb89752..660980881 100644 --- a/src/scheduler/optimize.jl +++ b/src/scheduler/optimize.jl @@ -184,7 +184,11 @@ function materialize_squeeze_expand_productions(root) tns_2 = alias(gensym(:A)) idxs_3 = withsubsequence(intersect(idxs_1, idxs_2), idxs_2) push!(preamble, query(tns_2, reorder(relabel(tns, idxs_1), idxs_3))) - reorder(relabel(tns_2, idxs_3), idxs_2) + if idxs_3 == idxs_2 + tns_2 + else + reorder(relabel(tns_2, idxs_3), idxs_2) + end else arg end diff --git a/src/tensors/combinators/offset.jl b/src/tensors/combinators/offset.jl index 41cddcb64..745bdeb5b 100644 --- a/src/tensors/combinators/offset.jl +++ b/src/tensors/combinators/offset.jl @@ -8,8 +8,6 @@ function Base.show(io::IO, mime::MIME"text/plain", ex::OffsetArray) print(io, "OffsetArray($(ex.body), $(ex.delta))") end -Base.getindex(arr::OffsetArray, i...) = arr.body[(i .+ arr.delta)...] - struct VirtualOffsetArray <: AbstractVirtualCombinator body delta @@ -20,9 +18,6 @@ is_atomic(ctx, lvl::VirtualOffsetArray) = is_atomic(ctx, lvl.body) is_concurrent(ctx, lvl::VirtualOffsetArray) = is_concurrent(ctx, lvl.body) Base.show(io::IO, ex::VirtualOffsetArray) = Base.show(io, MIME"text/plain"(), ex) -function Base.show(io::IO, mime::MIME"text/plain", ex::VirtualOffsetArray) - print(io, "VirtualOffsetArray($(ex.body), $(ex.delta))") -end Base.summary(io::IO, ex::VirtualOffsetArray) = print(io, "VOffset($(summary(ex.body)), $(ex.delta))") diff --git a/src/tensors/fibers.jl b/src/tensors/fibers.jl index 93bc5ae8d..38ea85e58 100644 --- a/src/tensors/fibers.jl +++ b/src/tensors/fibers.jl @@ -140,6 +140,30 @@ labelled_show(io, node) = show(io, node) AbstractTrees.children(node::LabelledTree) = labelled_children(node.node) labelled_children(node) = () +struct TruncatedTree + node + nmax + factor +end + +TruncatedTree(node; nmax = 4.0, factor=1.5) = TruncatedTree(node, nmax, factor) + +function Base.show(io::IO, node::TruncatedTree) + show(io, node.node) +end + + +struct EllipsisNode end +Base.show(io::IO, key::EllipsisNode) = print(io, "⋮") + +function AbstractTrees.children(node::TruncatedTree) + clds = collect(children(node.node)) + if length(clds) > node.nmax + clds = vcat(clds[1:ceil(Int, node.nmax/2), end], [EllipsisNode()], clds[end - floor(Int, node.nmax/2) + 1:end]) + end + clds = map(cld -> TruncatedTree(cld, nmax=node.nmax/node.factor, factor=node.factor), clds) +end + struct CartesianLabel idxs end @@ -268,9 +292,10 @@ function Base.show(io::IO, mime::MIME"text/plain", fbr::Tensor) if get(io, :compact, false) print(io, "Tensor($(summary(fbr.lvl)))") else - print_tree(io, LabelledTree(SubFiber(fbr.lvl, 1))) + print_tree(io, TruncatedTree(LabelledTree(SubFiber(fbr.lvl, 1)))) end end +print_tree function Base.show(io::IO, mime::MIME"text/plain", fbr::VirtualFiber) if get(io, :compact, false) @@ -288,7 +313,7 @@ function Base.show(io::IO, mime::MIME"text/plain", fbr::SubFiber) if get(io, :compact, false) print(io, "SubFiber($(summary(fbr.lvl)), $(fbr.pos))") else - print_tree(io, LabelledTree(fbr)) + print_tree(io, TruncatedTree(LabelledTree(fbr))) end end From aea136a5fb0519fb42c4d136fd1ef809385ec4f1 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Sat, 18 May 2024 11:10:56 -0400 Subject: [PATCH 10/22] cleanup printing more --- src/abstract_tensor.jl | 81 ++++++++++++++++++++- src/tensors/combinators/offset.jl | 12 +++- src/tensors/combinators/permissive.jl | 10 ++- src/tensors/combinators/product.jl | 13 +++- src/tensors/combinators/protocolized.jl | 11 +-- src/tensors/combinators/scale.jl | 11 +-- src/tensors/combinators/swizzle.jl | 13 ++-- src/tensors/combinators/toeplitz.jl | 13 +++- src/tensors/combinators/windowed.jl | 10 ++- src/tensors/fibers.jl | 96 +++---------------------- 10 files changed, 154 insertions(+), 116 deletions(-) diff --git a/src/abstract_tensor.jl b/src/abstract_tensor.jl index 5ebde6024..e87d1d6fe 100644 --- a/src/abstract_tensor.jl +++ b/src/abstract_tensor.jl @@ -111,4 +111,83 @@ If the virtual array is not on the given device, copy the array to that device. function may modify underlying data arrays, but cannot change the virtual itself. This function is used to move data to the device before a kernel is launched. """ -function virtual_moveto end \ No newline at end of file +function virtual_moveto end + +struct LabelledTree + key + node +end + +LabelledTree(node) = LabelledTree(nothing, node) + +function Base.show(io::IO, node::LabelledTree) + if node.key !== nothing + show(io, something(node.key)) + print(io, ": ") + end + labelled_show(io, node.node) +end +labelled_show(io, node) = show(io, node) + +AbstractTrees.children(node::LabelledTree) = labelled_children(node.node) +labelled_children(node) = () + +struct TruncatedTree + node + nmax +end + +TruncatedTree(node; nmax = 2) = TruncatedTree(node, nmax) + +function Base.show(io::IO, node::TruncatedTree) + show(io, node.node) +end + + +struct EllipsisNode end +Base.show(io::IO, key::EllipsisNode) = print(io, "⋮") + +function AbstractTrees.children(node::TruncatedTree) + clds = collect(children(node.node)) + if length(clds) > 2*node.nmax + clds = vcat(clds[1:node.nmax, end], [EllipsisNode()], clds[end - node.nmax + 1:end]) + end + clds = map(cld -> TruncatedTree(cld, nmax=node.nmax), clds) +end + +struct CartesianLabel + idxs +end + +cartesian_label(args...) = CartesianLabel(Any[args...]) + +function Base.show(io::IO, key::CartesianLabel) + print(io, "[") + join(io, key.idxs, ", ") + print(io, "]") +end + +struct RangeLabel + start + stop +end + +range_label(start = nothing, stop = nothing) = RangeLabel(start, stop) + +function Base.show(io::IO, key::RangeLabel) + if key.start !== nothing + print(io, something(key.start)) + end + print(io, ":") + if key.stop !== nothing + print(io, something(key.stop)) + end +end + +function Base.show(io::IO, mime::MIME"text/plain", tns::AbstractTensor) + if get(io, :compact, false) + summary(io, tns) + else + print_tree(io, TruncatedTree(LabelledTree(tns))) + end +end \ No newline at end of file diff --git a/src/tensors/combinators/offset.jl b/src/tensors/combinators/offset.jl index 745bdeb5b..d9ee5f891 100644 --- a/src/tensors/combinators/offset.jl +++ b/src/tensors/combinators/offset.jl @@ -3,9 +3,15 @@ struct OffsetArray{Delta<:Tuple, Body} <: AbstractCombinator delta::Delta end -Base.show(io::IO, ex::OffsetArray) = Base.show(io, MIME"text/plain"(), ex) -function Base.show(io::IO, mime::MIME"text/plain", ex::OffsetArray) - print(io, "OffsetArray($(ex.body), $(ex.delta))") +function Base.show(io::IO, ex::OffsetArray) + print(io, "OffsetArray($(ex.body), $(ex.delta)") +end + +labelled_show(io::IO, ::OffsetArray) = + print(io, "OffsetArray [$(join(map(d -> ":+$d", ex.delta), ", "))]") + +function labelled_children(ex::OffsetArray) + [LabelledTree(ex.body)] end struct VirtualOffsetArray <: AbstractVirtualCombinator diff --git a/src/tensors/combinators/permissive.jl b/src/tensors/combinators/permissive.jl index 671c18883..871cf8c29 100644 --- a/src/tensors/combinators/permissive.jl +++ b/src/tensors/combinators/permissive.jl @@ -5,12 +5,16 @@ end PermissiveArray(body, dims) = PermissiveArray{dims}(body) PermissiveArray{dims}(body::Body) where {dims, Body} = PermissiveArray{dims, Body}(body) -Base.show(io::IO, ex::PermissiveArray) = Base.show(io, MIME"text/plain"(), ex) -function Base.show(io::IO, mime::MIME"text/plain", ex::PermissiveArray{dims}) where {dims} +function Base.show(io::IO, ex::PermissiveArray{dims}) where {dims} print(io, "PermissiveArray($(ex.body), $dims)") end -#Base.getindex(arr::PermissiveArray, i...) = ... +labelled_show(io::IO, ::PermissiveArray{dims}) where {dims} = + print(io, "PermissiveArray [$(join(map(d -> d ? "~:" : ":", dims), ", "))]") + +function labelled_children(ex::PermissiveArray) + [LabelledTree(ex.body)] +end struct VirtualPermissiveArray <: AbstractVirtualCombinator body diff --git a/src/tensors/combinators/product.jl b/src/tensors/combinators/product.jl index 6bfbe28e3..80b601201 100644 --- a/src/tensors/combinators/product.jl +++ b/src/tensors/combinators/product.jl @@ -5,12 +5,19 @@ end ProductArray(body, dim) = ProductArray{dim}(body) ProductArray{dim}(body::Body) where {dim, Body} = ProductArray{dim, Body}(body) -Base.show(io::IO, ex::ProductArray) = Base.show(io, MIME"text/plain"(), ex) -function Base.show(io::IO, mime::MIME"text/plain", ex::ProductArray{dim}) where {dim} +function Base.show(io::IO, ex::ProductArray{dim}) where {dim} print(io, "ProductArray{$dim}($(ex.body))") end -#Base.getindex(arr::ProductArray, i...) = ... +function labelled_show(io::IO, tns::ProductArray{dim}) where {dim} + dims = [":" for _ in ndims(tns)] + dims[dim] = ": * :" + print(io, "ProductArray [$(join(dims, ", "))]") +end + +function labelled_children(ex::ProductArray) + [LabelledTree(ex.body)] +end struct VirtualProductArray <: AbstractVirtualCombinator body diff --git a/src/tensors/combinators/protocolized.jl b/src/tensors/combinators/protocolized.jl index b59862301..06c5b3217 100644 --- a/src/tensors/combinators/protocolized.jl +++ b/src/tensors/combinators/protocolized.jl @@ -3,12 +3,15 @@ struct ProtocolizedArray{Protos<:Tuple, Body} <: AbstractCombinator protos::Protos end -Base.show(io::IO, ex::ProtocolizedArray) = Base.show(io, MIME"text/plain"(), ex) -function Base.show(io::IO, mime::MIME"text/plain", ex::ProtocolizedArray) +Base.show(io::IO, ex::ProtocolizedArray) = print(io, "ProtocolizedArray($(ex.body), $(ex.protos))") -end -Base.getindex(arr::ProtocolizedArray, i...) = arr.body[i...] +labelled_show(io::IO, ::ProtocolizedArray) = + print(io, "ProtocolizedArray [$(join(map(p -> isnothing(p) ? ":" : "$p(:)", ex.protos), ", "))]") + +function labelled_children(ex::ProtocolizedArray) + [LabelledTree(ex.body)] +end struct VirtualProtocolizedArray <: AbstractVirtualCombinator body diff --git a/src/tensors/combinators/scale.jl b/src/tensors/combinators/scale.jl index 19602eb3a..5b34e72ee 100644 --- a/src/tensors/combinators/scale.jl +++ b/src/tensors/combinators/scale.jl @@ -3,12 +3,15 @@ struct ScaleArray{Scale<:Tuple, Body} <: AbstractCombinator scale::Scale end -Base.show(io::IO, ex::ScaleArray) = Base.show(io, MIME"text/plain"(), ex) -function Base.show(io::IO, mime::MIME"text/plain", ex::ScaleArray) +Base.show(io::IO, ex::ScaleArray) = print(io, "ScaleArray($(ex.body), $(ex.scale))") -end -Base.getindex(arr::ScaleArray, i...) = arr.body[(i .* arr.scale)...] +labelled_show(io::IO, ex::ScaleArray) = + print(io, "ScaleArray [$(join(map(s -> ":*$s", ex.scale), ", "))]") + +function labelled_children(ex::ScaleArray) + [LabelledTree(ex.body)] +end struct VirtualScaleArray <: AbstractVirtualCombinator body diff --git a/src/tensors/combinators/swizzle.jl b/src/tensors/combinators/swizzle.jl index 64ff1ba61..eb55090d0 100644 --- a/src/tensors/combinators/swizzle.jl +++ b/src/tensors/combinators/swizzle.jl @@ -17,19 +17,22 @@ countstored(arr::SwizzleArray) = countstored(arr.body) Base.size(arr::SwizzleArray{dims}) where {dims} = map(n->size(arr.body)[n], dims) -Base.show(io::IO, ex::SwizzleArray) = Base.show(io, MIME"text/plain"(), ex) -function Base.show(io::IO, mime::MIME"text/plain", ex::SwizzleArray{dims}) where {dims} +function Base.show(io::IO, ex::SwizzleArray{dims}) where {dims} print(io, "SwizzleArray($(ex.body), $(dims))") end +labelled_show(io::IO, ::SwizzleArray{dims}) where {dims} = + print(io, "SwizzleArray ($(join(ex.dims, ", ")))") + +function labelled_children(ex::SwizzleArray) + [LabelledTree(ex.body)] +end + struct VirtualSwizzleArray <: AbstractVirtualCombinator body dims end -#is_injective(ctx, lvl::VirtualSwizzleArray) = is_injective(ctx, lvl.body) -#is_atomic(ctx, lvl::VirtualSwizzleArray) = is_atomic(ctx, lvl.body) - Base.show(io::IO, ex::VirtualSwizzleArray) = Base.show(io, MIME"text/plain"(), ex) function Base.show(io::IO, mime::MIME"text/plain", ex::VirtualSwizzleArray) print(io, "VirtualSwizzleArray($(ex.body), $(ex.dims))") diff --git a/src/tensors/combinators/toeplitz.jl b/src/tensors/combinators/toeplitz.jl index 2bbbd3f13..9b6c9d020 100644 --- a/src/tensors/combinators/toeplitz.jl +++ b/src/tensors/combinators/toeplitz.jl @@ -5,12 +5,19 @@ end ToeplitzArray(body, dim) = ToeplitzArray{dim}(body) ToeplitzArray{dim}(body::Body) where {dim, Body} = ToeplitzArray{dim, Body}(body) -Base.show(io::IO, ex::ToeplitzArray) = Base.show(io, MIME"text/plain"(), ex) -function Base.show(io::IO, mime::MIME"text/plain", ex::ToeplitzArray{dim}) where {dim} +function Base.show(io::IO, ex::ToeplitzArray{dim}) where {dim} print(io, "ToeplitzArray{$dim}($(ex.body))") end -#Base.getindex(arr::ToeplitzArray, i...) = ... +function labelled_show(io::IO, tns::ToeplitzArray{dim}) where {dim} + dims = [":" for _ in ndims(tns)] + dims[dim] = ": + :" + print(io, "ToeplitzArray [$(join(dims, ", "))]") +end + +function labelled_children(ex::ToeplitzArray) + [LabelledTree(ex.body)] +end struct VirtualToeplitzArray <: AbstractVirtualCombinator body diff --git a/src/tensors/combinators/windowed.jl b/src/tensors/combinators/windowed.jl index eb034d317..c86160b37 100644 --- a/src/tensors/combinators/windowed.jl +++ b/src/tensors/combinators/windowed.jl @@ -3,12 +3,16 @@ struct WindowedArray{Dims<:Tuple, Body} <: AbstractCombinator dims::Dims end -Base.show(io::IO, ex::WindowedArray) = Base.show(io, MIME"text/plain"(), ex) -function Base.show(io::IO, mime::MIME"text/plain", ex::WindowedArray) +function Base.show(io::IO, ex::WindowedArray) print(io, "WindowedArray($(ex.body), $(ex.dims))") end -Base.getindex(arr::WindowedArray, i...) = arr.body[i...] +labelled_show(io::IO, ::WindowedArray) = + print(io, "WindowedArray [$(join(ex.dims, ", "))]") + +function labelled_children(ex::WindowedArray) + [LabelledTree(ex.body)] +end struct VirtualWindowedArray <: AbstractVirtualCombinator body diff --git a/src/tensors/fibers.jl b/src/tensors/fibers.jl index 38ea85e58..336cd56a4 100644 --- a/src/tensors/fibers.jl +++ b/src/tensors/fibers.jl @@ -121,78 +121,6 @@ virtual_fill_value(ctx, tns::AbstractVirtualFiber) = virtual_level_fill_value(tn postype(fbr::AbstractVirtualFiber) = postype(fbr.lvl) allocator(fbr::AbstractVirtualFiber) = allocator(fbr.lvl) -struct LabelledTree - key - node -end - -LabelledTree(node) = LabelledTree(nothing, node) - -function Base.show(io::IO, node::LabelledTree) - if node.key !== nothing - show(io, something(node.key)) - print(io, ": ") - end - labelled_show(io, node.node) -end -labelled_show(io, node) = show(io, node) - -AbstractTrees.children(node::LabelledTree) = labelled_children(node.node) -labelled_children(node) = () - -struct TruncatedTree - node - nmax - factor -end - -TruncatedTree(node; nmax = 4.0, factor=1.5) = TruncatedTree(node, nmax, factor) - -function Base.show(io::IO, node::TruncatedTree) - show(io, node.node) -end - - -struct EllipsisNode end -Base.show(io::IO, key::EllipsisNode) = print(io, "⋮") - -function AbstractTrees.children(node::TruncatedTree) - clds = collect(children(node.node)) - if length(clds) > node.nmax - clds = vcat(clds[1:ceil(Int, node.nmax/2), end], [EllipsisNode()], clds[end - floor(Int, node.nmax/2) + 1:end]) - end - clds = map(cld -> TruncatedTree(cld, nmax=node.nmax/node.factor, factor=node.factor), clds) -end - -struct CartesianLabel - idxs -end - -cartesian_label(args...) = CartesianLabel(Any[args...]) - -function Base.show(io::IO, key::CartesianLabel) - print(io, "[") - join(io, key.idxs, ", ") - print(io, "]") -end - -struct RangeLabel - start - stop -end - -range_label(start = nothing, stop = nothing) = RangeLabel(start, stop) - -function Base.show(io::IO, key::RangeLabel) - if key.start !== nothing - print(io, something(key.start)) - end - print(io, ":") - if key.stop !== nothing - print(io, something(key.stop)) - end -end - function declare!(ctx::AbstractCompiler, fbr::VirtualFiber, init) lvl = declare_level!(ctx, fbr.lvl, literal(1), init) push!(ctx.code.preamble, assemble_level!(ctx, lvl, literal(1), literal(1))) #TODO this feels unnecessary? @@ -288,14 +216,14 @@ function Base.show(io::IO, fbr::Tensor) print(io, "Tensor(", fbr.lvl, ")") end -function Base.show(io::IO, mime::MIME"text/plain", fbr::Tensor) - if get(io, :compact, false) - print(io, "Tensor($(summary(fbr.lvl)))") - else - print_tree(io, TruncatedTree(LabelledTree(SubFiber(fbr.lvl, 1)))) - end -end -print_tree +labelled_show(io::IO, fbr::Tensor) = + print(io, join(size(fbr), "×"), "-Tensor") + +labelled_children(fbr::Tensor) = + [LabelledTree(SubFiber(fbr.lvl, 1))] + +Base.summary(io::IO, fbr::Tensor) = + print(io, "Tensor($(summary(fbr.lvl)))") function Base.show(io::IO, mime::MIME"text/plain", fbr::VirtualFiber) if get(io, :compact, false) @@ -309,13 +237,7 @@ function Base.show(io::IO, fbr::SubFiber) print(io, "SubFiber(", fbr.lvl, ", ", fbr.pos, ")") end -function Base.show(io::IO, mime::MIME"text/plain", fbr::SubFiber) - if get(io, :compact, false) - print(io, "SubFiber($(summary(fbr.lvl)), $(fbr.pos))") - else - print_tree(io, TruncatedTree(LabelledTree(fbr))) - end -end +Base.summary(io::IO, fbr::SubFiber) = println(io, "SubFiber($(summary(fbr.lvl)), $(fbr.pos))") function Base.show(io::IO, mime::MIME"text/plain", fbr::VirtualSubFiber) if get(io, :compact, false) From 8ae086b5c405bbdb95604198ab94ca458ff8f8fc Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Sat, 18 May 2024 11:16:14 -0400 Subject: [PATCH 11/22] quick fix --- src/tensors/combinators/swizzle.jl | 2 +- test/reference64/print/display_byte_dense.txt | 88 ++++++------------- test/reference64/print/display_coo1_dense.txt | 88 ++++++------------- test/reference64/print/display_coo2.txt | 41 ++------- test/reference64/print/display_dense_byte.txt | 64 +++++--------- test/reference64/print/display_dense_coo1.txt | 64 +++++--------- test/reference64/print/display_dense_dict.txt | 64 +++++--------- .../reference64/print/display_dense_hash1.txt | 64 +++++--------- test/reference64/print/display_dense_list.txt | 64 +++++--------- test/reference64/print/display_dict_dense.txt | 88 ++++++------------- .../reference64/print/display_hash1_dense.txt | 88 ++++++------------- test/reference64/print/display_hash2.txt | 41 ++------- test/reference64/print/display_list_dense.txt | 88 ++++++------------- 13 files changed, 250 insertions(+), 594 deletions(-) diff --git a/src/tensors/combinators/swizzle.jl b/src/tensors/combinators/swizzle.jl index eb55090d0..b823e7e1d 100644 --- a/src/tensors/combinators/swizzle.jl +++ b/src/tensors/combinators/swizzle.jl @@ -22,7 +22,7 @@ function Base.show(io::IO, ex::SwizzleArray{dims}) where {dims} end labelled_show(io::IO, ::SwizzleArray{dims}) where {dims} = - print(io, "SwizzleArray ($(join(ex.dims, ", ")))") + print(io, "SwizzleArray ($(join(dims, ", ")))") function labelled_children(ex::SwizzleArray) [LabelledTree(ex.body)] diff --git a/test/reference64/print/display_byte_dense.txt b/test/reference64/print/display_byte_dense.txt index cc673fce5..a540477d9 100644 --- a/test/reference64/print/display_byte_dense.txt +++ b/test/reference64/print/display_byte_dense.txt @@ -1,62 +1,28 @@ -SparseByteMap (0.0) [:,1:10] -├─ [:, 1]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 2]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 3]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 5]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 6]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 8]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 9]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: Dense [1:5] - ├─ [1]: 2.0 - ├─ [2]: 0.0 - ├─ [3]: 1.0 - ├─ [4]: 2.0 - └─ [5]: 0.0 +5×10-Tensor +└─ SparseByteMap (0.0) [:,1:10] + ├─ [:, 1]: Dense [1:5] + │ ├─ [1]: 2.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [4]: 2.0 + │ └─ [5]: 0.0 + ├─ [:, 2]: Dense [1:5] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.0 + │ ├─ ⋮ + │ ├─ [4]: 0.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: Dense [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ ⋮ + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: Dense [1:5] + ├─ [1]: 2.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [4]: 2.0 + └─ [5]: 0.0 diff --git a/test/reference64/print/display_coo1_dense.txt b/test/reference64/print/display_coo1_dense.txt index 6f4bce856..1e2aad37f 100644 --- a/test/reference64/print/display_coo1_dense.txt +++ b/test/reference64/print/display_coo1_dense.txt @@ -1,62 +1,28 @@ -SparseCOO{1} (0.0) [:,1:10] -├─ [:, 1]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 2]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 3]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 5]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 6]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 8]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 9]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: Dense [1:5] - ├─ [1]: 2.0 - ├─ [2]: 0.0 - ├─ [3]: 1.0 - ├─ [4]: 2.0 - └─ [5]: 0.0 +5×10-Tensor +└─ SparseCOO{1} (0.0) [:,1:10] + ├─ [:, 1]: Dense [1:5] + │ ├─ [1]: 2.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [4]: 2.0 + │ └─ [5]: 0.0 + ├─ [:, 2]: Dense [1:5] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.0 + │ ├─ ⋮ + │ ├─ [4]: 0.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: Dense [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ ⋮ + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: Dense [1:5] + ├─ [1]: 2.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [4]: 2.0 + └─ [5]: 0.0 diff --git a/test/reference64/print/display_coo2.txt b/test/reference64/print/display_coo2.txt index bfa027acf..1fb9e8410 100644 --- a/test/reference64/print/display_coo2.txt +++ b/test/reference64/print/display_coo2.txt @@ -1,35 +1,8 @@ -SparseCOO{2} (0.0) [:,1:10] -├─ [1, 1]: 2.0 -├─ [3, 1]: 1.0 -├─ [4, 1]: 2.0 -├─ [2, 2]: 1.0 -├─ [3, 2]: 2.0 -├─ [5, 2]: 1.0 -├─ [1, 3]: 1.0 -├─ [2, 3]: 2.0 -├─ [4, 3]: 1.0 -├─ [5, 3]: 2.0 -├─ [1, 4]: 2.0 -├─ [3, 4]: 1.0 -├─ [4, 4]: 2.0 -├─ [2, 5]: 1.0 -├─ [3, 5]: 2.0 -├─ [5, 5]: 1.0 -├─ [1, 6]: 1.0 -├─ [2, 6]: 2.0 -├─ [4, 6]: 1.0 -├─ [5, 6]: 2.0 -├─ [1, 7]: 2.0 -├─ [3, 7]: 1.0 -├─ [4, 7]: 2.0 -├─ [2, 8]: 1.0 -├─ [3, 8]: 2.0 -├─ [5, 8]: 1.0 -├─ [1, 9]: 1.0 -├─ [2, 9]: 2.0 -├─ [4, 9]: 1.0 -├─ [5, 9]: 2.0 -├─ [1, 10]: 2.0 -├─ [3, 10]: 1.0 -└─ [4, 10]: 2.0 +5×10-Tensor +└─ SparseCOO{2} (0.0) [:,1:10] + ├─ [1, 1]: 2.0 + ├─ [3, 1]: 1.0 + ├─ ⋮ + ├─ [3, 10]: 1.0 + └─ [4, 10]: 2.0 diff --git a/test/reference64/print/display_dense_byte.txt b/test/reference64/print/display_dense_byte.txt index 3d5518eed..7952cffde 100644 --- a/test/reference64/print/display_dense_byte.txt +++ b/test/reference64/print/display_dense_byte.txt @@ -1,45 +1,21 @@ -Dense [:,1:10] -├─ [:, 1]: SparseByteMap (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 0.0 -│ └─ [4]: 1.0 -├─ [:, 2]: SparseByteMap (0.0) [1:5] -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ └─ [5]: 0.0 -├─ [:, 3]: SparseByteMap (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 4]: SparseByteMap (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [4]: 0.0 -├─ [:, 5]: SparseByteMap (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 2.0 -├─ [:, 6]: SparseByteMap (0.0) [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 7]: SparseByteMap (0.0) [1:5] -│ ├─ [1]: 0.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 8]: SparseByteMap (0.0) [1:5] -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ └─ [5]: 1.0 -├─ [:, 9]: SparseByteMap (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: SparseByteMap (0.0) [1:5] - ├─ [1]: 2.0 - ├─ [3]: 0.0 - └─ [4]: 1.0 +5×10-Tensor +└─ Dense [:,1:10] + ├─ [:, 1]: SparseByteMap (0.0) [1:5] + │ ├─ [1]: 2.0 + │ ├─ [3]: 0.0 + │ └─ [4]: 1.0 + ├─ [:, 2]: SparseByteMap (0.0) [1:5] + │ ├─ [2]: 2.0 + │ ├─ [3]: 0.0 + │ └─ [5]: 0.0 + ├─ ⋮ + ├─ [:, 9]: SparseByteMap (0.0) [1:5] + │ ├─ [1]: 2.0 + │ ├─ [2]: 0.0 + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: SparseByteMap (0.0) [1:5] + ├─ [1]: 2.0 + ├─ [3]: 0.0 + └─ [4]: 1.0 diff --git a/test/reference64/print/display_dense_coo1.txt b/test/reference64/print/display_dense_coo1.txt index 40796be13..c951f5c9a 100644 --- a/test/reference64/print/display_dense_coo1.txt +++ b/test/reference64/print/display_dense_coo1.txt @@ -1,45 +1,21 @@ -Dense [:,1:10] -├─ [:, 1]: SparseCOO{1} (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 2]: SparseCOO{1} (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 3]: SparseCOO{1} (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: SparseCOO{1} (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 5]: SparseCOO{1} (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 6]: SparseCOO{1} (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: SparseCOO{1} (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 8]: SparseCOO{1} (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 9]: SparseCOO{1} (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: SparseCOO{1} (0.0) [1:5] - ├─ [1]: 2.0 - ├─ [3]: 1.0 - └─ [4]: 2.0 +5×10-Tensor +└─ Dense [:,1:10] + ├─ [:, 1]: SparseCOO{1} (0.0) [1:5] + │ ├─ [1]: 2.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 2.0 + ├─ [:, 2]: SparseCOO{1} (0.0) [1:5] + │ ├─ [2]: 1.0 + │ ├─ [3]: 2.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: SparseCOO{1} (0.0) [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: SparseCOO{1} (0.0) [1:5] + ├─ [1]: 2.0 + ├─ [3]: 1.0 + └─ [4]: 2.0 diff --git a/test/reference64/print/display_dense_dict.txt b/test/reference64/print/display_dense_dict.txt index 64626f03f..63c92017f 100644 --- a/test/reference64/print/display_dense_dict.txt +++ b/test/reference64/print/display_dense_dict.txt @@ -1,45 +1,21 @@ -Dense [:,1:10] -├─ [:, 1]: Sparse (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 2]: Sparse (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 3]: Sparse (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: Sparse (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 5]: Sparse (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 6]: Sparse (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: Sparse (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 8]: Sparse (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 9]: Sparse (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: Sparse (0.0) [1:5] - ├─ [1]: 2.0 - ├─ [3]: 1.0 - └─ [4]: 2.0 +5×10-Tensor +└─ Dense [:,1:10] + ├─ [:, 1]: Sparse (0.0) [1:5] + │ ├─ [1]: 2.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 2.0 + ├─ [:, 2]: Sparse (0.0) [1:5] + │ ├─ [2]: 1.0 + │ ├─ [3]: 2.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: Sparse (0.0) [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: Sparse (0.0) [1:5] + ├─ [1]: 2.0 + ├─ [3]: 1.0 + └─ [4]: 2.0 diff --git a/test/reference64/print/display_dense_hash1.txt b/test/reference64/print/display_dense_hash1.txt index 05cc250ad..413dae3d0 100644 --- a/test/reference64/print/display_dense_hash1.txt +++ b/test/reference64/print/display_dense_hash1.txt @@ -1,45 +1,21 @@ -Dense [:,1:10] -├─ [:, 1]: SparseHash{1} (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 2]: SparseHash{1} (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 3]: SparseHash{1} (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: SparseHash{1} (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 5]: SparseHash{1} (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 6]: SparseHash{1} (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: SparseHash{1} (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 8]: SparseHash{1} (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 9]: SparseHash{1} (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: SparseHash{1} (0.0) [1:5] - ├─ [1]: 2.0 - ├─ [3]: 1.0 - └─ [4]: 2.0 +5×10-Tensor +└─ Dense [:,1:10] + ├─ [:, 1]: SparseHash{1} (0.0) [1:5] + │ ├─ [1]: 2.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 2.0 + ├─ [:, 2]: SparseHash{1} (0.0) [1:5] + │ ├─ [2]: 1.0 + │ ├─ [3]: 2.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: SparseHash{1} (0.0) [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: SparseHash{1} (0.0) [1:5] + ├─ [1]: 2.0 + ├─ [3]: 1.0 + └─ [4]: 2.0 diff --git a/test/reference64/print/display_dense_list.txt b/test/reference64/print/display_dense_list.txt index 6013902be..4054ba441 100644 --- a/test/reference64/print/display_dense_list.txt +++ b/test/reference64/print/display_dense_list.txt @@ -1,45 +1,21 @@ -Dense [:,1:10] -├─ [:, 1]: SparseList (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 2]: SparseList (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 3]: SparseList (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: SparseList (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 5]: SparseList (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 6]: SparseList (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: SparseList (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 8]: SparseList (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 9]: SparseList (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: SparseList (0.0) [1:5] - ├─ [1]: 2.0 - ├─ [3]: 1.0 - └─ [4]: 2.0 +5×10-Tensor +└─ Dense [:,1:10] + ├─ [:, 1]: SparseList (0.0) [1:5] + │ ├─ [1]: 2.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 2.0 + ├─ [:, 2]: SparseList (0.0) [1:5] + │ ├─ [2]: 1.0 + │ ├─ [3]: 2.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: SparseList (0.0) [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: SparseList (0.0) [1:5] + ├─ [1]: 2.0 + ├─ [3]: 1.0 + └─ [4]: 2.0 diff --git a/test/reference64/print/display_dict_dense.txt b/test/reference64/print/display_dict_dense.txt index 0d950d946..032edf52e 100644 --- a/test/reference64/print/display_dict_dense.txt +++ b/test/reference64/print/display_dict_dense.txt @@ -1,62 +1,28 @@ -Sparse (0.0) [:,1:10] -├─ [:, 1]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 2]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 3]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 5]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 6]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 8]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 9]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: Dense [1:5] - ├─ [1]: 2.0 - ├─ [2]: 0.0 - ├─ [3]: 1.0 - ├─ [4]: 2.0 - └─ [5]: 0.0 +5×10-Tensor +└─ Sparse (0.0) [:,1:10] + ├─ [:, 1]: Dense [1:5] + │ ├─ [1]: 2.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [4]: 2.0 + │ └─ [5]: 0.0 + ├─ [:, 2]: Dense [1:5] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.0 + │ ├─ ⋮ + │ ├─ [4]: 0.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: Dense [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ ⋮ + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: Dense [1:5] + ├─ [1]: 2.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [4]: 2.0 + └─ [5]: 0.0 diff --git a/test/reference64/print/display_hash1_dense.txt b/test/reference64/print/display_hash1_dense.txt index e5b778daa..31245d49f 100644 --- a/test/reference64/print/display_hash1_dense.txt +++ b/test/reference64/print/display_hash1_dense.txt @@ -1,62 +1,28 @@ -SparseHash{1} (0.0) [:,1:5] -├─ [:, 1]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 2]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 3]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 5]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 6]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 8]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 9]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: Dense [1:5] - ├─ [1]: 2.0 - ├─ [2]: 0.0 - ├─ [3]: 1.0 - ├─ [4]: 2.0 - └─ [5]: 0.0 +10×5-Tensor +└─ SparseHash{1} (0.0) [:,1:5] + ├─ [:, 1]: Dense [1:5] + │ ├─ [1]: 2.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [4]: 2.0 + │ └─ [5]: 0.0 + ├─ [:, 2]: Dense [1:5] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.0 + │ ├─ ⋮ + │ ├─ [4]: 0.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: Dense [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ ⋮ + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: Dense [1:5] + ├─ [1]: 2.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [4]: 2.0 + └─ [5]: 0.0 diff --git a/test/reference64/print/display_hash2.txt b/test/reference64/print/display_hash2.txt index 8b4724256..1d1048ed1 100644 --- a/test/reference64/print/display_hash2.txt +++ b/test/reference64/print/display_hash2.txt @@ -1,35 +1,8 @@ -SparseHash{2} (0.0) [:,1:10] -├─ [1, 1]: 2.0 -├─ [3, 1]: 1.0 -├─ [4, 1]: 2.0 -├─ [2, 2]: 1.0 -├─ [3, 2]: 2.0 -├─ [5, 2]: 1.0 -├─ [1, 3]: 1.0 -├─ [2, 3]: 2.0 -├─ [4, 3]: 1.0 -├─ [5, 3]: 2.0 -├─ [1, 4]: 2.0 -├─ [3, 4]: 1.0 -├─ [4, 4]: 2.0 -├─ [2, 5]: 1.0 -├─ [3, 5]: 2.0 -├─ [5, 5]: 1.0 -├─ [1, 6]: 1.0 -├─ [2, 6]: 2.0 -├─ [4, 6]: 1.0 -├─ [5, 6]: 2.0 -├─ [1, 7]: 2.0 -├─ [3, 7]: 1.0 -├─ [4, 7]: 2.0 -├─ [2, 8]: 1.0 -├─ [3, 8]: 2.0 -├─ [5, 8]: 1.0 -├─ [1, 9]: 1.0 -├─ [2, 9]: 2.0 -├─ [4, 9]: 1.0 -├─ [5, 9]: 2.0 -├─ [1, 10]: 2.0 -├─ [3, 10]: 1.0 -└─ [4, 10]: 2.0 +5×10-Tensor +└─ SparseHash{2} (0.0) [:,1:10] + ├─ [1, 1]: 2.0 + ├─ [3, 1]: 1.0 + ├─ ⋮ + ├─ [3, 10]: 1.0 + └─ [4, 10]: 2.0 diff --git a/test/reference64/print/display_list_dense.txt b/test/reference64/print/display_list_dense.txt index 6ad012e34..54c273e6a 100644 --- a/test/reference64/print/display_list_dense.txt +++ b/test/reference64/print/display_list_dense.txt @@ -1,62 +1,28 @@ -SparseList (0.0) [:,1:10] -├─ [:, 1]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 2]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 3]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 5]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 6]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 8]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 9]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: Dense [1:5] - ├─ [1]: 2.0 - ├─ [2]: 0.0 - ├─ [3]: 1.0 - ├─ [4]: 2.0 - └─ [5]: 0.0 +5×10-Tensor +└─ SparseList (0.0) [:,1:10] + ├─ [:, 1]: Dense [1:5] + │ ├─ [1]: 2.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [4]: 2.0 + │ └─ [5]: 0.0 + ├─ [:, 2]: Dense [1:5] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.0 + │ ├─ ⋮ + │ ├─ [4]: 0.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: Dense [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ ⋮ + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: Dense [1:5] + ├─ [1]: 2.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [4]: 2.0 + └─ [5]: 0.0 From f35e04f6c1f937d7057135dce984749ea0a3bfe4 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Sat, 18 May 2024 11:20:18 -0400 Subject: [PATCH 12/22] fix --- src/tensors/combinators/protocolized.jl | 2 +- src/tensors/combinators/windowed.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tensors/combinators/protocolized.jl b/src/tensors/combinators/protocolized.jl index 06c5b3217..679537d81 100644 --- a/src/tensors/combinators/protocolized.jl +++ b/src/tensors/combinators/protocolized.jl @@ -6,7 +6,7 @@ end Base.show(io::IO, ex::ProtocolizedArray) = print(io, "ProtocolizedArray($(ex.body), $(ex.protos))") -labelled_show(io::IO, ::ProtocolizedArray) = +labelled_show(io::IO, ex::ProtocolizedArray) = print(io, "ProtocolizedArray [$(join(map(p -> isnothing(p) ? ":" : "$p(:)", ex.protos), ", "))]") function labelled_children(ex::ProtocolizedArray) diff --git a/src/tensors/combinators/windowed.jl b/src/tensors/combinators/windowed.jl index c86160b37..51e98888f 100644 --- a/src/tensors/combinators/windowed.jl +++ b/src/tensors/combinators/windowed.jl @@ -7,7 +7,7 @@ function Base.show(io::IO, ex::WindowedArray) print(io, "WindowedArray($(ex.body), $(ex.dims))") end -labelled_show(io::IO, ::WindowedArray) = +labelled_show(io::IO, ex::WindowedArray) = print(io, "WindowedArray [$(join(ex.dims, ", "))]") function labelled_children(ex::WindowedArray) From 97a3d525d05831fcc2b538d520121f0f5cf174f0 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Sat, 18 May 2024 11:23:38 -0400 Subject: [PATCH 13/22] more diff --- test/reference64/index/chunkmask.txt | 135 +++-------- test/reference64/interface/asmd.txt | 131 ++++++++-- test/reference64/interface/broadcast.txt | 39 ++- test/reference64/interface/countstored.txt | 88 +++---- test/reference64/interface/getindex.txt | 229 +++++++++--------- test/reference64/interface/reduce.txt | 58 +++-- test/reference64/interface/setindex.txt | 160 +++--------- .../typical/typical_inplace_sparse_add.txt | 31 ++- test/reference64/typical/typical_spmv_csc.txt | 39 +-- .../typical/typical_stats_example.txt | 13 +- .../typical/typical_transpose_csc_to_coo.txt | 22 +- 11 files changed, 474 insertions(+), 471 deletions(-) diff --git a/test/reference64/index/chunkmask.txt b/test/reference64/index/chunkmask.txt index 019b6a4f4..546e6a216 100644 --- a/test/reference64/index/chunkmask.txt +++ b/test/reference64/index/chunkmask.txt @@ -1,54 +1,25 @@ chunkmask tests julia> A = Tensor(Dense(Dense(Element(0.0))), 15, 3) -Dense [:,1:3] -├─ [:, 1]: Dense [1:15] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ ├─ [10]: 0.0 -│ ├─ [11]: 0.0 -│ ├─ [12]: 0.0 -│ ├─ [13]: 0.0 -│ ├─ [14]: 0.0 -│ └─ [15]: 0.0 -├─ [:, 2]: Dense [1:15] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ ├─ [10]: 0.0 -│ ├─ [11]: 0.0 -│ ├─ [12]: 0.0 -│ ├─ [13]: 0.0 -│ ├─ [14]: 0.0 -│ └─ [15]: 0.0 -└─ [:, 3]: Dense [1:15] - ├─ [1]: 0.0 - ├─ [2]: 0.0 - ├─ [3]: 0.0 - ├─ [4]: 0.0 - ├─ [5]: 0.0 - ├─ [6]: 0.0 - ├─ [7]: 0.0 - ├─ [8]: 0.0 - ├─ [9]: 0.0 - ├─ [10]: 0.0 - ├─ [11]: 0.0 - ├─ [12]: 0.0 - ├─ [13]: 0.0 - ├─ [14]: 0.0 - └─ [15]: 0.0 +15×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:15] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [14]: 0.0 + │ └─ [15]: 0.0 + ├─ [:, 2]: Dense [1:15] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [14]: 0.0 + │ └─ [15]: 0.0 + └─ [:, 3]: Dense [1:15] + ├─ [1]: 0.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [14]: 0.0 + └─ [15]: 0.0 julia> @finch begin let m = Finch.chunkmask(5, 1:15) @@ -78,52 +49,26 @@ julia> AsArray(A) 0.0 0.0 1.0 0.0 0.0 1.0 julia> A = Tensor(Dense(Dense(Element(0.0))), 14, 3) -Dense [:,1:3] -├─ [:, 1]: Dense [1:14] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ ├─ [10]: 0.0 -│ ├─ [11]: 0.0 -│ ├─ [12]: 0.0 -│ ├─ [13]: 0.0 -│ └─ [14]: 0.0 -├─ [:, 2]: Dense [1:14] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ ├─ [10]: 0.0 -│ ├─ [11]: 0.0 -│ ├─ [12]: 0.0 -│ ├─ [13]: 0.0 -│ └─ [14]: 0.0 -└─ [:, 3]: Dense [1:14] - ├─ [1]: 0.0 - ├─ [2]: 0.0 - ├─ [3]: 0.0 - ├─ [4]: 0.0 - ├─ [5]: 0.0 - ├─ [6]: 0.0 - ├─ [7]: 0.0 - ├─ [8]: 0.0 - ├─ [9]: 0.0 - ├─ [10]: 0.0 - ├─ [11]: 0.0 - ├─ [12]: 0.0 - ├─ [13]: 0.0 - └─ [14]: 0.0 +14×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:14] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [13]: 0.0 + │ └─ [14]: 0.0 + ├─ [:, 2]: Dense [1:14] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [13]: 0.0 + │ └─ [14]: 0.0 + └─ [:, 3]: Dense [1:14] + ├─ [1]: 0.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [13]: 0.0 + └─ [14]: 0.0 julia> @finch begin let m = Finch.chunkmask(5, 1:14) diff --git a/test/reference64/interface/asmd.txt b/test/reference64/interface/asmd.txt index 1d81455b3..857c9d492 100644 --- a/test/reference64/interface/asmd.txt +++ b/test/reference64/interface/asmd.txt @@ -1,27 +1,126 @@ +,-, *, / tests julia> A = Tensor(Dense(SparseList(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 4.4 - └─ [3]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 4.4 + └─ [3]: 5.5 julia> A + 1 -SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{1.0, Float64, Int64}([1.0, 2.1, 3.2, 4.3, 1.0, 1.0, 1.0, 1.0, 5.4, 1.0, 6.5, 1.0]), 4), 3)), (1, 2)) +SwizzleArray (1, 2) +└─ 4×3-Tensor + └─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.1 + │ ├─ [3]: 3.2 + │ └─ [4]: 4.3 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: 1.0 + │ ├─ [2]: 1.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 1.0 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 5.4 + ├─ [2]: 1.0 + ├─ [3]: 6.5 + └─ [4]: 1.0 + julia> 1 + A -SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{1.0, Float64, Int64}([1.0, 2.1, 3.2, 4.3, 1.0, 1.0, 1.0, 1.0, 5.4, 1.0, 6.5, 1.0]), 4), 3)), (1, 2)) +SwizzleArray (1, 2) +└─ 4×3-Tensor + └─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.1 + │ ├─ [3]: 3.2 + │ └─ [4]: 4.3 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: 1.0 + │ ├─ [2]: 1.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 1.0 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 5.4 + ├─ [2]: 1.0 + ├─ [3]: 6.5 + └─ [4]: 1.0 + julia> A + A -SwizzleArray(Tensor(Dense{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([2.2, 4.4, 6.6, 8.8, 11.0]), 4, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (3, 1) => 4, (3, 3) => 5, (1, 3) => 2, (1, 4) => 3))), 3)), (1, 2)) +SwizzleArray (1, 2) +└─ 4×3-Tensor + └─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:4] + │ ├─ [2]: 2.2 + │ ├─ [3]: 4.4 + │ └─ [4]: 6.6 + ├─ [:, 2]: Sparse (0.0) [1:4] + └─ [:, 3]: Sparse (0.0) [1:4] + ├─ [1]: 8.8 + └─ [3]: 11.0 + julia> 2A -SwizzleArray(Tensor(Dense{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([2.2, 4.4, 6.6, 8.8, 11.0]), 4, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (3, 1) => 4, (3, 3) => 5, (1, 3) => 2, (1, 4) => 3))), 3)), (1, 2)) +SwizzleArray (1, 2) +└─ 4×3-Tensor + └─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:4] + │ ├─ [2]: 2.2 + │ ├─ [3]: 4.4 + │ └─ [4]: 6.6 + ├─ [:, 2]: Sparse (0.0) [1:4] + └─ [:, 3]: Sparse (0.0) [1:4] + ├─ [1]: 8.8 + └─ [3]: 11.0 + julia> A * 3 -SwizzleArray(Tensor(Dense{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([3.3000000000000003, 6.6000000000000005, 9.899999999999999, 13.200000000000001, 16.5]), 4, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (3, 1) => 4, (3, 3) => 5, (1, 3) => 2, (1, 4) => 3))), 3)), (1, 2)) +SwizzleArray (1, 2) +└─ 4×3-Tensor + └─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:4] + │ ├─ [2]: 3.3 + │ ├─ [3]: 6.6 + │ └─ [4]: 9.9 + ├─ [:, 2]: Sparse (0.0) [1:4] + └─ [:, 3]: Sparse (0.0) [1:4] + ├─ [1]: 13.2 + └─ [3]: 16.5 + julia> A / 3 -SwizzleArray(Tensor(Dense{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([0.3666666666666667, 0.7333333333333334, 1.0999999999999999, 1.4666666666666668, 1.8333333333333333]), 4, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (3, 1) => 4, (3, 3) => 5, (1, 3) => 2, (1, 4) => 3))), 3)), (1, 2)) +SwizzleArray (1, 2) +└─ 4×3-Tensor + └─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:4] + │ ├─ [2]: 0.366667 + │ ├─ [3]: 0.733333 + │ └─ [4]: 1.1 + ├─ [:, 2]: Sparse (0.0) [1:4] + └─ [:, 3]: Sparse (0.0) [1:4] + ├─ [1]: 1.46667 + └─ [3]: 1.83333 + julia> 3 / A -SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{Inf, Float64, Int64}([Inf, 2.727272727272727, 1.3636363636363635, 0.9090909090909092, Inf, Inf, Inf, Inf, 0.6818181818181818, Inf, 0.5454545454545454, Inf]), 4), 3)), (1, 2)) +SwizzleArray (1, 2) +└─ 4×3-Tensor + └─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: Inf + │ ├─ [2]: 2.72727 + │ ├─ [3]: 1.36364 + │ └─ [4]: 0.909091 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: Inf + │ ├─ [2]: Inf + │ ├─ [3]: Inf + │ └─ [4]: Inf + └─ [:, 3]: Dense [1:4] + ├─ [1]: 0.681818 + ├─ [2]: Inf + ├─ [3]: 0.545455 + └─ [4]: Inf + diff --git a/test/reference64/interface/broadcast.txt b/test/reference64/interface/broadcast.txt index 63730de63..cfc41868e 100644 --- a/test/reference64/interface/broadcast.txt +++ b/test/reference64/interface/broadcast.txt @@ -1,14 +1,15 @@ broadcast tests julia> A = Tensor(Dense(SparseList(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 4.4 - └─ [3]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 4.4 + └─ [3]: 5.5 julia> B = [1, 2, 3, 4] 4-element Vector{Int64}: @@ -33,7 +34,25 @@ julia> AsArray(D) 6.6 0.0 16.5 13.2 0.0 0.0 julia> E = ifelse.(A .== 0, 1, 2) -SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{1, Int64, Int64}([1, 2, 2, 2, 1, 1, 1, 1, 2, 1, 2, 1]), 4), 3)), (1, 2)) +SwizzleArray (1, 2) +└─ 4×3-Tensor + └─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 1 + │ ├─ [2]: 2 + │ ├─ [3]: 2 + │ └─ [4]: 2 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: 1 + │ ├─ [2]: 1 + │ ├─ [3]: 1 + │ └─ [4]: 1 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 2 + ├─ [2]: 1 + ├─ [3]: 2 + └─ [4]: 1 + julia> AsArray(E) 4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{1, Int64, Int64, Vector{Int64}}}}}}: 1 1 2 diff --git a/test/reference64/interface/countstored.txt b/test/reference64/interface/countstored.txt index 803c74ef3..d8e284c8c 100644 --- a/test/reference64/interface/countstored.txt +++ b/test/reference64/interface/countstored.txt @@ -1,59 +1,63 @@ countstored tests julia> A = Tensor(Dense(SparseList(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 4.4 - └─ [3]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 4.4 + └─ [3]: 5.5 julia> countstored(A) 5 julia> A = Tensor(SparseCOO{2}(Element(0.0)), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -SparseCOO{2} (0.0) [:,1:3] -├─ [2, 1]: 1.1 -├─ [3, 1]: 2.2 -├─ [4, 1]: 3.3 -├─ [1, 3]: 4.4 -└─ [3, 3]: 5.5 +4×3-Tensor +└─ SparseCOO{2} (0.0) [:,1:3] + ├─ [2, 1]: 1.1 + ├─ [3, 1]: 2.2 + ├─ ⋮ + ├─ [1, 3]: 4.4 + └─ [3, 3]: 5.5 julia> countstored(A) 5 julia> A = Tensor(Dense(Dense(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -Dense [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: Dense [1:4] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ └─ [4]: 0.0 -└─ [:, 3]: Dense [1:4] - ├─ [1]: 4.4 - ├─ [2]: 0.0 - ├─ [3]: 5.5 - └─ [4]: 0.0 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ [3]: 0.0 + │ └─ [4]: 0.0 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 4.4 + ├─ [2]: 0.0 + ├─ [3]: 5.5 + └─ [4]: 0.0 julia> countstored(A) 12 julia> A = Tensor(SparseList(Dense(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -SparseList (0.0) [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -└─ [:, 3]: Dense [1:4] - ├─ [1]: 4.4 - ├─ [2]: 0.0 - ├─ [3]: 5.5 - └─ [4]: 0.0 +4×3-Tensor +└─ SparseList (0.0) [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 4.4 + ├─ [2]: 0.0 + ├─ [3]: 5.5 + └─ [4]: 0.0 julia> countstored(A) 8 diff --git a/test/reference64/interface/getindex.txt b/test/reference64/interface/getindex.txt index 00333c762..14bcc8a11 100644 --- a/test/reference64/interface/getindex.txt +++ b/test/reference64/interface/getindex.txt @@ -1,123 +1,128 @@ getindex tests -A = SparseList (0.0) [:,:,1:4] -├─ [:, :, 1]: Dense [:,1:3] -│ ├─ [:, 1]: SparseList (0.0) [1:5] -│ │ ├─ [2]: 1.01 -│ │ └─ [3]: 2.02 -│ ├─ [:, 2]: SparseList (0.0) [1:5] -│ │ ├─ [3]: 3.03 -│ │ ├─ [4]: 4.04 -│ │ └─ [5]: 5.05 -│ └─ [:, 3]: SparseList (0.0) [1:5] -│ ├─ [2]: 6.06 -│ └─ [3]: 7.07 -├─ [:, :, 2]: Dense [:,1:3] -│ ├─ [:, 1]: SparseList (0.0) [1:5] -│ │ ├─ [1]: 8.08 -│ │ ├─ [3]: 9.09 -│ │ ├─ [4]: 10.1 -│ │ └─ [5]: 11.11 -│ ├─ [:, 2]: SparseList (0.0) [1:5] -│ │ ├─ [2]: 12.12 -│ │ └─ [4]: 13.13 -│ └─ [:, 3]: SparseList (0.0) [1:5] -│ ├─ [2]: 14.14 -│ ├─ [4]: 15.15 -│ └─ [5]: 16.16 -├─ [:, :, 3]: Dense [:,1:3] -│ ├─ [:, 1]: SparseList (0.0) [1:5] -│ │ ├─ [2]: 17.17 -│ │ ├─ [3]: 18.18 -│ │ └─ [5]: 19.19 -│ ├─ [:, 2]: SparseList (0.0) [1:5] -│ │ ├─ [1]: 20.2 -│ │ ├─ [3]: 21.21 -│ │ ├─ [4]: 22.22 -│ │ └─ [5]: 23.23 -│ └─ [:, 3]: SparseList (0.0) [1:5] -│ ├─ [2]: 24.24 -│ ├─ [3]: 25.25 -│ └─ [4]: 26.26 -└─ [:, :, 4]: Dense [:,1:3] - ├─ [:, 1]: SparseList (0.0) [1:5] - ├─ [:, 2]: SparseList (0.0) [1:5] - │ └─ [2]: 27.27 - └─ [:, 3]: SparseList (0.0) [1:5] - ├─ [1]: 28.28 - ├─ [2]: 29.29 - └─ [3]: 30.3 +A = 5×3×4-Tensor +└─ SparseList (0.0) [:,:,1:4] + ├─ [:, :, 1]: Dense [:,1:3] + │ ├─ [:, 1]: SparseList (0.0) [1:5] + │ │ ├─ [2]: 1.01 + │ │ └─ [3]: 2.02 + │ ├─ [:, 2]: SparseList (0.0) [1:5] + │ │ ├─ [3]: 3.03 + │ │ ├─ [4]: 4.04 + │ │ └─ [5]: 5.05 + │ └─ [:, 3]: SparseList (0.0) [1:5] + │ ├─ [2]: 6.06 + │ └─ [3]: 7.07 + ├─ [:, :, 2]: Dense [:,1:3] + │ ├─ [:, 1]: SparseList (0.0) [1:5] + │ │ ├─ [1]: 8.08 + │ │ ├─ [3]: 9.09 + │ │ ├─ [4]: 10.1 + │ │ └─ [5]: 11.11 + │ ├─ [:, 2]: SparseList (0.0) [1:5] + │ │ ├─ [2]: 12.12 + │ │ └─ [4]: 13.13 + │ └─ [:, 3]: SparseList (0.0) [1:5] + │ ├─ [2]: 14.14 + │ ├─ [4]: 15.15 + │ └─ [5]: 16.16 + ├─ [:, :, 3]: Dense [:,1:3] + │ ├─ [:, 1]: SparseList (0.0) [1:5] + │ │ ├─ [2]: 17.17 + │ │ ├─ [3]: 18.18 + │ │ └─ [5]: 19.19 + │ ├─ [:, 2]: SparseList (0.0) [1:5] + │ │ ├─ [1]: 20.2 + │ │ ├─ [3]: 21.21 + │ │ ├─ [4]: 22.22 + │ │ └─ [5]: 23.23 + │ └─ [:, 3]: SparseList (0.0) [1:5] + │ ├─ [2]: 24.24 + │ ├─ [3]: 25.25 + │ └─ [4]: 26.26 + └─ [:, :, 4]: Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:5] + ├─ [:, 2]: SparseList (0.0) [1:5] + │ └─ [2]: 27.27 + └─ [:, 3]: SparseList (0.0) [1:5] + ├─ [1]: 28.28 + ├─ [2]: 29.29 + └─ [3]: 30.3 A[1,2,3] = 20.2 A[1,1,1] = 0.0 -A[1,Colon(),3] = Sparse (0.0) [1:3] -└─ [2]: 20.2 +A[1,Colon(),3] = 3-Tensor +└─ Sparse (0.0) [1:3] + └─ [2]: 20.2 -A[Colon(),1,3] = Sparse (0.0) [1:5] -├─ [2]: 17.17 -├─ [3]: 18.18 -└─ [5]: 19.19 +A[Colon(),1,3] = 5-Tensor +└─ Sparse (0.0) [1:5] + ├─ [2]: 17.17 + ├─ [3]: 18.18 + └─ [5]: 19.19 -A[Colon(),Colon(),3] = Sparse (0.0) [:,1:3] -├─ [:, 1]: Sparse (0.0) [1:5] -│ ├─ [2]: 17.17 -│ ├─ [3]: 18.18 -│ └─ [5]: 19.19 -├─ [:, 2]: Sparse (0.0) [1:5] -│ ├─ [1]: 20.2 -│ ├─ [3]: 21.21 -│ ├─ [4]: 22.22 -│ └─ [5]: 23.23 -└─ [:, 3]: Sparse (0.0) [1:5] - ├─ [2]: 24.24 - ├─ [3]: 25.25 - └─ [4]: 26.26 - -A[Colon(),Colon(),Colon()] = Sparse (0.0) [:,:,1:4] -├─ [:, :, 1]: Dense [:,1:3] -│ ├─ [:, 1]: Sparse (0.0) [1:5] -│ │ ├─ [2]: 1.01 -│ │ └─ [3]: 2.02 -│ ├─ [:, 2]: Sparse (0.0) [1:5] -│ │ ├─ [3]: 3.03 -│ │ ├─ [4]: 4.04 -│ │ └─ [5]: 5.05 -│ └─ [:, 3]: Sparse (0.0) [1:5] -│ ├─ [2]: 6.06 -│ └─ [3]: 7.07 -├─ [:, :, 2]: Dense [:,1:3] -│ ├─ [:, 1]: Sparse (0.0) [1:5] -│ │ ├─ [1]: 8.08 -│ │ ├─ [3]: 9.09 -│ │ ├─ [4]: 10.1 -│ │ └─ [5]: 11.11 -│ ├─ [:, 2]: Sparse (0.0) [1:5] -│ │ ├─ [2]: 12.12 -│ │ └─ [4]: 13.13 -│ └─ [:, 3]: Sparse (0.0) [1:5] -│ ├─ [2]: 14.14 -│ ├─ [4]: 15.15 -│ └─ [5]: 16.16 -├─ [:, :, 3]: Dense [:,1:3] -│ ├─ [:, 1]: Sparse (0.0) [1:5] -│ │ ├─ [2]: 17.17 -│ │ ├─ [3]: 18.18 -│ │ └─ [5]: 19.19 -│ ├─ [:, 2]: Sparse (0.0) [1:5] -│ │ ├─ [1]: 20.2 -│ │ ├─ [3]: 21.21 -│ │ ├─ [4]: 22.22 -│ │ └─ [5]: 23.23 -│ └─ [:, 3]: Sparse (0.0) [1:5] -│ ├─ [2]: 24.24 -│ ├─ [3]: 25.25 -│ └─ [4]: 26.26 -└─ [:, :, 4]: Dense [:,1:3] +A[Colon(),Colon(),3] = 5×3-Tensor +└─ Sparse (0.0) [:,1:3] ├─ [:, 1]: Sparse (0.0) [1:5] + │ ├─ [2]: 17.17 + │ ├─ [3]: 18.18 + │ └─ [5]: 19.19 ├─ [:, 2]: Sparse (0.0) [1:5] - │ └─ [2]: 27.27 + │ ├─ [1]: 20.2 + │ ├─ [3]: 21.21 + │ ├─ [4]: 22.22 + │ └─ [5]: 23.23 └─ [:, 3]: Sparse (0.0) [1:5] - ├─ [1]: 28.28 - ├─ [2]: 29.29 - └─ [3]: 30.3 + ├─ [2]: 24.24 + ├─ [3]: 25.25 + └─ [4]: 26.26 + +A[Colon(),Colon(),Colon()] = 5×3×4-Tensor +└─ Sparse (0.0) [:,:,1:4] + ├─ [:, :, 1]: Dense [:,1:3] + │ ├─ [:, 1]: Sparse (0.0) [1:5] + │ │ ├─ [2]: 1.01 + │ │ └─ [3]: 2.02 + │ ├─ [:, 2]: Sparse (0.0) [1:5] + │ │ ├─ [3]: 3.03 + │ │ ├─ [4]: 4.04 + │ │ └─ [5]: 5.05 + │ └─ [:, 3]: Sparse (0.0) [1:5] + │ ├─ [2]: 6.06 + │ └─ [3]: 7.07 + ├─ [:, :, 2]: Dense [:,1:3] + │ ├─ [:, 1]: Sparse (0.0) [1:5] + │ │ ├─ [1]: 8.08 + │ │ ├─ [3]: 9.09 + │ │ ├─ [4]: 10.1 + │ │ └─ [5]: 11.11 + │ ├─ [:, 2]: Sparse (0.0) [1:5] + │ │ ├─ [2]: 12.12 + │ │ └─ [4]: 13.13 + │ └─ [:, 3]: Sparse (0.0) [1:5] + │ ├─ [2]: 14.14 + │ ├─ [4]: 15.15 + │ └─ [5]: 16.16 + ├─ [:, :, 3]: Dense [:,1:3] + │ ├─ [:, 1]: Sparse (0.0) [1:5] + │ │ ├─ [2]: 17.17 + │ │ ├─ [3]: 18.18 + │ │ └─ [5]: 19.19 + │ ├─ [:, 2]: Sparse (0.0) [1:5] + │ │ ├─ [1]: 20.2 + │ │ ├─ [3]: 21.21 + │ │ ├─ [4]: 22.22 + │ │ └─ [5]: 23.23 + │ └─ [:, 3]: Sparse (0.0) [1:5] + │ ├─ [2]: 24.24 + │ ├─ [3]: 25.25 + │ └─ [4]: 26.26 + └─ [:, :, 4]: Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:5] + ├─ [:, 2]: Sparse (0.0) [1:5] + │ └─ [2]: 27.27 + └─ [:, 3]: Sparse (0.0) [1:5] + ├─ [1]: 28.28 + ├─ [2]: 29.29 + └─ [3]: 30.3 diff --git a/test/reference64/interface/reduce.txt b/test/reference64/interface/reduce.txt index c26e5b1ae..fba13b204 100644 --- a/test/reference64/interface/reduce.txt +++ b/test/reference64/interface/reduce.txt @@ -1,25 +1,55 @@ reduce tests julia> A = Tensor(Dense(SparseList(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 4.4 - └─ [3]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 4.4 + └─ [3]: 5.5 julia> reduce(+, A, dims = (1,)) -SwizzleArray(Tensor(Dense{Int64}(Element{0.0, Float64, Int64}([6.6, 0.0, 9.9]), 3)), (1,)) +SwizzleArray (1) +└─ 3-Tensor + └─ Dense [1:3] + ├─ [1]: 6.6 + ├─ [2]: 0.0 + └─ [3]: 9.9 + julia> reduce(+, A, dims = 1) -SwizzleArray(Tensor(Dense{Int64}(Element{0.0, Float64, Int64}([6.6, 0.0, 9.9]), 3)), (1,)) +SwizzleArray (1) +└─ 3-Tensor + └─ Dense [1:3] + ├─ [1]: 6.6 + ├─ [2]: 0.0 + └─ [3]: 9.9 + julia> reduce(+, A, dims = (2,)) -SwizzleArray(Tensor(Sparse{Int64}(Element{0.0, Float64, Int64}([1.1, 7.7, 3.3, 4.4]), 4, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 5], [1, 2, 3, 4], [4, 1, 2, 3], Dict((1, 2) => 1, (1, 1) => 4, (1, 3) => 2, (1, 4) => 3)))), (1,)) +SwizzleArray (1) +└─ 4-Tensor + └─ Sparse (0.0) [1:4] + ├─ [1]: 4.4 + ├─ [2]: 1.1 + ├─ [3]: 7.7 + └─ [4]: 3.3 + julia> reduce(+, A, dims = 2) -SwizzleArray(Tensor(Sparse{Int64}(Element{0.0, Float64, Int64}([1.1, 7.7, 3.3, 4.4]), 4, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 5], [1, 2, 3, 4], [4, 1, 2, 3], Dict((1, 2) => 1, (1, 1) => 4, (1, 3) => 2, (1, 4) => 3)))), (1,)) +SwizzleArray (1) +└─ 4-Tensor + └─ Sparse (0.0) [1:4] + ├─ [1]: 4.4 + ├─ [2]: 1.1 + ├─ [3]: 7.7 + └─ [4]: 3.3 + julia> reduce(+, A, dims = (1, 2)) -SwizzleArray(Tensor(Element{0.0, Float64, Int64}([16.5])), ()) +SwizzleArray () +└─ -Tensor + └─ 16.5 + julia> reduce(+, A, dims = (:)) 16.5 diff --git a/test/reference64/interface/setindex.txt b/test/reference64/interface/setindex.txt index dbc7eae68..9d087ab18 100644 --- a/test/reference64/interface/setindex.txt +++ b/test/reference64/interface/setindex.txt @@ -1,138 +1,32 @@ setindex! tests julia> A = Tensor(Dense(Dense(Element(0.0))), 10, 12) -Dense [:,1:12] -├─ [:, 1]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 2]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 3]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 4]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 5]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 6]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 7]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 8]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 9]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 10]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 11]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -└─ [:, 12]: Dense [1:10] - ├─ [1]: 0.0 - ├─ [2]: 0.0 - ├─ [3]: 0.0 - ├─ [4]: 0.0 - ├─ [5]: 0.0 - ├─ [6]: 0.0 - ├─ [7]: 0.0 - ├─ [8]: 0.0 - ├─ [9]: 0.0 - └─ [10]: 0.0 +10×12-Tensor +└─ Dense [:,1:12] + ├─ [:, 1]: Dense [1:10] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [9]: 0.0 + │ └─ [10]: 0.0 + ├─ [:, 2]: Dense [1:10] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [9]: 0.0 + │ └─ [10]: 0.0 + ├─ ⋮ + ├─ [:, 11]: Dense [1:10] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [9]: 0.0 + │ └─ [10]: 0.0 + └─ [:, 12]: Dense [1:10] + ├─ [1]: 0.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [9]: 0.0 + └─ [10]: 0.0 julia> A[1, 4] = 3 3 diff --git a/test/reference64/typical/typical_inplace_sparse_add.txt b/test/reference64/typical/typical_inplace_sparse_add.txt index 48047c346..180fe07ff 100644 --- a/test/reference64/typical/typical_inplace_sparse_add.txt +++ b/test/reference64/typical/typical_inplace_sparse_add.txt @@ -1,23 +1,20 @@ julia> A = Tensor(SparseList(Element(0.0)), [2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0]) -SparseList (0.0) [1:10] -├─ [1]: 2.0 -├─ [3]: 3.0 -├─ [5]: 4.0 -├─ [7]: 5.0 -└─ [9]: 6.0 +10-Tensor +└─ SparseList (0.0) [1:10] + ├─ [1]: 2.0 + ├─ [3]: 3.0 + ├─ ⋮ + ├─ [7]: 5.0 + └─ [9]: 6.0 julia> B = Tensor(Dense(Element(0.0)), fill(1.1, 10)) -Dense [1:10] -├─ [1]: 1.1 -├─ [2]: 1.1 -├─ [3]: 1.1 -├─ [4]: 1.1 -├─ [5]: 1.1 -├─ [6]: 1.1 -├─ [7]: 1.1 -├─ [8]: 1.1 -├─ [9]: 1.1 -└─ [10]: 1.1 +10-Tensor +└─ Dense [1:10] + ├─ [1]: 1.1 + ├─ [2]: 1.1 + ├─ ⋮ + ├─ [9]: 1.1 + └─ [10]: 1.1 julia> @finch_code for i = _ B[i] += A[i] diff --git a/test/reference64/typical/typical_spmv_csc.txt b/test/reference64/typical/typical_spmv_csc.txt index 6cc777b94..a152d4134 100644 --- a/test/reference64/typical/typical_spmv_csc.txt +++ b/test/reference64/typical/typical_spmv_csc.txt @@ -1,26 +1,29 @@ julia> A = Tensor(Dense(SparseList(Element(0.0))), [0 0 3.3; 1.1 0 0; 2.2 0 4.4; 0 0 5.5]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ └─ [3]: 2.2 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 3.3 - ├─ [3]: 4.4 - └─ [4]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ └─ [3]: 2.2 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 3.3 + ├─ [3]: 4.4 + └─ [4]: 5.5 julia> y = Tensor([1.0, 2.0, 3.0, 4.0]) -Dense [1:4] -├─ [1]: 1.0 -├─ [2]: 2.0 -├─ [3]: 3.0 -└─ [4]: 4.0 +4-Tensor +└─ Dense [1:4] + ├─ [1]: 1.0 + ├─ [2]: 2.0 + ├─ [3]: 3.0 + └─ [4]: 4.0 julia> x = Tensor([1, 2, 3]) -Dense [1:3] -├─ [1]: 1 -├─ [2]: 2 -└─ [3]: 3 +3-Tensor +└─ Dense [1:3] + ├─ [1]: 1 + ├─ [2]: 2 + └─ [3]: 3 julia> @finch_code begin y .= 0 diff --git a/test/reference64/typical/typical_stats_example.txt b/test/reference64/typical/typical_stats_example.txt index 2aabffe77..4abc46306 100644 --- a/test/reference64/typical/typical_stats_example.txt +++ b/test/reference64/typical/typical_stats_example.txt @@ -1,17 +1,22 @@ julia> X = Tensor(SparseList(Element(0.0)), [1.0, 0.0, 0.0, 3.0, 0.0, 2.0, 0.0]) -SparseList (0.0) [1:7] -├─ [1]: 1.0 -├─ [4]: 3.0 -└─ [6]: 2.0 +7-Tensor +└─ SparseList (0.0) [1:7] + ├─ [1]: 1.0 + ├─ [4]: 3.0 + └─ [6]: 2.0 julia> x_min = Scalar(Inf) Scalar{Inf, Float64}(Inf) + julia> x_max = Scalar(-Inf) Scalar{-Inf, Float64}(-Inf) + julia> x_sum = Scalar(0.0) Scalar{0.0, Float64}(0.0) + julia> x_var = Scalar(0.0) Scalar{0.0, Float64}(0.0) + julia> @finch_code begin for i = _ let x = X[i] diff --git a/test/reference64/typical/typical_transpose_csc_to_coo.txt b/test/reference64/typical/typical_transpose_csc_to_coo.txt index 21be804cd..bfdb3e4fb 100644 --- a/test/reference64/typical/typical_transpose_csc_to_coo.txt +++ b/test/reference64/typical/typical_transpose_csc_to_coo.txt @@ -1,16 +1,18 @@ julia> A = Tensor(Dense(SparseList(Element(0.0))), [0 0 3.3; 1.1 0 0; 2.2 0 4.4; 0 0 5.5]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ └─ [3]: 2.2 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 3.3 - ├─ [3]: 4.4 - └─ [4]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ └─ [3]: 2.2 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 3.3 + ├─ [3]: 4.4 + └─ [4]: 5.5 julia> B = Tensor(SparseDict(SparseDict(Element(0.0)))) -Sparse (0.0) [:,1:0] +0×0-Tensor +└─ Sparse (0.0) [:,1:0] julia> @finch_code mode = :fast begin B .= 0 From d5677b85f9a87f15760f0f0c68038b4eafae3954 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Sat, 18 May 2024 11:28:54 -0400 Subject: [PATCH 14/22] more fix --- docs/src/guides/array_api.md | 88 ++++++++++++++++--- docs/src/guides/sparse_utils.md | 85 ++++++++++++------ docs/src/guides/tensor_formats.md | 28 +++--- docs/src/interactive.ipynb | 6 +- .../advanced_implementation/internals.md | 16 ++-- .../tensor_interface.md | 60 +++++++------ src/FinchNotation/syntax.jl | 7 +- src/interface/fsparse.jl | 6 +- src/scheduler/optimize.jl | 2 + src/symbolic/symbolic.jl | 19 ++-- src/tensors/fibers.jl | 26 +++--- src/tensors/levels/dense_levels.jl | 15 ++-- src/tensors/levels/dense_rle_levels.jl | 23 ++--- src/tensors/levels/element_levels.jl | 9 +- src/tensors/levels/pattern_levels.jl | 35 ++++---- src/tensors/levels/separate_levels.jl | 15 ++-- src/tensors/levels/sparse_bytemap_levels.jl | 28 +++--- src/tensors/levels/sparse_coo_levels.jl | 28 +++--- src/tensors/levels/sparse_hash_levels.jl | 28 +++--- src/tensors/levels/sparse_interval_levels.jl | 5 +- src/tensors/levels/sparse_levels.jl | 32 +++---- src/tensors/levels/sparse_list_levels.jl | 32 +++---- src/tensors/levels/sparse_point_levels.jl | 15 ++-- src/tensors/levels/sparse_rle_levels.jl | 17 ++-- 24 files changed, 379 insertions(+), 246 deletions(-) diff --git a/docs/src/guides/array_api.md b/docs/src/guides/array_api.md index 6d3534a74..52bfc384c 100644 --- a/docs/src/guides/array_api.md +++ b/docs/src/guides/array_api.md @@ -10,27 +10,83 @@ For example: ```jldoctest example1; setup = :(using Finch) julia> A = fsparse([1, 1, 2, 3], [2, 4, 5, 6], [1.0, 2.0, 3.0]) -SparseCOO{2} (0.0) [:,1:6] -├─ [1, 2]: 1.0 -├─ [1, 4]: 2.0 -└─ [2, 5]: 3.0 +3×6-Tensor +└─ SparseCOO{2} (0.0) [:,1:6] + ├─ [1, 2]: 1.0 + ├─ [1, 4]: 2.0 + └─ [2, 5]: 3.0 julia> A + 0 -SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{0.0, Float64, Int64}([0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0]), 3), 6)), (1, 2)) +SwizzleArray (1, 2) +└─ 3×6-Tensor + └─ Dense [:,1:6] + ├─ [:, 1]: Dense [1:3] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ └─ [3]: 0.0 + ├─ [:, 2]: Dense [1:3] + │ ├─ [1]: 1.0 + │ ├─ [2]: 0.0 + │ └─ [3]: 0.0 + ├─ ⋮ + ├─ [:, 5]: Dense [1:3] + │ ├─ [1]: 0.0 + │ ├─ [2]: 3.0 + │ └─ [3]: 0.0 + └─ [:, 6]: Dense [1:3] + ├─ [1]: 0.0 + ├─ [2]: 0.0 + └─ [3]: 0.0 julia> A + 1 -SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{1.0, Float64, Int64}([1.0, 1.0, 1.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 4.0, 1.0, 1.0, 1.0, 1.0]), 3), 6)), (1, 2)) +SwizzleArray (1, 2) +└─ 3×6-Tensor + └─ Dense [:,1:6] + ├─ [:, 1]: Dense [1:3] + │ ├─ [1]: 1.0 + │ ├─ [2]: 1.0 + │ └─ [3]: 1.0 + ├─ [:, 2]: Dense [1:3] + │ ├─ [1]: 2.0 + │ ├─ [2]: 1.0 + │ └─ [3]: 1.0 + ├─ ⋮ + ├─ [:, 5]: Dense [1:3] + │ ├─ [1]: 1.0 + │ ├─ [2]: 4.0 + │ └─ [3]: 1.0 + └─ [:, 6]: Dense [1:3] + ├─ [1]: 1.0 + ├─ [2]: 1.0 + └─ [3]: 1.0 julia> B = A .* 2 -SwizzleArray(Tensor(Sparse{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([2.0, 4.0, 6.0]), 3, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 2, 3, 4], [1, 1, 2], [1, 2, 3], Dict((3, 2) => 3, (1, 1) => 1, (2, 1) => 2))), 6, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4], [2, 4, 5], [1, 2, 3], Dict((1, 2) => 1, (1, 4) => 2, (1, 5) => 3)))), (1, 2)) +SwizzleArray (1, 2) +└─ 3×6-Tensor + └─ Sparse (0.0) [:,1:6] + ├─ [:, 2]: Sparse (0.0) [1:3] + │ └─ [1]: 2.0 + ├─ [:, 4]: Sparse (0.0) [1:3] + │ └─ [1]: 4.0 + └─ [:, 5]: Sparse (0.0) [1:3] + └─ [2]: 6.0 julia> B[1:2, 1:2] -Sparse (0.0) [:,1:2] -└─ [:, 2]: Sparse (0.0) [1:2] - └─ [1]: 2.0 +2×2-Tensor +└─ Sparse (0.0) [:,1:2] + └─ [:, 2]: Sparse (0.0) [1:2] + └─ [1]: 2.0 julia> map(x -> x^2, B) -SwizzleArray(Tensor(Sparse{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([4.0, 16.0, 36.0]), 3, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 2, 3, 4], [1, 1, 2], [1, 2, 3], Dict((3, 2) => 3, (1, 1) => 1, (2, 1) => 2))), 6, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4], [2, 4, 5], [1, 2, 3], Dict((1, 2) => 1, (1, 4) => 2, (1, 5) => 3)))), (1, 2)) +SwizzleArray (1, 2) +└─ 3×6-Tensor + └─ Sparse (0.0) [:,1:6] + ├─ [:, 2]: Sparse (0.0) [1:3] + │ └─ [1]: 4.0 + ├─ [:, 4]: Sparse (0.0) [1:3] + │ └─ [1]: 16.0 + └─ [:, 5]: Sparse (0.0) [1:3] + └─ [2]: 36.0 ``` # Array Fusion @@ -50,7 +106,15 @@ julia> D = lazy(B); julia> E = (C .+ D)/2; julia> compute(E) -SwizzleArray(Tensor(Sparse{Int64}(Sparse{Int64}(Element{0.0, Float64, Int64}([1.5, 3.0, 4.5]), 3, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 2, 3, 4], [1, 1, 2], [1, 2, 3], Dict((3, 2) => 3, (1, 1) => 1, (2, 1) => 2))), 6, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4], [2, 4, 5], [1, 2, 3], Dict((1, 2) => 1, (1, 4) => 2, (1, 5) => 3)))), (1, 2)) +SwizzleArray (1, 2) +└─ 3×6-Tensor + └─ Sparse (0.0) [:,1:6] + ├─ [:, 2]: Sparse (0.0) [1:3] + │ └─ [1]: 1.5 + ├─ [:, 4]: Sparse (0.0) [1:3] + │ └─ [1]: 3.0 + └─ [:, 5]: Sparse (0.0) [1:3] + └─ [2]: 4.5 ``` diff --git a/docs/src/guides/sparse_utils.md b/docs/src/guides/sparse_utils.md index 5020fc2b8..743dcb0fe 100644 --- a/docs/src/guides/sparse_utils.md +++ b/docs/src/guides/sparse_utils.md @@ -21,34 +21,64 @@ Finch tensors support an arbitrary "background" value for sparse arrays. While m ```jldoctest example1; setup = :(using Finch) julia> A = fsparse([1, 1, 2, 3], [2, 4, 5, 6], [1.0, 2.0, 3.0]) -SparseCOO{2} (0.0) [:,1:6] -├─ [1, 2]: 1.0 -├─ [1, 4]: 2.0 -└─ [2, 5]: 3.0 +3×6-Tensor +└─ SparseCOO{2} (0.0) [:,1:6] + ├─ [1, 2]: 1.0 + ├─ [1, 4]: 2.0 + └─ [2, 5]: 3.0 julia> min.(A, -1) -SwizzleArray(Tensor(Dense{Int64}(Dense{Int64}(Element{-1.0, Float64, Int64}([-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]), 3), 6)), (1, 2)) +SwizzleArray (1, 2) +└─ 3×6-Tensor + └─ Dense [:,1:6] + ├─ [:, 1]: Dense [1:3] + │ ├─ [1]: -1.0 + │ ├─ [2]: -1.0 + │ └─ [3]: -1.0 + ├─ [:, 2]: Dense [1:3] + │ ├─ [1]: -1.0 + │ ├─ [2]: -1.0 + │ └─ [3]: -1.0 + ├─ ⋮ + ├─ [:, 5]: Dense [1:3] + │ ├─ [1]: -1.0 + │ ├─ [2]: -1.0 + │ └─ [3]: -1.0 + └─ [:, 6]: Dense [1:3] + ├─ [1]: -1.0 + ├─ [2]: -1.0 + └─ [3]: -1.0 julia> fill_value(A) 0.0 julia> B = set_fill_value!(A, -Inf) -SparseCOO{2} (-Inf) [:,1:6] -├─ [1, 2]: 1.0 -├─ [1, 4]: 2.0 -└─ [2, 5]: 3.0 +3×6-Tensor +└─ SparseCOO{2} (-Inf) [:,1:6] + ├─ [1, 2]: 1.0 + ├─ [1, 4]: 2.0 + └─ [2, 5]: 3.0 julia> min.(B, -1) -SwizzleArray(Tensor(Sparse{Int64}(Sparse{Int64}(Element{-Inf, Float64, Int64}([-1.0, -1.0, -1.0]), 3, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 2, 3, 4], [1, 1, 2], [1, 2, 3], Dict((3, 2) => 3, (1, 1) => 1, (2, 1) => 2))), 6, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}([1, 4], [2, 4, 5], [1, 2, 3], Dict((1, 2) => 1, (1, 4) => 2, (1, 5) => 3)))), (1, 2)) +SwizzleArray (1, 2) +└─ 3×6-Tensor + └─ Sparse (-Inf) [:,1:6] + ├─ [:, 2]: Sparse (-Inf) [1:3] + │ └─ [1]: -1.0 + ├─ [:, 4]: Sparse (-Inf) [1:3] + │ └─ [1]: -1.0 + └─ [:, 5]: Sparse (-Inf) [1:3] + └─ [2]: -1.0 julia> countstored(A) 3 julia> pattern!(A) -SparseCOO{2} (false) [:,1:6] -├─ [1, 2]: true -├─ [1, 4]: true -└─ [2, 5]: true +3×6-Tensor +└─ SparseCOO{2} (false) [:,1:6] + ├─ [1, 2]: true + ├─ [1, 4]: true + └─ [2, 5]: true ``` @@ -73,21 +103,22 @@ instead store a tensor of tuples of the form `(value, is_fill)`. For example, ```jldoctest example3; setup = :(using Finch) julia> A = fsparse([1, 1, 2, 3], [2, 4, 5, 6], [(1.0, false), (0.0, true), (3.0, false)]; fill_value=(0.0, true)) -SparseCOO{2} ((0.0, true)) [:,1:6] -├─ [1, 2]: (1.0, false) -├─ [1, 4]: (0.0, true) -└─ [2, 5]: (3.0, false) +3×6-Tensor +└─ SparseCOO{2} ((0.0, true)) [:,1:6] + ├─ [1, 2]: (1.0, false) + ├─ [1, 4]: (0.0, true) + └─ [2, 5]: (3.0, false) julia> B = Tensor(Dense(SparseList(Element((0.0, true)))), A) -Dense [:,1:6] -├─ [:, 1]: SparseList ((0.0, true)) [1:3] -├─ [:, 2]: SparseList ((0.0, true)) [1:3] -│ └─ [1]: (1.0, false) -├─ [:, 3]: SparseList ((0.0, true)) [1:3] -├─ [:, 4]: SparseList ((0.0, true)) [1:3] -├─ [:, 5]: SparseList ((0.0, true)) [1:3] -│ └─ [2]: (3.0, false) -└─ [:, 6]: SparseList ((0.0, true)) [1:3] +3×6-Tensor +└─ Dense [:,1:6] + ├─ [:, 1]: SparseList ((0.0, true)) [1:3] + ├─ [:, 2]: SparseList ((0.0, true)) [1:3] + │ └─ [1]: (1.0, false) + ├─ ⋮ + ├─ [:, 5]: SparseList ((0.0, true)) [1:3] + │ └─ [2]: (3.0, false) + └─ [:, 6]: SparseList ((0.0, true)) [1:3] julia> sum(map(last, B)) 16 diff --git a/docs/src/guides/tensor_formats.md b/docs/src/guides/tensor_formats.md index 3226f8ef0..97da5f6b5 100644 --- a/docs/src/guides/tensor_formats.md +++ b/docs/src/guides/tensor_formats.md @@ -12,10 +12,11 @@ For example, to construct an empty sparse matrix: ```jldoctest example1; setup=:(using Finch) julia> A_fbr = Tensor(Dense(SparseList(Element(0.0))), 4, 3) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] ``` To initialize a sparse matrix with some values: @@ -29,15 +30,16 @@ julia> A = [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0] 3.3 0.0 0.0 julia> A_fbr = Tensor(Dense(SparseList(Element(0.0))), A) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 4.4 - └─ [3]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 4.4 + └─ [3]: 5.5 ``` diff --git a/docs/src/interactive.ipynb b/docs/src/interactive.ipynb index dcb87347c..afaf3c67d 100644 --- a/docs/src/interactive.ipynb +++ b/docs/src/interactive.ipynb @@ -49,11 +49,11 @@ "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.6.7" + "version": "1.10.3" }, "kernelspec": { - "name": "julia-1.6", - "display_name": "Julia 1.6.7", + "name": "julia-1.10", + "display_name": "Julia 1.10.3", "language": "julia" } }, diff --git a/docs/src/reference/advanced_implementation/internals.md b/docs/src/reference/advanced_implementation/internals.md index 43bd3096c..fac8146f1 100644 --- a/docs/src/reference/advanced_implementation/internals.md +++ b/docs/src/reference/advanced_implementation/internals.md @@ -96,9 +96,10 @@ julia> typeof(prgm) Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:C}, Tensor{SparseListLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}, Finch.FinchNotation.LiteralInstance{0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:C}, Tensor{SparseListLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i}, Finch.FinchNotation.IndexInstance{:i}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:*}, Finch.FinchNotation.LiteralInstance{*}}, Tuple{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:A}, Tensor{SparseListLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i}, Finch.FinchNotation.IndexInstance{:i}}}}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:B}, Tensor{DenseLevel{Int64, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i}, Finch.FinchNotation.IndexInstance{:i}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:C}, Tensor{SparseListLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}}}}} julia> C = Finch.execute(prgm).C -SparseList (0) [1:5] -├─ [2]: 24 -└─ [5]: 45 +5-Tensor +└─ SparseList (0) [1:5] + ├─ [2]: 24 + └─ [5]: 45 ``` This functionality is sufficient for building finch kernels programatically. For @@ -123,9 +124,10 @@ julia> function pointwise_sum(As...) pointwise_sum (generic function with 1 method) julia> pointwise_sum([1, 2], [3, 4]) -Dense [1:2] -├─ [1]: 4 -└─ [2]: 6 +2-Tensor +└─ Dense [1:2] + ├─ [1]: 4 + └─ [2]: 6 ``` @@ -165,7 +167,7 @@ julia> inst = Finch.@finch_program_instance begin end end Finch program instance: for i = Dimensionless() - tag(s, Scalar{0, Int64}(0))[] <>= tag(A, Tensor(SparseList(Element(0))))[tag(i, i)] + tag(s, Scalar{0, Int64})[] <>= tag(A, Tensor(SparseList(Element(0))))[tag(i, i)] end julia> typeof(inst) diff --git a/docs/src/reference/advanced_implementation/tensor_interface.md b/docs/src/reference/advanced_implementation/tensor_interface.md index 5db52faaf..f5a7c3c06 100644 --- a/docs/src/reference/advanced_implementation/tensor_interface.md +++ b/docs/src/reference/advanced_implementation/tensor_interface.md @@ -46,11 +46,12 @@ Dense [1:4] └─ [4]: 0.0 julia> A_fbr[:, 3] -Dense [1:4] -├─ [1]: 4.4 -├─ [2]: 0.0 -├─ [3]: 5.5 -└─ [4]: 0.0 +4-Tensor +└─ Dense [1:4] + ├─ [1]: 4.4 + ├─ [2]: 0.0 + ├─ [3]: 5.5 + └─ [4]: 0.0 julia> A_fbr(3) Dense [1:4] @@ -84,15 +85,16 @@ nonzeros") instead of `d` (for "`Dense`"): ```jldoctest example1 julia> A_fbr = Tensor(Dense(SparseList(Element(0.0))), A) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 4.4 - └─ [3]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 4.4 + └─ [3]: 5.5 ``` ![CSC Format Index Tree](../../assets/levels-A-d-sl-e.png) @@ -109,14 +111,15 @@ hypersparsity), it is better to compress the root level as well: ```jldoctest example1 julia> A_fbr = Tensor(SparseList(SparseList(Element(0.0))), A) -SparseList (0.0) [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 4.4 - └─ [3]: 5.5 +4×3-Tensor +└─ SparseList (0.0) [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 4.4 + └─ [3]: 5.5 ``` ![DCSC Format Index Tree](../../assets/levels-A-sl-sl-e.png) @@ -136,12 +139,13 @@ declare the number of indices handled by the level: ```jldoctest example1 julia> A_fbr = Tensor(SparseCOO{2}(Element(0.0)), A) -SparseCOO{2} (0.0) [:,1:3] -├─ [2, 1]: 1.1 -├─ [3, 1]: 2.2 -├─ [4, 1]: 3.3 -├─ [1, 3]: 4.4 -└─ [3, 3]: 5.5 +4×3-Tensor +└─ SparseCOO{2} (0.0) [:,1:3] + ├─ [2, 1]: 1.1 + ├─ [3, 1]: 2.2 + ├─ ⋮ + ├─ [1, 3]: 4.4 + └─ [3, 3]: 5.5 ``` ![COO Format Index Tree](../../assets/levels-A-sc2-e.png) diff --git a/src/FinchNotation/syntax.jl b/src/FinchNotation/syntax.jl index 87302fee3..9785c30fb 100644 --- a/src/FinchNotation/syntax.jl +++ b/src/FinchNotation/syntax.jl @@ -82,9 +82,10 @@ initwrite(z) = InitWriter{z}() ```jldoctest setup=:(using Finch) julia> a = Tensor(SparseList(Element(0.0)), [0, 1.1, 0, 4.4, 0]) -SparseList (0.0) [1:5] -├─ [2]: 1.1 -└─ [4]: 4.4 +5-Tensor +└─ SparseList (0.0) [1:5] + ├─ [2]: 1.1 + └─ [4]: 4.4 julia> x = Scalar(0.0); @finch for i=_; x[] <>= a[i] end; diff --git a/src/interface/fsparse.jl b/src/interface/fsparse.jl index a8066bcfb..103a45780 100644 --- a/src/interface/fsparse.jl +++ b/src/interface/fsparse.jl @@ -232,10 +232,12 @@ See also: (`spzeros`)(https://docs.julialang.org/en/v1/stdlib/SparseArrays/#Spar # Examples ```jldoctest julia> fspzeros(Bool, 3, 3) -SparseCOO{2} (false) [:,1:3] +3×3-Tensor +└─ SparseCOO{2} (false) [:,1:3] julia> fspzeros(Float64, 2, 2, 2) -SparseCOO{3} (0.0) [:,:,1:2] +2×2×2-Tensor +└─ SparseCOO{3} (0.0) [:,:,1:2] ``` """ fspzeros(M...) = fspzeros(Float64, M...) diff --git a/src/scheduler/optimize.jl b/src/scheduler/optimize.jl index 660980881..1b3f90ae7 100644 --- a/src/scheduler/optimize.jl +++ b/src/scheduler/optimize.jl @@ -189,6 +189,8 @@ function materialize_squeeze_expand_productions(root) else reorder(relabel(tns_2, idxs_3), idxs_2) end + elseif @capture(arg, reorder(relabel(~tns, ~i...), ~i...)) + tns else arg end diff --git a/src/symbolic/symbolic.jl b/src/symbolic/symbolic.jl index 18fb4f88c..99d58c608 100644 --- a/src/symbolic/symbolic.jl +++ b/src/symbolic/symbolic.jl @@ -20,9 +20,10 @@ neither are `z`, then return `a`. Useful for getting the first nonfill value in a sparse array. ```jldoctest setup=:(using Finch) julia> a = Tensor(SparseList(Element(0.0)), [0, 1.1, 0, 4.4, 0]) -SparseList (0.0) [1:5] -├─ [2]: 1.1 -└─ [4]: 4.4 +5-Tensor +└─ SparseList (0.0) [1:5] + ├─ [2]: 1.1 + └─ [4]: 4.4 julia> x = Scalar(0.0); @finch for i=_; x[] <>= a[i] end; @@ -45,9 +46,10 @@ is handy for filtering out values based on a mask or a predicate. ```jldoctest setup=:(using Finch) julia> a = Tensor(SparseList(Element(0.0)), [0, 1.1, 0, 4.4, 0]) -SparseList (0.0) [1:5] -├─ [2]: 1.1 -└─ [4]: 4.4 +5-Tensor +└─ SparseList (0.0) [1:5] + ├─ [2]: 1.1 + └─ [4]: 4.4 julia> x = Tensor(SparseList(Element(0.0))); @@ -57,8 +59,9 @@ julia> @finch (x .= 0; for i=_; x[i] = filterop(0)(c[i], a[i]) end) (x = Tensor(SparseList{Int64}(Element{0.0, Float64, Int64}([4.4]), 5, [1, 2], [4])),) julia> x -SparseList (0.0) [1:5] -└─ [4]: 4.4 +5-Tensor +└─ SparseList (0.0) [1:5] + └─ [4]: 4.4 ``` """ filterop(d) = FilterOp{d}() diff --git a/src/tensors/fibers.jl b/src/tensors/fibers.jl index 336cd56a4..66a607191 100644 --- a/src/tensors/fibers.jl +++ b/src/tensors/fibers.jl @@ -172,20 +172,22 @@ modified. ```jldoctest julia> A = Tensor(SparseList(Element(0.0), 10), [2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0]) -SparseList (0.0) [1:10] -├─ [1]: 2.0 -├─ [3]: 3.0 -├─ [5]: 4.0 -├─ [7]: 5.0 -└─ [9]: 6.0 +10-Tensor +└─ SparseList (0.0) [1:10] + ├─ [1]: 2.0 + ├─ [3]: 3.0 + ├─ ⋮ + ├─ [7]: 5.0 + └─ [9]: 6.0 julia> set_fill_value!(A, Inf) -SparseList (Inf) [1:10] -├─ [1]: 2.0 -├─ [3]: 3.0 -├─ [5]: 4.0 -├─ [7]: 5.0 -└─ [9]: 6.0 +10-Tensor +└─ SparseList (Inf) [1:10] + ├─ [1]: 2.0 + ├─ [3]: 3.0 + ├─ ⋮ + ├─ [7]: 5.0 + └─ [9]: 6.0 ``` """ set_fill_value!(fbr::Tensor, init) = Tensor(set_fill_value!(fbr.lvl, init)) diff --git a/src/tensors/levels/dense_levels.jl b/src/tensors/levels/dense_levels.jl index 33b087595..e03c4c8ac 100644 --- a/src/tensors/levels/dense_levels.jl +++ b/src/tensors/levels/dense_levels.jl @@ -13,13 +13,14 @@ julia> ndims(Tensor(Dense(Dense(Element(0.0))))) 2 julia> Tensor(Dense(Dense(Element(0.0))), [1 2; 3 4]) -Dense [:,1:2] -├─ [:, 1]: Dense [1:2] -│ ├─ [1]: 1.0 -│ └─ [2]: 3.0 -└─ [:, 2]: Dense [1:2] - ├─ [1]: 2.0 - └─ [2]: 4.0 +2×2-Tensor +└─ Dense [:,1:2] + ├─ [:, 1]: Dense [1:2] + │ ├─ [1]: 1.0 + │ └─ [2]: 3.0 + └─ [:, 2]: Dense [1:2] + ├─ [1]: 2.0 + └─ [2]: 4.0 ``` """ struct DenseLevel{Ti, Lvl} <: AbstractLevel diff --git a/src/tensors/levels/dense_rle_levels.jl b/src/tensors/levels/dense_rle_levels.jl index f4aec65bd..f75173bf8 100644 --- a/src/tensors/levels/dense_rle_levels.jl +++ b/src/tensors/levels/dense_rle_levels.jl @@ -14,17 +14,18 @@ duplicate consecutive runs. ```jldoctest julia> Tensor(Dense(DenseRLELevel(Element(0.0))), [10 0 20; 30 0 0; 0 0 40]) -Dense [:,1:3] -├─ [:, 1]: DenseRLE (0.0) [1:3] -│ ├─ [1:1]: 10.0 -│ ├─ [2:2]: 30.0 -│ └─ [3:3]: 0.0 -├─ [:, 2]: DenseRLE (0.0) [1:3] -│ └─ [1:3]: 0.0 -└─ [:, 3]: DenseRLE (0.0) [1:3] - ├─ [1:1]: 20.0 - ├─ [2:2]: 0.0 - └─ [3:3]: 40.0 +3×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: DenseRLE (0.0) [1:3] + │ ├─ [1:1]: 10.0 + │ ├─ [2:2]: 30.0 + │ └─ [3:3]: 0.0 + ├─ [:, 2]: DenseRLE (0.0) [1:3] + │ └─ [1:3]: 0.0 + └─ [:, 3]: DenseRLE (0.0) [1:3] + ├─ [1:1]: 20.0 + ├─ [2:2]: 0.0 + └─ [3:3]: 40.0 ``` """ struct DenseRLELevel{Ti, Ptr<:AbstractVector, Right<:AbstractVector, merge, Lvl} <: AbstractLevel diff --git a/src/tensors/levels/element_levels.jl b/src/tensors/levels/element_levels.jl index 92ec39f8f..9ba0b753b 100644 --- a/src/tensors/levels/element_levels.jl +++ b/src/tensors/levels/element_levels.jl @@ -10,10 +10,11 @@ access Val. ```jldoctest julia> Tensor(Dense(Element(0.0)), [1, 2, 3]) -Dense [1:3] -├─ [1]: 1.0 -├─ [2]: 2.0 -└─ [3]: 3.0 +3-Tensor +└─ Dense [1:3] + ├─ [1]: 1.0 + ├─ [2]: 2.0 + └─ [3]: 3.0 ``` """ struct ElementLevel{Vf, Tv, Tp, Val} <: AbstractLevel diff --git a/src/tensors/levels/pattern_levels.jl b/src/tensors/levels/pattern_levels.jl index 70c2bc842..ac8cd8af9 100644 --- a/src/tensors/levels/pattern_levels.jl +++ b/src/tensors/levels/pattern_levels.jl @@ -7,10 +7,11 @@ are stored by other fibers. See [`pattern!`](@ref) for usage examples. ```jldoctest julia> Tensor(Dense(Pattern()), 3) -Dense [1:3] -├─ [1]: true -├─ [2]: true -└─ [3]: true +3-Tensor +└─ Dense [1:3] + ├─ [1]: true + ├─ [2]: true + └─ [3]: true ``` """ struct PatternLevel{Tp} <: AbstractLevel end @@ -58,20 +59,22 @@ original tensor unusable when modified. ```jldoctest julia> A = Tensor(SparseList(Element(0.0), 10), [2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0]) -SparseList (0.0) [1:10] -├─ [1]: 2.0 -├─ [3]: 3.0 -├─ [5]: 4.0 -├─ [7]: 5.0 -└─ [9]: 6.0 +10-Tensor +└─ SparseList (0.0) [1:10] + ├─ [1]: 2.0 + ├─ [3]: 3.0 + ├─ ⋮ + ├─ [7]: 5.0 + └─ [9]: 6.0 julia> pattern!(A) -SparseList (false) [1:10] -├─ [1]: true -├─ [3]: true -├─ [5]: true -├─ [7]: true -└─ [9]: true +10-Tensor +└─ SparseList (false) [1:10] + ├─ [1]: true + ├─ [3]: true + ├─ ⋮ + ├─ [7]: true + └─ [9]: true ``` """ pattern!(fbr::Tensor) = Tensor(pattern!(fbr.lvl)) diff --git a/src/tensors/levels/separate_levels.jl b/src/tensors/levels/separate_levels.jl index d5e5fc16b..0975d852e 100644 --- a/src/tensors/levels/separate_levels.jl +++ b/src/tensors/levels/separate_levels.jl @@ -8,13 +8,14 @@ Each sublevel is stored in a vector of type `Val` with `eltype(Val) = Lvl`. ```jldoctest julia> Tensor(Dense(Separate(Element(0.0))), [1, 2, 3]) -Dense [1:3] -├─ [1]: Pointer -> -│ └─ 1.0 -├─ [2]: Pointer -> -│ └─ 2.0 -└─ [3]: Pointer -> - └─ 3.0 +3-Tensor +└─ Dense [1:3] + ├─ [1]: Pointer -> + │ └─ 1.0 + ├─ [2]: Pointer -> + │ └─ 2.0 + └─ [3]: Pointer -> + └─ 3.0 ``` """ struct SeparateLevel{Lvl, Val} <: AbstractLevel diff --git a/src/tensors/levels/sparse_bytemap_levels.jl b/src/tensors/levels/sparse_bytemap_levels.jl index 2bf153514..6fc4c240f 100644 --- a/src/tensors/levels/sparse_bytemap_levels.jl +++ b/src/tensors/levels/sparse_bytemap_levels.jl @@ -9,21 +9,23 @@ positions in the level. ```jldoctest julia> Tensor(Dense(SparseByteMap(Element(0.0))), [10 0 20; 30 0 0; 0 0 40]) -Dense [:,1:3] -├─ [:, 1]: SparseByteMap (0.0) [1:3] -│ ├─ [1]: 10.0 -│ └─ [2]: 30.0 -├─ [:, 2]: SparseByteMap (0.0) [1:3] -└─ [:, 3]: SparseByteMap (0.0) [1:3] - ├─ [1]: 0.0 - └─ [3]: 0.0 +3×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseByteMap (0.0) [1:3] + │ ├─ [1]: 10.0 + │ └─ [2]: 30.0 + ├─ [:, 2]: SparseByteMap (0.0) [1:3] + └─ [:, 3]: SparseByteMap (0.0) [1:3] + ├─ [1]: 0.0 + └─ [3]: 0.0 julia> Tensor(SparseByteMap(SparseByteMap(Element(0.0))), [10 0 20; 30 0 0; 0 0 40]) -SparseByteMap (0.0) [:,1:3] -├─ [:, 1]: SparseByteMap (0.0) [1:3] -│ ├─ [1]: 10.0 -│ └─ [2]: 30.0 -└─ [:, 3]: SparseByteMap (0.0) [1:3] +3×3-Tensor +└─ SparseByteMap (0.0) [:,1:3] + ├─ [:, 1]: SparseByteMap (0.0) [1:3] + │ ├─ [1]: 10.0 + │ └─ [2]: 30.0 + └─ [:, 3]: SparseByteMap (0.0) [1:3] ``` """ struct SparseByteMapLevel{Ti, Ptr, Tbl, Srt, Lvl} <: AbstractLevel diff --git a/src/tensors/levels/sparse_coo_levels.jl b/src/tensors/levels/sparse_coo_levels.jl index ddd883063..94f2e326c 100644 --- a/src/tensors/levels/sparse_coo_levels.jl +++ b/src/tensors/levels/sparse_coo_levels.jl @@ -18,21 +18,23 @@ The type `Ptr` is the type for the pointer array. ```jldoctest julia> Tensor(Dense(SparseCOO{1}(Element(0.0))), [10 0 20; 30 0 0; 0 0 40]) -Dense [:,1:3] -├─ [:, 1]: SparseCOO{1} (0.0) [1:3] -│ ├─ [1]: 10.0 -│ └─ [2]: 30.0 -├─ [:, 2]: SparseCOO{1} (0.0) [1:3] -└─ [:, 3]: SparseCOO{1} (0.0) [1:3] - ├─ [1]: 20.0 - └─ [3]: 40.0 +3×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseCOO{1} (0.0) [1:3] + │ ├─ [1]: 10.0 + │ └─ [2]: 30.0 + ├─ [:, 2]: SparseCOO{1} (0.0) [1:3] + └─ [:, 3]: SparseCOO{1} (0.0) [1:3] + ├─ [1]: 20.0 + └─ [3]: 40.0 julia> Tensor(SparseCOO{2}(Element(0.0)), [10 0 20; 30 0 0; 0 0 40]) -SparseCOO{2} (0.0) [:,1:3] -├─ [1, 1]: 10.0 -├─ [2, 1]: 30.0 -├─ [1, 3]: 20.0 -└─ [3, 3]: 40.0 +3×3-Tensor +└─ SparseCOO{2} (0.0) [:,1:3] + ├─ [1, 1]: 10.0 + ├─ [2, 1]: 30.0 + ├─ [1, 3]: 20.0 + └─ [3, 3]: 40.0 ``` """ struct SparseCOOLevel{N, TI<:Tuple, Ptr, Tbl, Lvl} <: AbstractLevel diff --git a/src/tensors/levels/sparse_hash_levels.jl b/src/tensors/levels/sparse_hash_levels.jl index 549f519ec..bfc08e94c 100644 --- a/src/tensors/levels/sparse_hash_levels.jl +++ b/src/tensors/levels/sparse_hash_levels.jl @@ -15,21 +15,23 @@ pairs in the hash table. ```jldoctest julia> Tensor(Dense(SparseHash{1}(Element(0.0))), [10 0 20; 30 0 0; 0 0 40]) -Dense [:,1:3] -├─ [:, 1]: SparseHash{1} (0.0) [1:3] -│ ├─ [1]: 10.0 -│ └─ [2]: 30.0 -├─ [:, 2]: SparseHash{1} (0.0) [1:3] -└─ [:, 3]: SparseHash{1} (0.0) [1:3] - ├─ [1]: 20.0 - └─ [3]: 40.0 +3×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseHash{1} (0.0) [1:3] + │ ├─ [1]: 10.0 + │ └─ [2]: 30.0 + ├─ [:, 2]: SparseHash{1} (0.0) [1:3] + └─ [:, 3]: SparseHash{1} (0.0) [1:3] + ├─ [1]: 20.0 + └─ [3]: 40.0 julia> Tensor(SparseHash{2}(Element(0.0)), [10 0 20; 30 0 0; 0 0 40]) -SparseHash{2} (0.0) [:,1:3] -├─ [1, 1]: 10.0 -├─ [2, 1]: 30.0 -├─ [1, 3]: 20.0 -└─ [3, 3]: 40.0 +3×3-Tensor +└─ SparseHash{2} (0.0) [:,1:3] + ├─ [1, 1]: 10.0 + ├─ [2, 1]: 30.0 + ├─ [1, 3]: 20.0 + └─ [3, 3]: 40.0 ``` """ struct SparseHashLevel{N, TI<:Tuple, Ptr, Tbl, Srt, Lvl} <: AbstractLevel diff --git a/src/tensors/levels/sparse_interval_levels.jl b/src/tensors/levels/sparse_interval_levels.jl index 0c9e93d65..41a2a9023 100644 --- a/src/tensors/levels/sparse_interval_levels.jl +++ b/src/tensors/levels/sparse_interval_levels.jl @@ -11,8 +11,9 @@ are the types of the arrays used to store positions and endpoints. ```jldoctest julia> Tensor(SparseInterval(Element(0)), [0, 10, 0]) -SparseInterval (0) [1:3] -└─ [2:2]: 10 +3-Tensor +└─ SparseInterval (0) [1:3] + └─ [2:2]: 10 julia> Tensor(SparseInterval(Element(0)), [0, 10, 10]) ERROR: Finch.FinchProtocolError("SparseIntervalLevels can only be updated once") diff --git a/src/tensors/levels/sparse_levels.jl b/src/tensors/levels/sparse_levels.jl index f8aff517d..634f667a5 100644 --- a/src/tensors/levels/sparse_levels.jl +++ b/src/tensors/levels/sparse_levels.jl @@ -124,23 +124,25 @@ arrays used to store positions and indicies. ```jldoctest julia> Tensor(Dense(Sparse(Element(0.0))), [10 0 20; 30 0 0; 0 0 40]) -Dense [:,1:3] -├─ [:, 1]: Sparse (0.0) [1:3] -│ ├─ [1]: 10.0 -│ └─ [2]: 30.0 -├─ [:, 2]: Sparse (0.0) [1:3] -└─ [:, 3]: Sparse (0.0) [1:3] - ├─ [1]: 20.0 - └─ [3]: 40.0 +3×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:3] + │ ├─ [1]: 10.0 + │ └─ [2]: 30.0 + ├─ [:, 2]: Sparse (0.0) [1:3] + └─ [:, 3]: Sparse (0.0) [1:3] + ├─ [1]: 20.0 + └─ [3]: 40.0 julia> Tensor(Sparse(Sparse(Element(0.0))), [10 0 20; 30 0 0; 0 0 40]) -Sparse (0.0) [:,1:3] -├─ [:, 1]: Sparse (0.0) [1:3] -│ ├─ [1]: 10.0 -│ └─ [2]: 30.0 -└─ [:, 3]: Sparse (0.0) [1:3] - ├─ [1]: 20.0 - └─ [3]: 40.0 +3×3-Tensor +└─ Sparse (0.0) [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:3] + │ ├─ [1]: 10.0 + │ └─ [2]: 30.0 + └─ [:, 3]: Sparse (0.0) [1:3] + ├─ [1]: 20.0 + └─ [3]: 40.0 ``` """ diff --git a/src/tensors/levels/sparse_list_levels.jl b/src/tensors/levels/sparse_list_levels.jl index d0a18fbcc..3281bdfee 100644 --- a/src/tensors/levels/sparse_list_levels.jl +++ b/src/tensors/levels/sparse_list_levels.jl @@ -12,23 +12,25 @@ arrays used to store positions and indicies. ```jldoctest julia> Tensor(Dense(SparseList(Element(0.0))), [10 0 20; 30 0 0; 0 0 40]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:3] -│ ├─ [1]: 10.0 -│ └─ [2]: 30.0 -├─ [:, 2]: SparseList (0.0) [1:3] -└─ [:, 3]: SparseList (0.0) [1:3] - ├─ [1]: 20.0 - └─ [3]: 40.0 +3×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:3] + │ ├─ [1]: 10.0 + │ └─ [2]: 30.0 + ├─ [:, 2]: SparseList (0.0) [1:3] + └─ [:, 3]: SparseList (0.0) [1:3] + ├─ [1]: 20.0 + └─ [3]: 40.0 julia> Tensor(SparseList(SparseList(Element(0.0))), [10 0 20; 30 0 0; 0 0 40]) -SparseList (0.0) [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:3] -│ ├─ [1]: 10.0 -│ └─ [2]: 30.0 -└─ [:, 3]: SparseList (0.0) [1:3] - ├─ [1]: 20.0 - └─ [3]: 40.0 +3×3-Tensor +└─ SparseList (0.0) [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:3] + │ ├─ [1]: 10.0 + │ └─ [2]: 30.0 + └─ [:, 3]: SparseList (0.0) [1:3] + ├─ [1]: 20.0 + └─ [3]: 40.0 ``` """ diff --git a/src/tensors/levels/sparse_point_levels.jl b/src/tensors/levels/sparse_point_levels.jl index 7cbef63f3..c4a1c590f 100644 --- a/src/tensors/levels/sparse_point_levels.jl +++ b/src/tensors/levels/sparse_point_levels.jl @@ -12,13 +12,14 @@ types of the arrays used to store positions and indicies. ```jldoctest julia> Tensor(Dense(SparsePoint(Element(0.0))), [10 0 0; 0 20 0; 0 0 30]) -Dense [:,1:3] -├─ [:, 1]: SparsePoint (0.0) [1:3] -│ └─ 10.0 -├─ [:, 2]: SparsePoint (0.0) [1:3] -│ └─ 20.0 -└─ [:, 3]: SparsePoint (0.0) [1:3] - └─ 30.0 +3×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparsePoint (0.0) [1:3] + │ └─ 10.0 + ├─ [:, 2]: SparsePoint (0.0) [1:3] + │ └─ 20.0 + └─ [:, 3]: SparsePoint (0.0) [1:3] + └─ 30.0 julia> Tensor(Dense(SparsePoint(Element(0.0))), [10 0 0; 0 20 0; 0 40 30]) ERROR: Finch.FinchProtocolError("SparsePointLevels can only be updated once") diff --git a/src/tensors/levels/sparse_rle_levels.jl b/src/tensors/levels/sparse_rle_levels.jl index aacf36997..f3d6f165f 100644 --- a/src/tensors/levels/sparse_rle_levels.jl +++ b/src/tensors/levels/sparse_rle_levels.jl @@ -14,14 +14,15 @@ duplicate consecutive runs. ```jldoctest julia> Tensor(Dense(SparseRLELevel(Element(0.0))), [10 0 20; 30 0 0; 0 0 40]) -Dense [:,1:3] -├─ [:, 1]: SparseRLE (0.0) [1:3] -│ ├─ [1:1]: 10.0 -│ └─ [2:2]: 30.0 -├─ [:, 2]: SparseRLE (0.0) [1:3] -└─ [:, 3]: SparseRLE (0.0) [1:3] - ├─ [1:1]: 20.0 - └─ [3:3]: 40.0 +3×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseRLE (0.0) [1:3] + │ ├─ [1:1]: 10.0 + │ └─ [2:2]: 30.0 + ├─ [:, 2]: SparseRLE (0.0) [1:3] + └─ [:, 3]: SparseRLE (0.0) [1:3] + ├─ [1:1]: 20.0 + └─ [3:3]: 40.0 ``` """ struct SparseRLELevel{Ti, Ptr<:AbstractVector, Left<:AbstractVector, Right<:AbstractVector, merge, Lvl} <: AbstractLevel From 73f2980804850e43c5a56522393280d29152d862 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Sat, 18 May 2024 11:31:50 -0400 Subject: [PATCH 15/22] remove needless swizzles --- test/reference64/interface/asmd.txt | 189 +++++++++++------------ test/reference64/interface/broadcast.txt | 41 +++-- test/reference64/interface/reduce.txt | 53 +++---- test/test_interface.jl | 2 +- 4 files changed, 136 insertions(+), 149 deletions(-) diff --git a/test/reference64/interface/asmd.txt b/test/reference64/interface/asmd.txt index 857c9d492..bdf9ef0d7 100644 --- a/test/reference64/interface/asmd.txt +++ b/test/reference64/interface/asmd.txt @@ -12,115 +12,108 @@ julia> A = Tensor(Dense(SparseList(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2. └─ [3]: 5.5 julia> A + 1 -SwizzleArray (1, 2) -└─ 4×3-Tensor - └─ Dense [:,1:3] - ├─ [:, 1]: Dense [1:4] - │ ├─ [1]: 1.0 - │ ├─ [2]: 2.1 - │ ├─ [3]: 3.2 - │ └─ [4]: 4.3 - ├─ [:, 2]: Dense [1:4] - │ ├─ [1]: 1.0 - │ ├─ [2]: 1.0 - │ ├─ [3]: 1.0 - │ └─ [4]: 1.0 - └─ [:, 3]: Dense [1:4] - ├─ [1]: 5.4 - ├─ [2]: 1.0 - ├─ [3]: 6.5 - └─ [4]: 1.0 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.1 + │ ├─ [3]: 3.2 + │ └─ [4]: 4.3 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: 1.0 + │ ├─ [2]: 1.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 1.0 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 5.4 + ├─ [2]: 1.0 + ├─ [3]: 6.5 + └─ [4]: 1.0 julia> 1 + A -SwizzleArray (1, 2) -└─ 4×3-Tensor - └─ Dense [:,1:3] - ├─ [:, 1]: Dense [1:4] - │ ├─ [1]: 1.0 - │ ├─ [2]: 2.1 - │ ├─ [3]: 3.2 - │ └─ [4]: 4.3 - ├─ [:, 2]: Dense [1:4] - │ ├─ [1]: 1.0 - │ ├─ [2]: 1.0 - │ ├─ [3]: 1.0 - │ └─ [4]: 1.0 - └─ [:, 3]: Dense [1:4] - ├─ [1]: 5.4 - ├─ [2]: 1.0 - ├─ [3]: 6.5 - └─ [4]: 1.0 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.1 + │ ├─ [3]: 3.2 + │ └─ [4]: 4.3 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: 1.0 + │ ├─ [2]: 1.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 1.0 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 5.4 + ├─ [2]: 1.0 + ├─ [3]: 6.5 + └─ [4]: 1.0 julia> A + A -SwizzleArray (1, 2) -└─ 4×3-Tensor - └─ Dense [:,1:3] - ├─ [:, 1]: Sparse (0.0) [1:4] - │ ├─ [2]: 2.2 - │ ├─ [3]: 4.4 - │ └─ [4]: 6.6 - ├─ [:, 2]: Sparse (0.0) [1:4] - └─ [:, 3]: Sparse (0.0) [1:4] - ├─ [1]: 8.8 - └─ [3]: 11.0 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:4] + │ ├─ [2]: 2.2 + │ ├─ [3]: 4.4 + │ └─ [4]: 6.6 + ├─ [:, 2]: Sparse (0.0) [1:4] + └─ [:, 3]: Sparse (0.0) [1:4] + ├─ [1]: 8.8 + └─ [3]: 11.0 julia> 2A -SwizzleArray (1, 2) -└─ 4×3-Tensor - └─ Dense [:,1:3] - ├─ [:, 1]: Sparse (0.0) [1:4] - │ ├─ [2]: 2.2 - │ ├─ [3]: 4.4 - │ └─ [4]: 6.6 - ├─ [:, 2]: Sparse (0.0) [1:4] - └─ [:, 3]: Sparse (0.0) [1:4] - ├─ [1]: 8.8 - └─ [3]: 11.0 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:4] + │ ├─ [2]: 2.2 + │ ├─ [3]: 4.4 + │ └─ [4]: 6.6 + ├─ [:, 2]: Sparse (0.0) [1:4] + └─ [:, 3]: Sparse (0.0) [1:4] + ├─ [1]: 8.8 + └─ [3]: 11.0 julia> A * 3 -SwizzleArray (1, 2) -└─ 4×3-Tensor - └─ Dense [:,1:3] - ├─ [:, 1]: Sparse (0.0) [1:4] - │ ├─ [2]: 3.3 - │ ├─ [3]: 6.6 - │ └─ [4]: 9.9 - ├─ [:, 2]: Sparse (0.0) [1:4] - └─ [:, 3]: Sparse (0.0) [1:4] - ├─ [1]: 13.2 - └─ [3]: 16.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:4] + │ ├─ [2]: 3.3 + │ ├─ [3]: 6.6 + │ └─ [4]: 9.9 + ├─ [:, 2]: Sparse (0.0) [1:4] + └─ [:, 3]: Sparse (0.0) [1:4] + ├─ [1]: 13.2 + └─ [3]: 16.5 julia> A / 3 -SwizzleArray (1, 2) -└─ 4×3-Tensor - └─ Dense [:,1:3] - ├─ [:, 1]: Sparse (0.0) [1:4] - │ ├─ [2]: 0.366667 - │ ├─ [3]: 0.733333 - │ └─ [4]: 1.1 - ├─ [:, 2]: Sparse (0.0) [1:4] - └─ [:, 3]: Sparse (0.0) [1:4] - ├─ [1]: 1.46667 - └─ [3]: 1.83333 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:4] + │ ├─ [2]: 0.366667 + │ ├─ [3]: 0.733333 + │ └─ [4]: 1.1 + ├─ [:, 2]: Sparse (0.0) [1:4] + └─ [:, 3]: Sparse (0.0) [1:4] + ├─ [1]: 1.46667 + └─ [3]: 1.83333 julia> 3 / A -SwizzleArray (1, 2) -└─ 4×3-Tensor - └─ Dense [:,1:3] - ├─ [:, 1]: Dense [1:4] - │ ├─ [1]: Inf - │ ├─ [2]: 2.72727 - │ ├─ [3]: 1.36364 - │ └─ [4]: 0.909091 - ├─ [:, 2]: Dense [1:4] - │ ├─ [1]: Inf - │ ├─ [2]: Inf - │ ├─ [3]: Inf - │ └─ [4]: Inf - └─ [:, 3]: Dense [1:4] - ├─ [1]: 0.681818 - ├─ [2]: Inf - ├─ [3]: 0.545455 - └─ [4]: Inf +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: Inf + │ ├─ [2]: 2.72727 + │ ├─ [3]: 1.36364 + │ └─ [4]: 0.909091 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: Inf + │ ├─ [2]: Inf + │ ├─ [3]: Inf + │ └─ [4]: Inf + └─ [:, 3]: Dense [1:4] + ├─ [1]: 0.681818 + ├─ [2]: Inf + ├─ [3]: 0.545455 + └─ [4]: Inf diff --git a/test/reference64/interface/broadcast.txt b/test/reference64/interface/broadcast.txt index cfc41868e..0b95573e2 100644 --- a/test/reference64/interface/broadcast.txt +++ b/test/reference64/interface/broadcast.txt @@ -20,7 +20,7 @@ julia> B = [1, 2, 3, 4] julia> C = A .+ B julia> AsArray(C) -4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}: +4×3 Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}: 1.0 1.0 5.4 3.1 2.0 2.0 5.2 3.0 8.5 @@ -28,33 +28,32 @@ julia> AsArray(C) julia> D = A .* B julia> AsArray(D) -4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int64, SparseLevel{Int64, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}: +4×3 Tensor{DenseLevel{Int64, SparseLevel{Int64, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}: 0.0 0.0 4.4 2.2 0.0 0.0 6.6 0.0 16.5 13.2 0.0 0.0 julia> E = ifelse.(A .== 0, 1, 2) -SwizzleArray (1, 2) -└─ 4×3-Tensor - └─ Dense [:,1:3] - ├─ [:, 1]: Dense [1:4] - │ ├─ [1]: 1 - │ ├─ [2]: 2 - │ ├─ [3]: 2 - │ └─ [4]: 2 - ├─ [:, 2]: Dense [1:4] - │ ├─ [1]: 1 - │ ├─ [2]: 1 - │ ├─ [3]: 1 - │ └─ [4]: 1 - └─ [:, 3]: Dense [1:4] - ├─ [1]: 2 - ├─ [2]: 1 - ├─ [3]: 2 - └─ [4]: 1 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 1 + │ ├─ [2]: 2 + │ ├─ [3]: 2 + │ └─ [4]: 2 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: 1 + │ ├─ [2]: 1 + │ ├─ [3]: 1 + │ └─ [4]: 1 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 2 + ├─ [2]: 1 + ├─ [3]: 2 + └─ [4]: 1 julia> AsArray(E) -4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{1, Int64, Int64, Vector{Int64}}}}}}: +4×3 Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{1, Int64, Int64, Vector{Int64}}}}}: 1 1 2 2 1 1 2 1 2 diff --git a/test/reference64/interface/reduce.txt b/test/reference64/interface/reduce.txt index fba13b204..619cca315 100644 --- a/test/reference64/interface/reduce.txt +++ b/test/reference64/interface/reduce.txt @@ -12,43 +12,38 @@ julia> A = Tensor(Dense(SparseList(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2. └─ [3]: 5.5 julia> reduce(+, A, dims = (1,)) -SwizzleArray (1) -└─ 3-Tensor - └─ Dense [1:3] - ├─ [1]: 6.6 - ├─ [2]: 0.0 - └─ [3]: 9.9 +3-Tensor +└─ Dense [1:3] + ├─ [1]: 6.6 + ├─ [2]: 0.0 + └─ [3]: 9.9 julia> reduce(+, A, dims = 1) -SwizzleArray (1) -└─ 3-Tensor - └─ Dense [1:3] - ├─ [1]: 6.6 - ├─ [2]: 0.0 - └─ [3]: 9.9 +3-Tensor +└─ Dense [1:3] + ├─ [1]: 6.6 + ├─ [2]: 0.0 + └─ [3]: 9.9 julia> reduce(+, A, dims = (2,)) -SwizzleArray (1) -└─ 4-Tensor - └─ Sparse (0.0) [1:4] - ├─ [1]: 4.4 - ├─ [2]: 1.1 - ├─ [3]: 7.7 - └─ [4]: 3.3 +4-Tensor +└─ Sparse (0.0) [1:4] + ├─ [1]: 4.4 + ├─ [2]: 1.1 + ├─ [3]: 7.7 + └─ [4]: 3.3 julia> reduce(+, A, dims = 2) -SwizzleArray (1) -└─ 4-Tensor - └─ Sparse (0.0) [1:4] - ├─ [1]: 4.4 - ├─ [2]: 1.1 - ├─ [3]: 7.7 - └─ [4]: 3.3 +4-Tensor +└─ Sparse (0.0) [1:4] + ├─ [1]: 4.4 + ├─ [2]: 1.1 + ├─ [3]: 7.7 + └─ [4]: 3.3 julia> reduce(+, A, dims = (1, 2)) -SwizzleArray () -└─ -Tensor - └─ 16.5 +-Tensor +└─ 16.5 julia> reduce(+, A, dims = (:)) 16.5 diff --git a/test/test_interface.jl b/test/test_interface.jl index d4c4c5385..82299e581 100644 --- a/test/test_interface.jl +++ b/test/test_interface.jl @@ -4,7 +4,7 @@ using Finch: AsArray @info "Testing Finch Interface" - for scheduler in [Finch.default_scheduler(verbose=true), Finch.DefaultLogicOptimizer(Finch.LogicInterpreter())] + for scheduler in [Finch.default_scheduler(), Finch.DefaultLogicOptimizer(Finch.LogicInterpreter())] Finch.with_scheduler(scheduler) do @info "Testing $scheduler" From acc8891ee332decd7dc2abe0342a5d06f52bee1f Mon Sep 17 00:00:00 2001 From: Willow Bot Date: Sat, 18 May 2024 15:53:57 +0000 Subject: [PATCH 16/22] Regenerate test output --- docs/src/guides/array_api.md | 129 +++++++++++++++----------------- docs/src/guides/sparse_utils.md | 56 +++++++------- docs/src/interactive.ipynb | 6 +- 3 files changed, 92 insertions(+), 99 deletions(-) diff --git a/docs/src/guides/array_api.md b/docs/src/guides/array_api.md index 52bfc384c..05b780d83 100644 --- a/docs/src/guides/array_api.md +++ b/docs/src/guides/array_api.md @@ -17,59 +17,56 @@ julia> A = fsparse([1, 1, 2, 3], [2, 4, 5, 6], [1.0, 2.0, 3.0]) └─ [2, 5]: 3.0 julia> A + 0 -SwizzleArray (1, 2) -└─ 3×6-Tensor - └─ Dense [:,1:6] - ├─ [:, 1]: Dense [1:3] - │ ├─ [1]: 0.0 - │ ├─ [2]: 0.0 - │ └─ [3]: 0.0 - ├─ [:, 2]: Dense [1:3] - │ ├─ [1]: 1.0 - │ ├─ [2]: 0.0 - │ └─ [3]: 0.0 - ├─ ⋮ - ├─ [:, 5]: Dense [1:3] - │ ├─ [1]: 0.0 - │ ├─ [2]: 3.0 - │ └─ [3]: 0.0 - └─ [:, 6]: Dense [1:3] - ├─ [1]: 0.0 - ├─ [2]: 0.0 - └─ [3]: 0.0 +3×6-Tensor +└─ Dense [:,1:6] + ├─ [:, 1]: Dense [1:3] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ └─ [3]: 0.0 + ├─ [:, 2]: Dense [1:3] + │ ├─ [1]: 1.0 + │ ├─ [2]: 0.0 + │ └─ [3]: 0.0 + ├─ ⋮ + ├─ [:, 5]: Dense [1:3] + │ ├─ [1]: 0.0 + │ ├─ [2]: 3.0 + │ └─ [3]: 0.0 + └─ [:, 6]: Dense [1:3] + ├─ [1]: 0.0 + ├─ [2]: 0.0 + └─ [3]: 0.0 julia> A + 1 -SwizzleArray (1, 2) -└─ 3×6-Tensor - └─ Dense [:,1:6] - ├─ [:, 1]: Dense [1:3] - │ ├─ [1]: 1.0 - │ ├─ [2]: 1.0 - │ └─ [3]: 1.0 - ├─ [:, 2]: Dense [1:3] - │ ├─ [1]: 2.0 - │ ├─ [2]: 1.0 - │ └─ [3]: 1.0 - ├─ ⋮ - ├─ [:, 5]: Dense [1:3] - │ ├─ [1]: 1.0 - │ ├─ [2]: 4.0 - │ └─ [3]: 1.0 - └─ [:, 6]: Dense [1:3] - ├─ [1]: 1.0 - ├─ [2]: 1.0 - └─ [3]: 1.0 +3×6-Tensor +└─ Dense [:,1:6] + ├─ [:, 1]: Dense [1:3] + │ ├─ [1]: 1.0 + │ ├─ [2]: 1.0 + │ └─ [3]: 1.0 + ├─ [:, 2]: Dense [1:3] + │ ├─ [1]: 2.0 + │ ├─ [2]: 1.0 + │ └─ [3]: 1.0 + ├─ ⋮ + ├─ [:, 5]: Dense [1:3] + │ ├─ [1]: 1.0 + │ ├─ [2]: 4.0 + │ └─ [3]: 1.0 + └─ [:, 6]: Dense [1:3] + ├─ [1]: 1.0 + ├─ [2]: 1.0 + └─ [3]: 1.0 julia> B = A .* 2 -SwizzleArray (1, 2) -└─ 3×6-Tensor - └─ Sparse (0.0) [:,1:6] - ├─ [:, 2]: Sparse (0.0) [1:3] - │ └─ [1]: 2.0 - ├─ [:, 4]: Sparse (0.0) [1:3] - │ └─ [1]: 4.0 - └─ [:, 5]: Sparse (0.0) [1:3] - └─ [2]: 6.0 +3×6-Tensor +└─ Sparse (0.0) [:,1:6] + ├─ [:, 2]: Sparse (0.0) [1:3] + │ └─ [1]: 2.0 + ├─ [:, 4]: Sparse (0.0) [1:3] + │ └─ [1]: 4.0 + └─ [:, 5]: Sparse (0.0) [1:3] + └─ [2]: 6.0 julia> B[1:2, 1:2] 2×2-Tensor @@ -78,15 +75,14 @@ julia> B[1:2, 1:2] └─ [1]: 2.0 julia> map(x -> x^2, B) -SwizzleArray (1, 2) -└─ 3×6-Tensor - └─ Sparse (0.0) [:,1:6] - ├─ [:, 2]: Sparse (0.0) [1:3] - │ └─ [1]: 4.0 - ├─ [:, 4]: Sparse (0.0) [1:3] - │ └─ [1]: 16.0 - └─ [:, 5]: Sparse (0.0) [1:3] - └─ [2]: 36.0 +3×6-Tensor +└─ Sparse (0.0) [:,1:6] + ├─ [:, 2]: Sparse (0.0) [1:3] + │ └─ [1]: 4.0 + ├─ [:, 4]: Sparse (0.0) [1:3] + │ └─ [1]: 16.0 + └─ [:, 5]: Sparse (0.0) [1:3] + └─ [2]: 36.0 ``` # Array Fusion @@ -106,15 +102,14 @@ julia> D = lazy(B); julia> E = (C .+ D)/2; julia> compute(E) -SwizzleArray (1, 2) -└─ 3×6-Tensor - └─ Sparse (0.0) [:,1:6] - ├─ [:, 2]: Sparse (0.0) [1:3] - │ └─ [1]: 1.5 - ├─ [:, 4]: Sparse (0.0) [1:3] - │ └─ [1]: 3.0 - └─ [:, 5]: Sparse (0.0) [1:3] - └─ [2]: 4.5 +3×6-Tensor +└─ Sparse (0.0) [:,1:6] + ├─ [:, 2]: Sparse (0.0) [1:3] + │ └─ [1]: 1.5 + ├─ [:, 4]: Sparse (0.0) [1:3] + │ └─ [1]: 3.0 + └─ [:, 5]: Sparse (0.0) [1:3] + └─ [2]: 4.5 ``` diff --git a/docs/src/guides/sparse_utils.md b/docs/src/guides/sparse_utils.md index 743dcb0fe..8e33beaa6 100644 --- a/docs/src/guides/sparse_utils.md +++ b/docs/src/guides/sparse_utils.md @@ -28,26 +28,25 @@ julia> A = fsparse([1, 1, 2, 3], [2, 4, 5, 6], [1.0, 2.0, 3.0]) └─ [2, 5]: 3.0 julia> min.(A, -1) -SwizzleArray (1, 2) -└─ 3×6-Tensor - └─ Dense [:,1:6] - ├─ [:, 1]: Dense [1:3] - │ ├─ [1]: -1.0 - │ ├─ [2]: -1.0 - │ └─ [3]: -1.0 - ├─ [:, 2]: Dense [1:3] - │ ├─ [1]: -1.0 - │ ├─ [2]: -1.0 - │ └─ [3]: -1.0 - ├─ ⋮ - ├─ [:, 5]: Dense [1:3] - │ ├─ [1]: -1.0 - │ ├─ [2]: -1.0 - │ └─ [3]: -1.0 - └─ [:, 6]: Dense [1:3] - ├─ [1]: -1.0 - ├─ [2]: -1.0 - └─ [3]: -1.0 +3×6-Tensor +└─ Dense [:,1:6] + ├─ [:, 1]: Dense [1:3] + │ ├─ [1]: -1.0 + │ ├─ [2]: -1.0 + │ └─ [3]: -1.0 + ├─ [:, 2]: Dense [1:3] + │ ├─ [1]: -1.0 + │ ├─ [2]: -1.0 + │ └─ [3]: -1.0 + ├─ ⋮ + ├─ [:, 5]: Dense [1:3] + │ ├─ [1]: -1.0 + │ ├─ [2]: -1.0 + │ └─ [3]: -1.0 + └─ [:, 6]: Dense [1:3] + ├─ [1]: -1.0 + ├─ [2]: -1.0 + └─ [3]: -1.0 julia> fill_value(A) 0.0 @@ -60,15 +59,14 @@ julia> B = set_fill_value!(A, -Inf) └─ [2, 5]: 3.0 julia> min.(B, -1) -SwizzleArray (1, 2) -└─ 3×6-Tensor - └─ Sparse (-Inf) [:,1:6] - ├─ [:, 2]: Sparse (-Inf) [1:3] - │ └─ [1]: -1.0 - ├─ [:, 4]: Sparse (-Inf) [1:3] - │ └─ [1]: -1.0 - └─ [:, 5]: Sparse (-Inf) [1:3] - └─ [2]: -1.0 +3×6-Tensor +└─ Sparse (-Inf) [:,1:6] + ├─ [:, 2]: Sparse (-Inf) [1:3] + │ └─ [1]: -1.0 + ├─ [:, 4]: Sparse (-Inf) [1:3] + │ └─ [1]: -1.0 + └─ [:, 5]: Sparse (-Inf) [1:3] + └─ [2]: -1.0 julia> countstored(A) 3 diff --git a/docs/src/interactive.ipynb b/docs/src/interactive.ipynb index afaf3c67d..dcb87347c 100644 --- a/docs/src/interactive.ipynb +++ b/docs/src/interactive.ipynb @@ -49,11 +49,11 @@ "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.10.3" + "version": "1.6.7" }, "kernelspec": { - "name": "julia-1.10", - "display_name": "Julia 1.10.3", + "name": "julia-1.6", + "display_name": "Julia 1.6.7", "language": "julia" } }, From 5fad6bd760222510ffedc77a34a0b9a8342c45b6 Mon Sep 17 00:00:00 2001 From: Willow Bot Date: Sat, 18 May 2024 16:09:02 +0000 Subject: [PATCH 17/22] Regenerate test output --- test/reference32/index/chunkmask.txt | 135 +++-------- test/reference32/interface/asmd.txt | 124 ++++++++-- test/reference32/interface/broadcast.txt | 44 +++- test/reference32/interface/countstored.txt | 88 +++---- test/reference32/interface/getindex.txt | 229 +++++++++--------- test/reference32/interface/reduce.txt | 53 ++-- test/reference32/interface/setindex.txt | 160 +++--------- test/reference32/print/display_byte_dense.txt | 88 +++---- test/reference32/print/display_coo1_dense.txt | 88 +++---- test/reference32/print/display_coo2.txt | 41 +--- test/reference32/print/display_dense_byte.txt | 64 ++--- test/reference32/print/display_dense_coo1.txt | 64 ++--- test/reference32/print/display_dense_dict.txt | 64 ++--- .../reference32/print/display_dense_hash1.txt | 64 ++--- test/reference32/print/display_dense_list.txt | 64 ++--- test/reference32/print/display_dict_dense.txt | 88 +++---- .../reference32/print/display_hash1_dense.txt | 88 +++---- test/reference32/print/display_hash2.txt | 41 +--- test/reference32/print/display_list_dense.txt | 88 +++---- .../typical/typical_inplace_sparse_add.txt | 31 ++- test/reference32/typical/typical_spmv_csc.txt | 39 +-- .../typical/typical_stats_example.txt | 13 +- .../typical/typical_transpose_csc_to_coo.txt | 22 +- 23 files changed, 713 insertions(+), 1067 deletions(-) diff --git a/test/reference32/index/chunkmask.txt b/test/reference32/index/chunkmask.txt index 662a627b3..3e8fede77 100644 --- a/test/reference32/index/chunkmask.txt +++ b/test/reference32/index/chunkmask.txt @@ -1,54 +1,25 @@ chunkmask tests julia> A = Tensor(Dense(Dense(Element(0.0))), 15, 3) -Dense [:,1:3] -├─ [:, 1]: Dense [1:15] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ ├─ [10]: 0.0 -│ ├─ [11]: 0.0 -│ ├─ [12]: 0.0 -│ ├─ [13]: 0.0 -│ ├─ [14]: 0.0 -│ └─ [15]: 0.0 -├─ [:, 2]: Dense [1:15] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ ├─ [10]: 0.0 -│ ├─ [11]: 0.0 -│ ├─ [12]: 0.0 -│ ├─ [13]: 0.0 -│ ├─ [14]: 0.0 -│ └─ [15]: 0.0 -└─ [:, 3]: Dense [1:15] - ├─ [1]: 0.0 - ├─ [2]: 0.0 - ├─ [3]: 0.0 - ├─ [4]: 0.0 - ├─ [5]: 0.0 - ├─ [6]: 0.0 - ├─ [7]: 0.0 - ├─ [8]: 0.0 - ├─ [9]: 0.0 - ├─ [10]: 0.0 - ├─ [11]: 0.0 - ├─ [12]: 0.0 - ├─ [13]: 0.0 - ├─ [14]: 0.0 - └─ [15]: 0.0 +15×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:15] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [14]: 0.0 + │ └─ [15]: 0.0 + ├─ [:, 2]: Dense [1:15] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [14]: 0.0 + │ └─ [15]: 0.0 + └─ [:, 3]: Dense [1:15] + ├─ [1]: 0.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [14]: 0.0 + └─ [15]: 0.0 julia> @finch begin let m = Finch.chunkmask(5, 1:15) @@ -78,52 +49,26 @@ julia> AsArray(A) 0.0 0.0 1.0 0.0 0.0 1.0 julia> A = Tensor(Dense(Dense(Element(0.0))), 14, 3) -Dense [:,1:3] -├─ [:, 1]: Dense [1:14] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ ├─ [10]: 0.0 -│ ├─ [11]: 0.0 -│ ├─ [12]: 0.0 -│ ├─ [13]: 0.0 -│ └─ [14]: 0.0 -├─ [:, 2]: Dense [1:14] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ ├─ [10]: 0.0 -│ ├─ [11]: 0.0 -│ ├─ [12]: 0.0 -│ ├─ [13]: 0.0 -│ └─ [14]: 0.0 -└─ [:, 3]: Dense [1:14] - ├─ [1]: 0.0 - ├─ [2]: 0.0 - ├─ [3]: 0.0 - ├─ [4]: 0.0 - ├─ [5]: 0.0 - ├─ [6]: 0.0 - ├─ [7]: 0.0 - ├─ [8]: 0.0 - ├─ [9]: 0.0 - ├─ [10]: 0.0 - ├─ [11]: 0.0 - ├─ [12]: 0.0 - ├─ [13]: 0.0 - └─ [14]: 0.0 +14×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:14] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [13]: 0.0 + │ └─ [14]: 0.0 + ├─ [:, 2]: Dense [1:14] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [13]: 0.0 + │ └─ [14]: 0.0 + └─ [:, 3]: Dense [1:14] + ├─ [1]: 0.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [13]: 0.0 + └─ [14]: 0.0 julia> @finch begin let m = Finch.chunkmask(5, 1:14) diff --git a/test/reference32/interface/asmd.txt b/test/reference32/interface/asmd.txt index 0d56d01af..bdf9ef0d7 100644 --- a/test/reference32/interface/asmd.txt +++ b/test/reference32/interface/asmd.txt @@ -1,27 +1,119 @@ +,-, *, / tests julia> A = Tensor(Dense(SparseList(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 4.4 - └─ [3]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 4.4 + └─ [3]: 5.5 julia> A + 1 -SwizzleArray(Tensor(Dense{Int32}(Dense{Int32}(Element{1.0, Float64, Int32}([1.0, 2.1, 3.2, 4.3, 1.0, 1.0, 1.0, 1.0, 5.4, 1.0, 6.5, 1.0]), 4), 3)), (1, 2)) +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.1 + │ ├─ [3]: 3.2 + │ └─ [4]: 4.3 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: 1.0 + │ ├─ [2]: 1.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 1.0 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 5.4 + ├─ [2]: 1.0 + ├─ [3]: 6.5 + └─ [4]: 1.0 + julia> 1 + A -SwizzleArray(Tensor(Dense{Int32}(Dense{Int32}(Element{1.0, Float64, Int32}([1.0, 2.1, 3.2, 4.3, 1.0, 1.0, 1.0, 1.0, 5.4, 1.0, 6.5, 1.0]), 4), 3)), (1, 2)) +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.1 + │ ├─ [3]: 3.2 + │ └─ [4]: 4.3 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: 1.0 + │ ├─ [2]: 1.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 1.0 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 5.4 + ├─ [2]: 1.0 + ├─ [3]: 6.5 + └─ [4]: 1.0 + julia> A + A -SwizzleArray(Tensor(Dense{Int32}(Sparse{Int32}(Element{0.0, Float64, Int32}([2.2, 4.4, 6.6, 8.8, 11.0]), 4, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (1, 4) => 3, (1, 3) => 2, (3, 1) => 4, (3, 3) => 5))), 3)), (1, 2)) +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:4] + │ ├─ [2]: 2.2 + │ ├─ [3]: 4.4 + │ └─ [4]: 6.6 + ├─ [:, 2]: Sparse (0.0) [1:4] + └─ [:, 3]: Sparse (0.0) [1:4] + ├─ [1]: 8.8 + └─ [3]: 11.0 + julia> 2A -SwizzleArray(Tensor(Dense{Int32}(Sparse{Int32}(Element{0.0, Float64, Int32}([2.2, 4.4, 6.6, 8.8, 11.0]), 4, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (1, 4) => 3, (1, 3) => 2, (3, 1) => 4, (3, 3) => 5))), 3)), (1, 2)) +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:4] + │ ├─ [2]: 2.2 + │ ├─ [3]: 4.4 + │ └─ [4]: 6.6 + ├─ [:, 2]: Sparse (0.0) [1:4] + └─ [:, 3]: Sparse (0.0) [1:4] + ├─ [1]: 8.8 + └─ [3]: 11.0 + julia> A * 3 -SwizzleArray(Tensor(Dense{Int32}(Sparse{Int32}(Element{0.0, Float64, Int32}([3.3000000000000003, 6.6000000000000005, 9.899999999999999, 13.200000000000001, 16.5]), 4, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (1, 4) => 3, (1, 3) => 2, (3, 1) => 4, (3, 3) => 5))), 3)), (1, 2)) +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:4] + │ ├─ [2]: 3.3 + │ ├─ [3]: 6.6 + │ └─ [4]: 9.9 + ├─ [:, 2]: Sparse (0.0) [1:4] + └─ [:, 3]: Sparse (0.0) [1:4] + ├─ [1]: 13.2 + └─ [3]: 16.5 + julia> A / 3 -SwizzleArray(Tensor(Dense{Int32}(Sparse{Int32}(Element{0.0, Float64, Int32}([0.3666666666666667, 0.7333333333333334, 1.0999999999999999, 1.4666666666666668, 1.8333333333333333]), 4, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}([1, 4, 4, 6], [2, 3, 4, 1, 3], [1, 2, 3, 4, 5], Dict((1, 2) => 1, (1, 4) => 3, (1, 3) => 2, (3, 1) => 4, (3, 3) => 5))), 3)), (1, 2)) +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:4] + │ ├─ [2]: 0.366667 + │ ├─ [3]: 0.733333 + │ └─ [4]: 1.1 + ├─ [:, 2]: Sparse (0.0) [1:4] + └─ [:, 3]: Sparse (0.0) [1:4] + ├─ [1]: 1.46667 + └─ [3]: 1.83333 + julia> 3 / A -SwizzleArray(Tensor(Dense{Int32}(Dense{Int32}(Element{Inf, Float64, Int32}([Inf, 2.727272727272727, 1.3636363636363635, 0.9090909090909092, Inf, Inf, Inf, Inf, 0.6818181818181818, Inf, 0.5454545454545454, Inf]), 4), 3)), (1, 2)) +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: Inf + │ ├─ [2]: 2.72727 + │ ├─ [3]: 1.36364 + │ └─ [4]: 0.909091 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: Inf + │ ├─ [2]: Inf + │ ├─ [3]: Inf + │ └─ [4]: Inf + └─ [:, 3]: Dense [1:4] + ├─ [1]: 0.681818 + ├─ [2]: Inf + ├─ [3]: 0.545455 + └─ [4]: Inf + diff --git a/test/reference32/interface/broadcast.txt b/test/reference32/interface/broadcast.txt index c18dbdd12..9c5656554 100644 --- a/test/reference32/interface/broadcast.txt +++ b/test/reference32/interface/broadcast.txt @@ -1,14 +1,15 @@ broadcast tests julia> A = Tensor(Dense(SparseList(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 4.4 - └─ [3]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 4.4 + └─ [3]: 5.5 julia> B = [1, 2, 3, 4] 4-element Vector{Int32}: @@ -19,7 +20,7 @@ julia> B = [1, 2, 3, 4] julia> C = A .+ B julia> AsArray(C) -4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int32, DenseLevel{Int32, ElementLevel{0.0, Float64, Int32, Vector{Float64}}}}}}: +4×3 Tensor{DenseLevel{Int32, DenseLevel{Int32, ElementLevel{0.0, Float64, Int32, Vector{Float64}}}}}: 1.0 1.0 5.4 3.1 2.0 2.0 5.2 3.0 8.5 @@ -27,15 +28,32 @@ julia> AsArray(C) julia> D = A .* B julia> AsArray(D) -4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int32, SparseLevel{Int32, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}, ElementLevel{0.0, Float64, Int32, Vector{Float64}}}}}}: +4×3 Tensor{DenseLevel{Int32, SparseLevel{Int32, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}, ElementLevel{0.0, Float64, Int32, Vector{Float64}}}}}: 0.0 0.0 4.4 2.2 0.0 0.0 6.6 0.0 16.5 13.2 0.0 0.0 julia> E = ifelse.(A .== 0, 1, 2) -SwizzleArray(Tensor(Dense{Int32}(Dense{Int32}(Element{1, Int32, Int32}([1, 2, 2, 2, 1, 1, 1, 1, 2, 1, 2, 1]), 4), 3)), (1, 2)) +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 1 + │ ├─ [2]: 2 + │ ├─ [3]: 2 + │ └─ [4]: 2 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: 1 + │ ├─ [2]: 1 + │ ├─ [3]: 1 + │ └─ [4]: 1 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 2 + ├─ [2]: 1 + ├─ [3]: 2 + └─ [4]: 1 + julia> AsArray(E) -4×3 Finch.SwizzleArray{(1, 2), Tensor{DenseLevel{Int32, DenseLevel{Int32, ElementLevel{1, Int32, Int32, Vector{Int32}}}}}}: +4×3 Tensor{DenseLevel{Int32, DenseLevel{Int32, ElementLevel{1, Int32, Int32, Vector{Int32}}}}}: 1 1 2 2 1 1 2 1 2 diff --git a/test/reference32/interface/countstored.txt b/test/reference32/interface/countstored.txt index 803c74ef3..d8e284c8c 100644 --- a/test/reference32/interface/countstored.txt +++ b/test/reference32/interface/countstored.txt @@ -1,59 +1,63 @@ countstored tests julia> A = Tensor(Dense(SparseList(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 4.4 - └─ [3]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 4.4 + └─ [3]: 5.5 julia> countstored(A) 5 julia> A = Tensor(SparseCOO{2}(Element(0.0)), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -SparseCOO{2} (0.0) [:,1:3] -├─ [2, 1]: 1.1 -├─ [3, 1]: 2.2 -├─ [4, 1]: 3.3 -├─ [1, 3]: 4.4 -└─ [3, 3]: 5.5 +4×3-Tensor +└─ SparseCOO{2} (0.0) [:,1:3] + ├─ [2, 1]: 1.1 + ├─ [3, 1]: 2.2 + ├─ ⋮ + ├─ [1, 3]: 4.4 + └─ [3, 3]: 5.5 julia> countstored(A) 5 julia> A = Tensor(Dense(Dense(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -Dense [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: Dense [1:4] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ └─ [4]: 0.0 -└─ [:, 3]: Dense [1:4] - ├─ [1]: 4.4 - ├─ [2]: 0.0 - ├─ [3]: 5.5 - └─ [4]: 0.0 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ [3]: 0.0 + │ └─ [4]: 0.0 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 4.4 + ├─ [2]: 0.0 + ├─ [3]: 5.5 + └─ [4]: 0.0 julia> countstored(A) 12 julia> A = Tensor(SparseList(Dense(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -SparseList (0.0) [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -└─ [:, 3]: Dense [1:4] - ├─ [1]: 4.4 - ├─ [2]: 0.0 - ├─ [3]: 5.5 - └─ [4]: 0.0 +4×3-Tensor +└─ SparseList (0.0) [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 4.4 + ├─ [2]: 0.0 + ├─ [3]: 5.5 + └─ [4]: 0.0 julia> countstored(A) 8 diff --git a/test/reference32/interface/getindex.txt b/test/reference32/interface/getindex.txt index 00333c762..14bcc8a11 100644 --- a/test/reference32/interface/getindex.txt +++ b/test/reference32/interface/getindex.txt @@ -1,123 +1,128 @@ getindex tests -A = SparseList (0.0) [:,:,1:4] -├─ [:, :, 1]: Dense [:,1:3] -│ ├─ [:, 1]: SparseList (0.0) [1:5] -│ │ ├─ [2]: 1.01 -│ │ └─ [3]: 2.02 -│ ├─ [:, 2]: SparseList (0.0) [1:5] -│ │ ├─ [3]: 3.03 -│ │ ├─ [4]: 4.04 -│ │ └─ [5]: 5.05 -│ └─ [:, 3]: SparseList (0.0) [1:5] -│ ├─ [2]: 6.06 -│ └─ [3]: 7.07 -├─ [:, :, 2]: Dense [:,1:3] -│ ├─ [:, 1]: SparseList (0.0) [1:5] -│ │ ├─ [1]: 8.08 -│ │ ├─ [3]: 9.09 -│ │ ├─ [4]: 10.1 -│ │ └─ [5]: 11.11 -│ ├─ [:, 2]: SparseList (0.0) [1:5] -│ │ ├─ [2]: 12.12 -│ │ └─ [4]: 13.13 -│ └─ [:, 3]: SparseList (0.0) [1:5] -│ ├─ [2]: 14.14 -│ ├─ [4]: 15.15 -│ └─ [5]: 16.16 -├─ [:, :, 3]: Dense [:,1:3] -│ ├─ [:, 1]: SparseList (0.0) [1:5] -│ │ ├─ [2]: 17.17 -│ │ ├─ [3]: 18.18 -│ │ └─ [5]: 19.19 -│ ├─ [:, 2]: SparseList (0.0) [1:5] -│ │ ├─ [1]: 20.2 -│ │ ├─ [3]: 21.21 -│ │ ├─ [4]: 22.22 -│ │ └─ [5]: 23.23 -│ └─ [:, 3]: SparseList (0.0) [1:5] -│ ├─ [2]: 24.24 -│ ├─ [3]: 25.25 -│ └─ [4]: 26.26 -└─ [:, :, 4]: Dense [:,1:3] - ├─ [:, 1]: SparseList (0.0) [1:5] - ├─ [:, 2]: SparseList (0.0) [1:5] - │ └─ [2]: 27.27 - └─ [:, 3]: SparseList (0.0) [1:5] - ├─ [1]: 28.28 - ├─ [2]: 29.29 - └─ [3]: 30.3 +A = 5×3×4-Tensor +└─ SparseList (0.0) [:,:,1:4] + ├─ [:, :, 1]: Dense [:,1:3] + │ ├─ [:, 1]: SparseList (0.0) [1:5] + │ │ ├─ [2]: 1.01 + │ │ └─ [3]: 2.02 + │ ├─ [:, 2]: SparseList (0.0) [1:5] + │ │ ├─ [3]: 3.03 + │ │ ├─ [4]: 4.04 + │ │ └─ [5]: 5.05 + │ └─ [:, 3]: SparseList (0.0) [1:5] + │ ├─ [2]: 6.06 + │ └─ [3]: 7.07 + ├─ [:, :, 2]: Dense [:,1:3] + │ ├─ [:, 1]: SparseList (0.0) [1:5] + │ │ ├─ [1]: 8.08 + │ │ ├─ [3]: 9.09 + │ │ ├─ [4]: 10.1 + │ │ └─ [5]: 11.11 + │ ├─ [:, 2]: SparseList (0.0) [1:5] + │ │ ├─ [2]: 12.12 + │ │ └─ [4]: 13.13 + │ └─ [:, 3]: SparseList (0.0) [1:5] + │ ├─ [2]: 14.14 + │ ├─ [4]: 15.15 + │ └─ [5]: 16.16 + ├─ [:, :, 3]: Dense [:,1:3] + │ ├─ [:, 1]: SparseList (0.0) [1:5] + │ │ ├─ [2]: 17.17 + │ │ ├─ [3]: 18.18 + │ │ └─ [5]: 19.19 + │ ├─ [:, 2]: SparseList (0.0) [1:5] + │ │ ├─ [1]: 20.2 + │ │ ├─ [3]: 21.21 + │ │ ├─ [4]: 22.22 + │ │ └─ [5]: 23.23 + │ └─ [:, 3]: SparseList (0.0) [1:5] + │ ├─ [2]: 24.24 + │ ├─ [3]: 25.25 + │ └─ [4]: 26.26 + └─ [:, :, 4]: Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:5] + ├─ [:, 2]: SparseList (0.0) [1:5] + │ └─ [2]: 27.27 + └─ [:, 3]: SparseList (0.0) [1:5] + ├─ [1]: 28.28 + ├─ [2]: 29.29 + └─ [3]: 30.3 A[1,2,3] = 20.2 A[1,1,1] = 0.0 -A[1,Colon(),3] = Sparse (0.0) [1:3] -└─ [2]: 20.2 +A[1,Colon(),3] = 3-Tensor +└─ Sparse (0.0) [1:3] + └─ [2]: 20.2 -A[Colon(),1,3] = Sparse (0.0) [1:5] -├─ [2]: 17.17 -├─ [3]: 18.18 -└─ [5]: 19.19 +A[Colon(),1,3] = 5-Tensor +└─ Sparse (0.0) [1:5] + ├─ [2]: 17.17 + ├─ [3]: 18.18 + └─ [5]: 19.19 -A[Colon(),Colon(),3] = Sparse (0.0) [:,1:3] -├─ [:, 1]: Sparse (0.0) [1:5] -│ ├─ [2]: 17.17 -│ ├─ [3]: 18.18 -│ └─ [5]: 19.19 -├─ [:, 2]: Sparse (0.0) [1:5] -│ ├─ [1]: 20.2 -│ ├─ [3]: 21.21 -│ ├─ [4]: 22.22 -│ └─ [5]: 23.23 -└─ [:, 3]: Sparse (0.0) [1:5] - ├─ [2]: 24.24 - ├─ [3]: 25.25 - └─ [4]: 26.26 - -A[Colon(),Colon(),Colon()] = Sparse (0.0) [:,:,1:4] -├─ [:, :, 1]: Dense [:,1:3] -│ ├─ [:, 1]: Sparse (0.0) [1:5] -│ │ ├─ [2]: 1.01 -│ │ └─ [3]: 2.02 -│ ├─ [:, 2]: Sparse (0.0) [1:5] -│ │ ├─ [3]: 3.03 -│ │ ├─ [4]: 4.04 -│ │ └─ [5]: 5.05 -│ └─ [:, 3]: Sparse (0.0) [1:5] -│ ├─ [2]: 6.06 -│ └─ [3]: 7.07 -├─ [:, :, 2]: Dense [:,1:3] -│ ├─ [:, 1]: Sparse (0.0) [1:5] -│ │ ├─ [1]: 8.08 -│ │ ├─ [3]: 9.09 -│ │ ├─ [4]: 10.1 -│ │ └─ [5]: 11.11 -│ ├─ [:, 2]: Sparse (0.0) [1:5] -│ │ ├─ [2]: 12.12 -│ │ └─ [4]: 13.13 -│ └─ [:, 3]: Sparse (0.0) [1:5] -│ ├─ [2]: 14.14 -│ ├─ [4]: 15.15 -│ └─ [5]: 16.16 -├─ [:, :, 3]: Dense [:,1:3] -│ ├─ [:, 1]: Sparse (0.0) [1:5] -│ │ ├─ [2]: 17.17 -│ │ ├─ [3]: 18.18 -│ │ └─ [5]: 19.19 -│ ├─ [:, 2]: Sparse (0.0) [1:5] -│ │ ├─ [1]: 20.2 -│ │ ├─ [3]: 21.21 -│ │ ├─ [4]: 22.22 -│ │ └─ [5]: 23.23 -│ └─ [:, 3]: Sparse (0.0) [1:5] -│ ├─ [2]: 24.24 -│ ├─ [3]: 25.25 -│ └─ [4]: 26.26 -└─ [:, :, 4]: Dense [:,1:3] +A[Colon(),Colon(),3] = 5×3-Tensor +└─ Sparse (0.0) [:,1:3] ├─ [:, 1]: Sparse (0.0) [1:5] + │ ├─ [2]: 17.17 + │ ├─ [3]: 18.18 + │ └─ [5]: 19.19 ├─ [:, 2]: Sparse (0.0) [1:5] - │ └─ [2]: 27.27 + │ ├─ [1]: 20.2 + │ ├─ [3]: 21.21 + │ ├─ [4]: 22.22 + │ └─ [5]: 23.23 └─ [:, 3]: Sparse (0.0) [1:5] - ├─ [1]: 28.28 - ├─ [2]: 29.29 - └─ [3]: 30.3 + ├─ [2]: 24.24 + ├─ [3]: 25.25 + └─ [4]: 26.26 + +A[Colon(),Colon(),Colon()] = 5×3×4-Tensor +└─ Sparse (0.0) [:,:,1:4] + ├─ [:, :, 1]: Dense [:,1:3] + │ ├─ [:, 1]: Sparse (0.0) [1:5] + │ │ ├─ [2]: 1.01 + │ │ └─ [3]: 2.02 + │ ├─ [:, 2]: Sparse (0.0) [1:5] + │ │ ├─ [3]: 3.03 + │ │ ├─ [4]: 4.04 + │ │ └─ [5]: 5.05 + │ └─ [:, 3]: Sparse (0.0) [1:5] + │ ├─ [2]: 6.06 + │ └─ [3]: 7.07 + ├─ [:, :, 2]: Dense [:,1:3] + │ ├─ [:, 1]: Sparse (0.0) [1:5] + │ │ ├─ [1]: 8.08 + │ │ ├─ [3]: 9.09 + │ │ ├─ [4]: 10.1 + │ │ └─ [5]: 11.11 + │ ├─ [:, 2]: Sparse (0.0) [1:5] + │ │ ├─ [2]: 12.12 + │ │ └─ [4]: 13.13 + │ └─ [:, 3]: Sparse (0.0) [1:5] + │ ├─ [2]: 14.14 + │ ├─ [4]: 15.15 + │ └─ [5]: 16.16 + ├─ [:, :, 3]: Dense [:,1:3] + │ ├─ [:, 1]: Sparse (0.0) [1:5] + │ │ ├─ [2]: 17.17 + │ │ ├─ [3]: 18.18 + │ │ └─ [5]: 19.19 + │ ├─ [:, 2]: Sparse (0.0) [1:5] + │ │ ├─ [1]: 20.2 + │ │ ├─ [3]: 21.21 + │ │ ├─ [4]: 22.22 + │ │ └─ [5]: 23.23 + │ └─ [:, 3]: Sparse (0.0) [1:5] + │ ├─ [2]: 24.24 + │ ├─ [3]: 25.25 + │ └─ [4]: 26.26 + └─ [:, :, 4]: Dense [:,1:3] + ├─ [:, 1]: Sparse (0.0) [1:5] + ├─ [:, 2]: Sparse (0.0) [1:5] + │ └─ [2]: 27.27 + └─ [:, 3]: Sparse (0.0) [1:5] + ├─ [1]: 28.28 + ├─ [2]: 29.29 + └─ [3]: 30.3 diff --git a/test/reference32/interface/reduce.txt b/test/reference32/interface/reduce.txt index f8e173df7..619cca315 100644 --- a/test/reference32/interface/reduce.txt +++ b/test/reference32/interface/reduce.txt @@ -1,25 +1,50 @@ reduce tests julia> A = Tensor(Dense(SparseList(Element(0.0))), [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 4.4 - └─ [3]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 4.4 + └─ [3]: 5.5 julia> reduce(+, A, dims = (1,)) -SwizzleArray(Tensor(Dense{Int32}(Element{0.0, Float64, Int32}([6.6, 0.0, 9.9]), 3)), (1,)) +3-Tensor +└─ Dense [1:3] + ├─ [1]: 6.6 + ├─ [2]: 0.0 + └─ [3]: 9.9 + julia> reduce(+, A, dims = 1) -SwizzleArray(Tensor(Dense{Int32}(Element{0.0, Float64, Int32}([6.6, 0.0, 9.9]), 3)), (1,)) +3-Tensor +└─ Dense [1:3] + ├─ [1]: 6.6 + ├─ [2]: 0.0 + └─ [3]: 9.9 + julia> reduce(+, A, dims = (2,)) -SwizzleArray(Tensor(Sparse{Int32}(Element{0.0, Float64, Int32}([1.1, 7.7, 3.3, 4.4]), 4, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}([1, 5], [1, 2, 3, 4], [4, 1, 2, 3], Dict((1, 2) => 1, (1, 4) => 3, (1, 3) => 2, (1, 1) => 4)))), (1,)) +4-Tensor +└─ Sparse (0.0) [1:4] + ├─ [1]: 4.4 + ├─ [2]: 1.1 + ├─ [3]: 7.7 + └─ [4]: 3.3 + julia> reduce(+, A, dims = 2) -SwizzleArray(Tensor(Sparse{Int32}(Element{0.0, Float64, Int32}([1.1, 7.7, 3.3, 4.4]), 4, Finch.DictTable{Int32, Int32, Vector{Int32}, Vector{Int32}, Vector{Int32}, Dict{Tuple{Int32, Int32}, Int32}}([1, 5], [1, 2, 3, 4], [4, 1, 2, 3], Dict((1, 2) => 1, (1, 4) => 3, (1, 3) => 2, (1, 1) => 4)))), (1,)) +4-Tensor +└─ Sparse (0.0) [1:4] + ├─ [1]: 4.4 + ├─ [2]: 1.1 + ├─ [3]: 7.7 + └─ [4]: 3.3 + julia> reduce(+, A, dims = (1, 2)) -SwizzleArray(Tensor(Element{0.0, Float64, Int32}([16.5])), ()) +-Tensor +└─ 16.5 + julia> reduce(+, A, dims = (:)) 16.5 diff --git a/test/reference32/interface/setindex.txt b/test/reference32/interface/setindex.txt index d1d275772..6976a5659 100644 --- a/test/reference32/interface/setindex.txt +++ b/test/reference32/interface/setindex.txt @@ -1,138 +1,32 @@ setindex! tests julia> A = Tensor(Dense(Dense(Element(0.0))), 10, 12) -Dense [:,1:12] -├─ [:, 1]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 2]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 3]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 4]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 5]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 6]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 7]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 8]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 9]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 10]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -├─ [:, 11]: Dense [1:10] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 0.0 -│ ├─ [5]: 0.0 -│ ├─ [6]: 0.0 -│ ├─ [7]: 0.0 -│ ├─ [8]: 0.0 -│ ├─ [9]: 0.0 -│ └─ [10]: 0.0 -└─ [:, 12]: Dense [1:10] - ├─ [1]: 0.0 - ├─ [2]: 0.0 - ├─ [3]: 0.0 - ├─ [4]: 0.0 - ├─ [5]: 0.0 - ├─ [6]: 0.0 - ├─ [7]: 0.0 - ├─ [8]: 0.0 - ├─ [9]: 0.0 - └─ [10]: 0.0 +10×12-Tensor +└─ Dense [:,1:12] + ├─ [:, 1]: Dense [1:10] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [9]: 0.0 + │ └─ [10]: 0.0 + ├─ [:, 2]: Dense [1:10] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [9]: 0.0 + │ └─ [10]: 0.0 + ├─ ⋮ + ├─ [:, 11]: Dense [1:10] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [9]: 0.0 + │ └─ [10]: 0.0 + └─ [:, 12]: Dense [1:10] + ├─ [1]: 0.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [9]: 0.0 + └─ [10]: 0.0 julia> A[1, 4] = 3 3 diff --git a/test/reference32/print/display_byte_dense.txt b/test/reference32/print/display_byte_dense.txt index cc673fce5..a540477d9 100644 --- a/test/reference32/print/display_byte_dense.txt +++ b/test/reference32/print/display_byte_dense.txt @@ -1,62 +1,28 @@ -SparseByteMap (0.0) [:,1:10] -├─ [:, 1]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 2]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 3]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 5]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 6]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 8]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 9]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: Dense [1:5] - ├─ [1]: 2.0 - ├─ [2]: 0.0 - ├─ [3]: 1.0 - ├─ [4]: 2.0 - └─ [5]: 0.0 +5×10-Tensor +└─ SparseByteMap (0.0) [:,1:10] + ├─ [:, 1]: Dense [1:5] + │ ├─ [1]: 2.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [4]: 2.0 + │ └─ [5]: 0.0 + ├─ [:, 2]: Dense [1:5] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.0 + │ ├─ ⋮ + │ ├─ [4]: 0.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: Dense [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ ⋮ + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: Dense [1:5] + ├─ [1]: 2.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [4]: 2.0 + └─ [5]: 0.0 diff --git a/test/reference32/print/display_coo1_dense.txt b/test/reference32/print/display_coo1_dense.txt index 6f4bce856..1e2aad37f 100644 --- a/test/reference32/print/display_coo1_dense.txt +++ b/test/reference32/print/display_coo1_dense.txt @@ -1,62 +1,28 @@ -SparseCOO{1} (0.0) [:,1:10] -├─ [:, 1]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 2]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 3]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 5]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 6]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 8]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 9]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: Dense [1:5] - ├─ [1]: 2.0 - ├─ [2]: 0.0 - ├─ [3]: 1.0 - ├─ [4]: 2.0 - └─ [5]: 0.0 +5×10-Tensor +└─ SparseCOO{1} (0.0) [:,1:10] + ├─ [:, 1]: Dense [1:5] + │ ├─ [1]: 2.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [4]: 2.0 + │ └─ [5]: 0.0 + ├─ [:, 2]: Dense [1:5] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.0 + │ ├─ ⋮ + │ ├─ [4]: 0.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: Dense [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ ⋮ + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: Dense [1:5] + ├─ [1]: 2.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [4]: 2.0 + └─ [5]: 0.0 diff --git a/test/reference32/print/display_coo2.txt b/test/reference32/print/display_coo2.txt index bfa027acf..1fb9e8410 100644 --- a/test/reference32/print/display_coo2.txt +++ b/test/reference32/print/display_coo2.txt @@ -1,35 +1,8 @@ -SparseCOO{2} (0.0) [:,1:10] -├─ [1, 1]: 2.0 -├─ [3, 1]: 1.0 -├─ [4, 1]: 2.0 -├─ [2, 2]: 1.0 -├─ [3, 2]: 2.0 -├─ [5, 2]: 1.0 -├─ [1, 3]: 1.0 -├─ [2, 3]: 2.0 -├─ [4, 3]: 1.0 -├─ [5, 3]: 2.0 -├─ [1, 4]: 2.0 -├─ [3, 4]: 1.0 -├─ [4, 4]: 2.0 -├─ [2, 5]: 1.0 -├─ [3, 5]: 2.0 -├─ [5, 5]: 1.0 -├─ [1, 6]: 1.0 -├─ [2, 6]: 2.0 -├─ [4, 6]: 1.0 -├─ [5, 6]: 2.0 -├─ [1, 7]: 2.0 -├─ [3, 7]: 1.0 -├─ [4, 7]: 2.0 -├─ [2, 8]: 1.0 -├─ [3, 8]: 2.0 -├─ [5, 8]: 1.0 -├─ [1, 9]: 1.0 -├─ [2, 9]: 2.0 -├─ [4, 9]: 1.0 -├─ [5, 9]: 2.0 -├─ [1, 10]: 2.0 -├─ [3, 10]: 1.0 -└─ [4, 10]: 2.0 +5×10-Tensor +└─ SparseCOO{2} (0.0) [:,1:10] + ├─ [1, 1]: 2.0 + ├─ [3, 1]: 1.0 + ├─ ⋮ + ├─ [3, 10]: 1.0 + └─ [4, 10]: 2.0 diff --git a/test/reference32/print/display_dense_byte.txt b/test/reference32/print/display_dense_byte.txt index 3d5518eed..7952cffde 100644 --- a/test/reference32/print/display_dense_byte.txt +++ b/test/reference32/print/display_dense_byte.txt @@ -1,45 +1,21 @@ -Dense [:,1:10] -├─ [:, 1]: SparseByteMap (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 0.0 -│ └─ [4]: 1.0 -├─ [:, 2]: SparseByteMap (0.0) [1:5] -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ └─ [5]: 0.0 -├─ [:, 3]: SparseByteMap (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 4]: SparseByteMap (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [4]: 0.0 -├─ [:, 5]: SparseByteMap (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 2.0 -├─ [:, 6]: SparseByteMap (0.0) [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 7]: SparseByteMap (0.0) [1:5] -│ ├─ [1]: 0.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 8]: SparseByteMap (0.0) [1:5] -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ └─ [5]: 1.0 -├─ [:, 9]: SparseByteMap (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: SparseByteMap (0.0) [1:5] - ├─ [1]: 2.0 - ├─ [3]: 0.0 - └─ [4]: 1.0 +5×10-Tensor +└─ Dense [:,1:10] + ├─ [:, 1]: SparseByteMap (0.0) [1:5] + │ ├─ [1]: 2.0 + │ ├─ [3]: 0.0 + │ └─ [4]: 1.0 + ├─ [:, 2]: SparseByteMap (0.0) [1:5] + │ ├─ [2]: 2.0 + │ ├─ [3]: 0.0 + │ └─ [5]: 0.0 + ├─ ⋮ + ├─ [:, 9]: SparseByteMap (0.0) [1:5] + │ ├─ [1]: 2.0 + │ ├─ [2]: 0.0 + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: SparseByteMap (0.0) [1:5] + ├─ [1]: 2.0 + ├─ [3]: 0.0 + └─ [4]: 1.0 diff --git a/test/reference32/print/display_dense_coo1.txt b/test/reference32/print/display_dense_coo1.txt index 40796be13..c951f5c9a 100644 --- a/test/reference32/print/display_dense_coo1.txt +++ b/test/reference32/print/display_dense_coo1.txt @@ -1,45 +1,21 @@ -Dense [:,1:10] -├─ [:, 1]: SparseCOO{1} (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 2]: SparseCOO{1} (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 3]: SparseCOO{1} (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: SparseCOO{1} (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 5]: SparseCOO{1} (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 6]: SparseCOO{1} (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: SparseCOO{1} (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 8]: SparseCOO{1} (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 9]: SparseCOO{1} (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: SparseCOO{1} (0.0) [1:5] - ├─ [1]: 2.0 - ├─ [3]: 1.0 - └─ [4]: 2.0 +5×10-Tensor +└─ Dense [:,1:10] + ├─ [:, 1]: SparseCOO{1} (0.0) [1:5] + │ ├─ [1]: 2.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 2.0 + ├─ [:, 2]: SparseCOO{1} (0.0) [1:5] + │ ├─ [2]: 1.0 + │ ├─ [3]: 2.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: SparseCOO{1} (0.0) [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: SparseCOO{1} (0.0) [1:5] + ├─ [1]: 2.0 + ├─ [3]: 1.0 + └─ [4]: 2.0 diff --git a/test/reference32/print/display_dense_dict.txt b/test/reference32/print/display_dense_dict.txt index 64626f03f..63c92017f 100644 --- a/test/reference32/print/display_dense_dict.txt +++ b/test/reference32/print/display_dense_dict.txt @@ -1,45 +1,21 @@ -Dense [:,1:10] -├─ [:, 1]: Sparse (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 2]: Sparse (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 3]: Sparse (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: Sparse (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 5]: Sparse (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 6]: Sparse (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: Sparse (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 8]: Sparse (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 9]: Sparse (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: Sparse (0.0) [1:5] - ├─ [1]: 2.0 - ├─ [3]: 1.0 - └─ [4]: 2.0 +5×10-Tensor +└─ Dense [:,1:10] + ├─ [:, 1]: Sparse (0.0) [1:5] + │ ├─ [1]: 2.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 2.0 + ├─ [:, 2]: Sparse (0.0) [1:5] + │ ├─ [2]: 1.0 + │ ├─ [3]: 2.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: Sparse (0.0) [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: Sparse (0.0) [1:5] + ├─ [1]: 2.0 + ├─ [3]: 1.0 + └─ [4]: 2.0 diff --git a/test/reference32/print/display_dense_hash1.txt b/test/reference32/print/display_dense_hash1.txt index 05cc250ad..413dae3d0 100644 --- a/test/reference32/print/display_dense_hash1.txt +++ b/test/reference32/print/display_dense_hash1.txt @@ -1,45 +1,21 @@ -Dense [:,1:10] -├─ [:, 1]: SparseHash{1} (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 2]: SparseHash{1} (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 3]: SparseHash{1} (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: SparseHash{1} (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 5]: SparseHash{1} (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 6]: SparseHash{1} (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: SparseHash{1} (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 8]: SparseHash{1} (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 9]: SparseHash{1} (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: SparseHash{1} (0.0) [1:5] - ├─ [1]: 2.0 - ├─ [3]: 1.0 - └─ [4]: 2.0 +5×10-Tensor +└─ Dense [:,1:10] + ├─ [:, 1]: SparseHash{1} (0.0) [1:5] + │ ├─ [1]: 2.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 2.0 + ├─ [:, 2]: SparseHash{1} (0.0) [1:5] + │ ├─ [2]: 1.0 + │ ├─ [3]: 2.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: SparseHash{1} (0.0) [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: SparseHash{1} (0.0) [1:5] + ├─ [1]: 2.0 + ├─ [3]: 1.0 + └─ [4]: 2.0 diff --git a/test/reference32/print/display_dense_list.txt b/test/reference32/print/display_dense_list.txt index 6013902be..4054ba441 100644 --- a/test/reference32/print/display_dense_list.txt +++ b/test/reference32/print/display_dense_list.txt @@ -1,45 +1,21 @@ -Dense [:,1:10] -├─ [:, 1]: SparseList (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 2]: SparseList (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 3]: SparseList (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: SparseList (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 5]: SparseList (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 6]: SparseList (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: SparseList (0.0) [1:5] -│ ├─ [1]: 2.0 -│ ├─ [3]: 1.0 -│ └─ [4]: 2.0 -├─ [:, 8]: SparseList (0.0) [1:5] -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ └─ [5]: 1.0 -├─ [:, 9]: SparseList (0.0) [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: SparseList (0.0) [1:5] - ├─ [1]: 2.0 - ├─ [3]: 1.0 - └─ [4]: 2.0 +5×10-Tensor +└─ Dense [:,1:10] + ├─ [:, 1]: SparseList (0.0) [1:5] + │ ├─ [1]: 2.0 + │ ├─ [3]: 1.0 + │ └─ [4]: 2.0 + ├─ [:, 2]: SparseList (0.0) [1:5] + │ ├─ [2]: 1.0 + │ ├─ [3]: 2.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: SparseList (0.0) [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: SparseList (0.0) [1:5] + ├─ [1]: 2.0 + ├─ [3]: 1.0 + └─ [4]: 2.0 diff --git a/test/reference32/print/display_dict_dense.txt b/test/reference32/print/display_dict_dense.txt index 0d950d946..032edf52e 100644 --- a/test/reference32/print/display_dict_dense.txt +++ b/test/reference32/print/display_dict_dense.txt @@ -1,62 +1,28 @@ -Sparse (0.0) [:,1:10] -├─ [:, 1]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 2]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 3]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 5]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 6]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 8]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 9]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: Dense [1:5] - ├─ [1]: 2.0 - ├─ [2]: 0.0 - ├─ [3]: 1.0 - ├─ [4]: 2.0 - └─ [5]: 0.0 +5×10-Tensor +└─ Sparse (0.0) [:,1:10] + ├─ [:, 1]: Dense [1:5] + │ ├─ [1]: 2.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [4]: 2.0 + │ └─ [5]: 0.0 + ├─ [:, 2]: Dense [1:5] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.0 + │ ├─ ⋮ + │ ├─ [4]: 0.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: Dense [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ ⋮ + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: Dense [1:5] + ├─ [1]: 2.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [4]: 2.0 + └─ [5]: 0.0 diff --git a/test/reference32/print/display_hash1_dense.txt b/test/reference32/print/display_hash1_dense.txt index e5b778daa..31245d49f 100644 --- a/test/reference32/print/display_hash1_dense.txt +++ b/test/reference32/print/display_hash1_dense.txt @@ -1,62 +1,28 @@ -SparseHash{1} (0.0) [:,1:5] -├─ [:, 1]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 2]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 3]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 5]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 6]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 8]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 9]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: Dense [1:5] - ├─ [1]: 2.0 - ├─ [2]: 0.0 - ├─ [3]: 1.0 - ├─ [4]: 2.0 - └─ [5]: 0.0 +10×5-Tensor +└─ SparseHash{1} (0.0) [:,1:5] + ├─ [:, 1]: Dense [1:5] + │ ├─ [1]: 2.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [4]: 2.0 + │ └─ [5]: 0.0 + ├─ [:, 2]: Dense [1:5] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.0 + │ ├─ ⋮ + │ ├─ [4]: 0.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: Dense [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ ⋮ + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: Dense [1:5] + ├─ [1]: 2.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [4]: 2.0 + └─ [5]: 0.0 diff --git a/test/reference32/print/display_hash2.txt b/test/reference32/print/display_hash2.txt index 8b4724256..1d1048ed1 100644 --- a/test/reference32/print/display_hash2.txt +++ b/test/reference32/print/display_hash2.txt @@ -1,35 +1,8 @@ -SparseHash{2} (0.0) [:,1:10] -├─ [1, 1]: 2.0 -├─ [3, 1]: 1.0 -├─ [4, 1]: 2.0 -├─ [2, 2]: 1.0 -├─ [3, 2]: 2.0 -├─ [5, 2]: 1.0 -├─ [1, 3]: 1.0 -├─ [2, 3]: 2.0 -├─ [4, 3]: 1.0 -├─ [5, 3]: 2.0 -├─ [1, 4]: 2.0 -├─ [3, 4]: 1.0 -├─ [4, 4]: 2.0 -├─ [2, 5]: 1.0 -├─ [3, 5]: 2.0 -├─ [5, 5]: 1.0 -├─ [1, 6]: 1.0 -├─ [2, 6]: 2.0 -├─ [4, 6]: 1.0 -├─ [5, 6]: 2.0 -├─ [1, 7]: 2.0 -├─ [3, 7]: 1.0 -├─ [4, 7]: 2.0 -├─ [2, 8]: 1.0 -├─ [3, 8]: 2.0 -├─ [5, 8]: 1.0 -├─ [1, 9]: 1.0 -├─ [2, 9]: 2.0 -├─ [4, 9]: 1.0 -├─ [5, 9]: 2.0 -├─ [1, 10]: 2.0 -├─ [3, 10]: 1.0 -└─ [4, 10]: 2.0 +5×10-Tensor +└─ SparseHash{2} (0.0) [:,1:10] + ├─ [1, 1]: 2.0 + ├─ [3, 1]: 1.0 + ├─ ⋮ + ├─ [3, 10]: 1.0 + └─ [4, 10]: 2.0 diff --git a/test/reference32/print/display_list_dense.txt b/test/reference32/print/display_list_dense.txt index 6ad012e34..54c273e6a 100644 --- a/test/reference32/print/display_list_dense.txt +++ b/test/reference32/print/display_list_dense.txt @@ -1,62 +1,28 @@ -SparseList (0.0) [:,1:10] -├─ [:, 1]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 2]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 3]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 4]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 5]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 6]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -├─ [:, 7]: Dense [1:5] -│ ├─ [1]: 2.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 1.0 -│ ├─ [4]: 2.0 -│ └─ [5]: 0.0 -├─ [:, 8]: Dense [1:5] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.0 -│ ├─ [3]: 2.0 -│ ├─ [4]: 0.0 -│ └─ [5]: 1.0 -├─ [:, 9]: Dense [1:5] -│ ├─ [1]: 1.0 -│ ├─ [2]: 2.0 -│ ├─ [3]: 0.0 -│ ├─ [4]: 1.0 -│ └─ [5]: 2.0 -└─ [:, 10]: Dense [1:5] - ├─ [1]: 2.0 - ├─ [2]: 0.0 - ├─ [3]: 1.0 - ├─ [4]: 2.0 - └─ [5]: 0.0 +5×10-Tensor +└─ SparseList (0.0) [:,1:10] + ├─ [:, 1]: Dense [1:5] + │ ├─ [1]: 2.0 + │ ├─ [2]: 0.0 + │ ├─ ⋮ + │ ├─ [4]: 2.0 + │ └─ [5]: 0.0 + ├─ [:, 2]: Dense [1:5] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.0 + │ ├─ ⋮ + │ ├─ [4]: 0.0 + │ └─ [5]: 1.0 + ├─ ⋮ + ├─ [:, 9]: Dense [1:5] + │ ├─ [1]: 1.0 + │ ├─ [2]: 2.0 + │ ├─ ⋮ + │ ├─ [4]: 1.0 + │ └─ [5]: 2.0 + └─ [:, 10]: Dense [1:5] + ├─ [1]: 2.0 + ├─ [2]: 0.0 + ├─ ⋮ + ├─ [4]: 2.0 + └─ [5]: 0.0 diff --git a/test/reference32/typical/typical_inplace_sparse_add.txt b/test/reference32/typical/typical_inplace_sparse_add.txt index 48047c346..180fe07ff 100644 --- a/test/reference32/typical/typical_inplace_sparse_add.txt +++ b/test/reference32/typical/typical_inplace_sparse_add.txt @@ -1,23 +1,20 @@ julia> A = Tensor(SparseList(Element(0.0)), [2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0]) -SparseList (0.0) [1:10] -├─ [1]: 2.0 -├─ [3]: 3.0 -├─ [5]: 4.0 -├─ [7]: 5.0 -└─ [9]: 6.0 +10-Tensor +└─ SparseList (0.0) [1:10] + ├─ [1]: 2.0 + ├─ [3]: 3.0 + ├─ ⋮ + ├─ [7]: 5.0 + └─ [9]: 6.0 julia> B = Tensor(Dense(Element(0.0)), fill(1.1, 10)) -Dense [1:10] -├─ [1]: 1.1 -├─ [2]: 1.1 -├─ [3]: 1.1 -├─ [4]: 1.1 -├─ [5]: 1.1 -├─ [6]: 1.1 -├─ [7]: 1.1 -├─ [8]: 1.1 -├─ [9]: 1.1 -└─ [10]: 1.1 +10-Tensor +└─ Dense [1:10] + ├─ [1]: 1.1 + ├─ [2]: 1.1 + ├─ ⋮ + ├─ [9]: 1.1 + └─ [10]: 1.1 julia> @finch_code for i = _ B[i] += A[i] diff --git a/test/reference32/typical/typical_spmv_csc.txt b/test/reference32/typical/typical_spmv_csc.txt index ed0bdd381..e06979e0c 100644 --- a/test/reference32/typical/typical_spmv_csc.txt +++ b/test/reference32/typical/typical_spmv_csc.txt @@ -1,26 +1,29 @@ julia> A = Tensor(Dense(SparseList(Element(0.0))), [0 0 3.3; 1.1 0 0; 2.2 0 4.4; 0 0 5.5]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ └─ [3]: 2.2 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 3.3 - ├─ [3]: 4.4 - └─ [4]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ └─ [3]: 2.2 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 3.3 + ├─ [3]: 4.4 + └─ [4]: 5.5 julia> y = Tensor([1.0, 2.0, 3.0, 4.0]) -Dense [1:4] -├─ [1]: 1.0 -├─ [2]: 2.0 -├─ [3]: 3.0 -└─ [4]: 4.0 +4-Tensor +└─ Dense [1:4] + ├─ [1]: 1.0 + ├─ [2]: 2.0 + ├─ [3]: 3.0 + └─ [4]: 4.0 julia> x = Tensor([1, 2, 3]) -Dense [1:3] -├─ [1]: 1 -├─ [2]: 2 -└─ [3]: 3 +3-Tensor +└─ Dense [1:3] + ├─ [1]: 1 + ├─ [2]: 2 + └─ [3]: 3 julia> @finch_code begin y .= 0 diff --git a/test/reference32/typical/typical_stats_example.txt b/test/reference32/typical/typical_stats_example.txt index 2aabffe77..4abc46306 100644 --- a/test/reference32/typical/typical_stats_example.txt +++ b/test/reference32/typical/typical_stats_example.txt @@ -1,17 +1,22 @@ julia> X = Tensor(SparseList(Element(0.0)), [1.0, 0.0, 0.0, 3.0, 0.0, 2.0, 0.0]) -SparseList (0.0) [1:7] -├─ [1]: 1.0 -├─ [4]: 3.0 -└─ [6]: 2.0 +7-Tensor +└─ SparseList (0.0) [1:7] + ├─ [1]: 1.0 + ├─ [4]: 3.0 + └─ [6]: 2.0 julia> x_min = Scalar(Inf) Scalar{Inf, Float64}(Inf) + julia> x_max = Scalar(-Inf) Scalar{-Inf, Float64}(-Inf) + julia> x_sum = Scalar(0.0) Scalar{0.0, Float64}(0.0) + julia> x_var = Scalar(0.0) Scalar{0.0, Float64}(0.0) + julia> @finch_code begin for i = _ let x = X[i] diff --git a/test/reference32/typical/typical_transpose_csc_to_coo.txt b/test/reference32/typical/typical_transpose_csc_to_coo.txt index e98770145..9cc8cd55a 100644 --- a/test/reference32/typical/typical_transpose_csc_to_coo.txt +++ b/test/reference32/typical/typical_transpose_csc_to_coo.txt @@ -1,16 +1,18 @@ julia> A = Tensor(Dense(SparseList(Element(0.0))), [0 0 3.3; 1.1 0 0; 2.2 0 4.4; 0 0 5.5]) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:4] -│ ├─ [2]: 1.1 -│ └─ [3]: 2.2 -├─ [:, 2]: SparseList (0.0) [1:4] -└─ [:, 3]: SparseList (0.0) [1:4] - ├─ [1]: 3.3 - ├─ [3]: 4.4 - └─ [4]: 5.5 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:4] + │ ├─ [2]: 1.1 + │ └─ [3]: 2.2 + ├─ [:, 2]: SparseList (0.0) [1:4] + └─ [:, 3]: SparseList (0.0) [1:4] + ├─ [1]: 3.3 + ├─ [3]: 4.4 + └─ [4]: 5.5 julia> B = Tensor(SparseDict(SparseDict(Element(0.0)))) -Sparse (0.0) [:,1:0] +0×0-Tensor +└─ Sparse (0.0) [:,1:0] julia> @finch_code mode = :fast begin B .= 0 From fbdad7b17b7cd0849123b0486520ca8d23106ea5 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Sun, 19 May 2024 10:29:37 -0400 Subject: [PATCH 18/22] fixes --- docs/Project.toml | 1 - docs/fix.jl | 3 - docs/make.jl | 1 - docs/src/guides/interoperability.md | 21 ++++--- docs/src/interactive.ipynb | 61 ------------------- docs/src/interactive.jl | 22 ------- .../advanced_implementation/internals.md | 3 +- .../tensor_interface.md | 35 ++++++----- 8 files changed, 32 insertions(+), 115 deletions(-) delete mode 100644 docs/src/interactive.ipynb delete mode 100644 docs/src/interactive.jl diff --git a/docs/Project.toml b/docs/Project.toml index 8ff961954..ccbd699ef 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -4,7 +4,6 @@ BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" CIndices = "5a98b6c4-18fa-405d-92b3-8277d93fed36" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" Finch = "9177782c-1635-4eb9-9bfb-d9dfa25e6bce" -Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" MatrixDepot = "b51810bb-c9f3-55da-ae3c-350fc1fbce05" RewriteTools = "5969e224-3634-4c61-9f66-721b69e98b8a" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" diff --git a/docs/fix.jl b/docs/fix.jl index 12ffbb0b0..dfa912c57 100755 --- a/docs/fix.jl +++ b/docs/fix.jl @@ -9,13 +9,10 @@ end using Test using Documenter -using Literate using Finch root = joinpath(@__DIR__, "..") DocMeta.setdocmeta!(Finch, :DocTestSetup, :(using Finch; using SparseArrays); recursive=true) -Literate.notebook(joinpath(@__DIR__, "src/interactive.jl"), joinpath(@__DIR__, "src"), credit = false) - doctest(Finch, fix=true) \ No newline at end of file diff --git a/docs/make.jl b/docs/make.jl index af9a5f574..ed479e6b9 100755 --- a/docs/make.jl +++ b/docs/make.jl @@ -9,7 +9,6 @@ end using Documenter using Documenter.Remotes -using Literate using Finch DocMeta.setdocmeta!(Finch, :DocTestSetup, :(using Finch; using SparseArrays); recursive=true) diff --git a/docs/src/guides/interoperability.md b/docs/src/guides/interoperability.md index b6e785d62..07705c603 100644 --- a/docs/src/guides/interoperability.md +++ b/docs/src/guides/interoperability.md @@ -80,6 +80,7 @@ julia> ptr_jl = reinterpret(CIndex{Int}, ptr_c) 4 4 6 + julia> idx_jl = reinterpret(CIndex{Int}, idx_c) 5-element reinterpret(CIndex{Int64}, ::Vector{Int64}): 2 @@ -87,16 +88,18 @@ julia> idx_jl = reinterpret(CIndex{Int}, idx_c) 4 1 3 + julia> A = Tensor(Dense(SparseList{CIndex{Int}}(Element{0.0, Float64, CIndex{Int}}(val_c), m, ptr_jl, idx_jl), n)) -Dense [:,1:3] -├─ [:, 1]: SparseList (0.0) [1:CIndex{Int64}(4)] -│ ├─ [CIndex{Int64}(2)]: 1.1 -│ ├─ [CIndex{Int64}(3)]: 2.2 -│ └─ [CIndex{Int64}(4)]: 3.3 -├─ [:, 2]: SparseList (0.0) [1:CIndex{Int64}(4)] -└─ [:, 3]: SparseList (0.0) [1:CIndex{Int64}(4)] - ├─ [CIndex{Int64}(1)]: 4.4 - └─ [CIndex{Int64}(3)]: 5.5 +CIndex{Int64}(4)×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: SparseList (0.0) [1:CIndex{Int64}(4)] + │ ├─ [CIndex{Int64}(2)]: 1.1 + │ ├─ [CIndex{Int64}(3)]: 2.2 + │ └─ [CIndex{Int64}(4)]: 3.3 + ├─ [:, 2]: SparseList (0.0) [1:CIndex{Int64}(4)] + └─ [:, 3]: SparseList (0.0) [1:CIndex{Int64}(4)] + ├─ [CIndex{Int64}(1)]: 4.4 + └─ [CIndex{Int64}(3)]: 5.5 ``` We can also convert between representations by copying to or from `CIndex` fibers. \ No newline at end of file diff --git a/docs/src/interactive.ipynb b/docs/src/interactive.ipynb deleted file mode 100644 index dcb87347c..000000000 --- a/docs/src/interactive.ipynb +++ /dev/null @@ -1,61 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "source": [ - "An example generating sparse code with Finch, make some changes and give it a try!\n", - "\n", - "A note to visitors: it may take a minute or\n", - "two to compile the first kernel, perhaps enjoy a nice little coffee break ^.^" - ], - "metadata": {} - }, - { - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": "quote\n y = (ex.bodies[1]).body.body.lhs.tns.bind\n sugar_1 = size((ex.bodies[1]).body.body.lhs.tns.bind)\n y_mode1_stop = sugar_1[1]\n A_lvl = ((ex.bodies[1]).body.body.rhs.args[1]).tns.bind.lvl\n A_lvl_2 = A_lvl.lvl\n A_lvl_ptr = A_lvl_2.ptr\n A_lvl_idx = A_lvl_2.idx\n A_lvl_2_val = A_lvl_2.lvl.val\n x = ((ex.bodies[1]).body.body.rhs.args[2]).tns.bind\n sugar_2 = size(((ex.bodies[1]).body.body.rhs.args[2]).tns.bind)\n x_mode1_stop = sugar_2[1]\n A_lvl_2.shape == y_mode1_stop || throw(DimensionMismatch(\"mismatched dimension limits ($(A_lvl_2.shape) != $(y_mode1_stop))\"))\n x_mode1_stop == A_lvl.shape || throw(DimensionMismatch(\"mismatched dimension limits ($(x_mode1_stop) != $(A_lvl.shape))\"))\n result = nothing\n for j_4 = 1:x_mode1_stop\n val = x[j_4]\n A_lvl_q = (1 - 1) * A_lvl.shape + j_4\n A_lvl_2_q = A_lvl_ptr[A_lvl_q]\n A_lvl_2_q_stop = A_lvl_ptr[A_lvl_q + 1]\n if A_lvl_2_q < A_lvl_2_q_stop\n A_lvl_2_i1 = A_lvl_idx[A_lvl_2_q_stop - 1]\n else\n A_lvl_2_i1 = 0\n end\n phase_stop = min(A_lvl_2.shape, A_lvl_2_i1)\n if phase_stop >= 1\n if A_lvl_idx[A_lvl_2_q] < 1\n A_lvl_2_q = Finch.scansearch(A_lvl_idx, 1, A_lvl_2_q, A_lvl_2_q_stop - 1)\n end\n while true\n A_lvl_2_i = A_lvl_idx[A_lvl_2_q]\n if A_lvl_2_i < phase_stop\n A_lvl_3_val = A_lvl_2_val[A_lvl_2_q]\n y[A_lvl_2_i] = val * A_lvl_3_val + y[A_lvl_2_i]\n A_lvl_2_q += 1\n else\n phase_stop_3 = min(A_lvl_2_i, phase_stop)\n if A_lvl_2_i == phase_stop_3\n A_lvl_3_val = A_lvl_2_val[A_lvl_2_q]\n y[phase_stop_3] = val * A_lvl_3_val + y[phase_stop_3]\n A_lvl_2_q += 1\n end\n break\n end\n end\n end\n end\n result = ()\n result\nend" - }, - "metadata": {}, - "execution_count": 1 - } - ], - "cell_type": "code", - "source": [ - "using Finch\n", - "\n", - "# Construct a CSR sparse input matrix (20% random nonzeros)\n", - "A = Tensor(Dense(SparseList(Element(0.0))), fsprand(5, 7, 0.2))\n", - "\n", - "# Construct a dense vector input and output (all random values)\n", - "x = rand(7)\n", - "y = rand(5)\n", - "\n", - "# Emit code for matrix-vector multiply y = A * x\n", - "@finch_code begin\n", - " for j = _, i = _\n", - " y[i] += A[i, j] * x[j]\n", - " end\n", - "end" - ], - "metadata": {}, - "execution_count": 1 - } - ], - "nbformat_minor": 3, - "metadata": { - "language_info": { - "file_extension": ".jl", - "mimetype": "application/julia", - "name": "julia", - "version": "1.6.7" - }, - "kernelspec": { - "name": "julia-1.6", - "display_name": "Julia 1.6.7", - "language": "julia" - } - }, - "nbformat": 4 -} diff --git a/docs/src/interactive.jl b/docs/src/interactive.jl deleted file mode 100644 index 08eea288f..000000000 --- a/docs/src/interactive.jl +++ /dev/null @@ -1,22 +0,0 @@ -# -# An example generating sparse code with Finch, make some changes and give it a try! -# -# A note to visitors: it may take a minute or -# two to compile the first kernel, perhaps enjoy a nice little coffee break ^.^ -# - -using Finch - -## Construct a CSR sparse input matrix (20% random nonzeros) -A = Tensor(Dense(SparseList(Element(0.0))), fsprand(5, 7, 0.2)) - -## Construct a dense vector input and output (all random values) -x = rand(7) -y = rand(5) - -## Emit code for matrix-vector multiply y = A * x -@finch_code begin - for j = _, i = _ - y[i] += A[i, j] * x[j] - end -end diff --git a/docs/src/reference/advanced_implementation/internals.md b/docs/src/reference/advanced_implementation/internals.md index fac8146f1..5fe17baea 100644 --- a/docs/src/reference/advanced_implementation/internals.md +++ b/docs/src/reference/advanced_implementation/internals.md @@ -30,16 +30,15 @@ julia> C = Tensor(SparseList(Element(0))); julia> A = Tensor(SparseList(Element(0)), [0, 2, 0, 0, 3]); - julia> B = Tensor(Dense(Element(0)), [11, 12, 13, 14, 15]); julia> @finch (C .= 0; for i=_; C[i] = A[i] * B[i] end); - julia> C SparseList (0) [1:5] ├─ [2]: 24 └─ [5]: 45 + ``` The diff --git a/docs/src/reference/advanced_implementation/tensor_interface.md b/docs/src/reference/advanced_implementation/tensor_interface.md index f5a7c3c06..60e6fe9ac 100644 --- a/docs/src/reference/advanced_implementation/tensor_interface.md +++ b/docs/src/reference/advanced_implementation/tensor_interface.md @@ -7,23 +7,26 @@ julia> A = [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0] 1.1 0.0 0.0 2.2 0.0 5.5 3.3 0.0 0.0 + julia> A_fbr = Tensor(Dense(Dense(Element(0.0))), A) -Dense [:,1:3] -├─ [:, 1]: Dense [1:4] -│ ├─ [1]: 0.0 -│ ├─ [2]: 1.1 -│ ├─ [3]: 2.2 -│ └─ [4]: 3.3 -├─ [:, 2]: Dense [1:4] -│ ├─ [1]: 0.0 -│ ├─ [2]: 0.0 -│ ├─ [3]: 0.0 -│ └─ [4]: 0.0 -└─ [:, 3]: Dense [1:4] - ├─ [1]: 4.4 - ├─ [2]: 0.0 - ├─ [3]: 5.5 - └─ [4]: 0.0 +4×3-Tensor +└─ Dense [:,1:3] + ├─ [:, 1]: Dense [1:4] + │ ├─ [1]: 0.0 + │ ├─ [2]: 1.1 + │ ├─ [3]: 2.2 + │ └─ [4]: 3.3 + ├─ [:, 2]: Dense [1:4] + │ ├─ [1]: 0.0 + │ ├─ [2]: 0.0 + │ ├─ [3]: 0.0 + │ └─ [4]: 0.0 + └─ [:, 3]: Dense [1:4] + ├─ [1]: 4.4 + ├─ [2]: 0.0 + ├─ [3]: 5.5 + └─ [4]: 0.0 + ``` We refer to a node in the tree as a subfiber. All of the nodes at the same level From 0567ca7c06ce1e97b9b27f3eaf3d8776d0687a5b Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Sun, 19 May 2024 10:54:31 -0400 Subject: [PATCH 19/22] fixed --- benchmark/runbenchmarks.jl | 1 - benchmark/runjudge.jl | 1 - docs/fix.jl | 1 - docs/make.jl | 1 - .../advanced_implementation/internals.md | 11 +-- src/tensors/levels/sparse_interval_levels.jl | 43 +++++++++--- src/tensors/levels/sparse_point_levels.jl | 69 ++++++++++++++++--- test/runtests.jl | 1 - 8 files changed, 101 insertions(+), 27 deletions(-) diff --git a/benchmark/runbenchmarks.jl b/benchmark/runbenchmarks.jl index 21facd8e4..8e6eb9024 100755 --- a/benchmark/runbenchmarks.jl +++ b/benchmark/runbenchmarks.jl @@ -3,7 +3,6 @@ if abspath(PROGRAM_FILE) == @__FILE__ using Pkg Pkg.activate(@__DIR__) Pkg.develop(PackageSpec(path = joinpath(@__DIR__, ".."))) - Pkg.resolve() Pkg.instantiate() end diff --git a/benchmark/runjudge.jl b/benchmark/runjudge.jl index 7cb7b82d0..273a304cc 100755 --- a/benchmark/runjudge.jl +++ b/benchmark/runjudge.jl @@ -3,7 +3,6 @@ if abspath(PROGRAM_FILE) == @__FILE__ using Pkg Pkg.activate(@__DIR__) Pkg.develop(PackageSpec(path = joinpath(@__DIR__, ".."))) - Pkg.resolve() Pkg.instantiate() end diff --git a/docs/fix.jl b/docs/fix.jl index dfa912c57..651879426 100755 --- a/docs/fix.jl +++ b/docs/fix.jl @@ -3,7 +3,6 @@ if abspath(PROGRAM_FILE) == @__FILE__ using Pkg Pkg.activate(@__DIR__) Pkg.develop(PackageSpec(path = joinpath(@__DIR__, ".."))) - Pkg.resolve() Pkg.instantiate() end diff --git a/docs/make.jl b/docs/make.jl index ed479e6b9..a59796a8d 100755 --- a/docs/make.jl +++ b/docs/make.jl @@ -3,7 +3,6 @@ if abspath(PROGRAM_FILE) == @__FILE__ using Pkg Pkg.activate(@__DIR__) Pkg.develop(PackageSpec(path = joinpath(@__DIR__, ".."))) - Pkg.resolve() Pkg.instantiate() end diff --git a/docs/src/reference/advanced_implementation/internals.md b/docs/src/reference/advanced_implementation/internals.md index 5fe17baea..a809f5379 100644 --- a/docs/src/reference/advanced_implementation/internals.md +++ b/docs/src/reference/advanced_implementation/internals.md @@ -35,9 +35,10 @@ julia> B = Tensor(Dense(Element(0)), [11, 12, 13, 14, 15]); julia> @finch (C .= 0; for i=_; C[i] = A[i] * B[i] end); julia> C -SparseList (0) [1:5] -├─ [2]: 24 -└─ [5]: 45 +5-Tensor +└─ SparseList (0) [1:5] + ├─ [2]: 24 + └─ [5]: 45 ``` @@ -244,6 +245,7 @@ quote s.val = s_val result end + ``` Users can also create their own virtual nodes to represent their custom types. @@ -267,13 +269,12 @@ julia> prgm_inst = Finch.@finch_program_instance for i = _ s[] += A[i] end; - julia> println(prgm_inst) loop_instance(index_instance(i), Finch.FinchNotation.Dimensionless(), assign_instance(access_instance(tag_instance(variable_instance(:s), Scalar{0, Int64}(0)), literal_instance(Finch.FinchNotation.Updater())), tag_instance(variable_instance(:+), literal_instance(+)), access_instance(tag_instance(variable_instance(:A), Tensor(SparseList{Int64}(Element{0, Int64, Int64}([2, 3]), 5, [1, 3], [2, 5]))), literal_instance(Finch.FinchNotation.Reader()), tag_instance(variable_instance(:i), index_instance(i))))) julia> prgm_inst Finch program instance: for i = Dimensionless() - tag(s, Scalar{0, Int64}(0))[] <>= tag(A, Tensor(SparseList(Element(0))))[tag(i, i)] + tag(s, Scalar{0, Int64})[] <>= tag(A, Tensor(SparseList(Element(0))))[tag(i, i)] end julia> prgm = Finch.@finch_program for i = _ diff --git a/src/tensors/levels/sparse_interval_levels.jl b/src/tensors/levels/sparse_interval_levels.jl index 41a2a9023..04b92d3c0 100644 --- a/src/tensors/levels/sparse_interval_levels.jl +++ b/src/tensors/levels/sparse_interval_levels.jl @@ -10,21 +10,48 @@ an error if the program tries to write multiple (>=2) runs into SparseInterval. are the types of the arrays used to store positions and endpoints. ```jldoctest -julia> Tensor(SparseInterval(Element(0)), [0, 10, 0]) +julia> Tensor(SparseInterval(Element(0)), [0, 10, 0]) 3-Tensor └─ SparseInterval (0) [1:3] └─ [2:2]: 10 julia> Tensor(SparseInterval(Element(0)), [0, 10, 10]) ERROR: Finch.FinchProtocolError("SparseIntervalLevels can only be updated once") +Stacktrace: + [1] macro expansion + @ ~/Projects/Finch.jl/src/execute.jl:78 [inlined] + [2] macro expansion + @ ~/Projects/Finch.jl/src/util/staging.jl:59 [inlined] + [3] execute_impl(ex::Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparseIntervalLevel{Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}, Finch.FinchNotation.LiteralInstance{0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_1}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.DefineInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:src}, Vector{Int64}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}}}, Finch.FinchNotation.SieveInstance{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:!}, Finch.FinchNotation.LiteralInstance{!}}, Tuple{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:isequal}, Finch.FinchNotation.LiteralInstance{isequal}}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}, Finch.FinchNotation.LiteralInstance{0}}}}}, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparseIntervalLevel{Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.VariableInstance{:dst}}}}}, algebra::Val{Finch.DefaultAlgebra()}, mode::Val{:safe}) + @ Finch ~/Projects/Finch.jl/src/util/staging.jl:51 + [4] execute(ex::Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparseIntervalLevel{Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}, Finch.FinchNotation.LiteralInstance{0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_1}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.DefineInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:src}, Vector{Int64}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}}}, Finch.FinchNotation.SieveInstance{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:!}, Finch.FinchNotation.LiteralInstance{!}}, Tuple{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:isequal}, Finch.FinchNotation.LiteralInstance{isequal}}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}, Finch.FinchNotation.LiteralInstance{0}}}}}, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparseIntervalLevel{Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.VariableInstance{:dst}}}}}; algebra::Finch.DefaultAlgebra, mode::Symbol) + @ Finch ~/Projects/Finch.jl/src/execute.jl:56 + [5] execute + @ ~/Projects/Finch.jl/src/execute.jl:56 [inlined] + [6] macro expansion + @ ~/Projects/Finch.jl/src/execute.jl:185 [inlined] + [7] macro expansion + @ ~/Projects/Finch.jl/src/interface/copy.jl:86 [inlined] + [8] macro expansion + @ ~/Projects/Finch.jl/src/util/staging.jl:59 [inlined] + [9] dropfills_helper!(dst::Tensor{SparseIntervalLevel{Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}, src::Vector{Int64}) + @ Finch ~/Projects/Finch.jl/src/util/staging.jl:51 + [10] dropfills! + @ ~/Projects/Finch.jl/src/interface/copy.jl:75 [inlined] + [11] Tensor(lvl::SparseIntervalLevel{Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}, arr::Vector{Int64}) + @ Finch ~/Projects/Finch.jl/src/tensors/fibers.jl:44 + [12] top-level scope + @ none:1 + +julia> x = Tensor(SparseInterval(Element(0)), 10); + +julia> @finch begin for i = extent(3,6); x[~i] = 1 end end; + +julia> x +10-Tensor +└─ SparseInterval (0) [1:10] + └─ [3:6]: 1 -julia> begin - x = Tensor(SparseInterval(Element(0)), 10); - @finch begin for i = extent(3,6); x[~i] = 1 end end - x - end -SparseInterval (0) [1:10] -└─ [3:6]: 1 ``` """ struct SparseIntervalLevel{Ti, Ptr<:AbstractVector, Left<:AbstractVector, Right<:AbstractVector, Lvl} <: AbstractLevel diff --git a/src/tensors/levels/sparse_point_levels.jl b/src/tensors/levels/sparse_point_levels.jl index c4a1c590f..cbac0db2d 100644 --- a/src/tensors/levels/sparse_point_levels.jl +++ b/src/tensors/levels/sparse_point_levels.jl @@ -11,7 +11,7 @@ an error if the program tries to write multiple (>=2) coordinates into SparsePoi types of the arrays used to store positions and indicies. ```jldoctest -julia> Tensor(Dense(SparsePoint(Element(0.0))), [10 0 0; 0 20 0; 0 0 30]) +julia> Tensor(Dense(SparsePoint(Element(0.0))), [10 0 0; 0 20 0; 0 0 30]) 3×3-Tensor └─ Dense [:,1:3] ├─ [:, 1]: SparsePoint (0.0) [1:3] @@ -23,16 +23,67 @@ julia> Tensor(Dense(SparsePoint(Element(0.0))), [10 0 0; 0 20 0; 0 0 30]) julia> Tensor(Dense(SparsePoint(Element(0.0))), [10 0 0; 0 20 0; 0 40 30]) ERROR: Finch.FinchProtocolError("SparsePointLevels can only be updated once") +Stacktrace: + [1] macro expansion + @ ~/Projects/Finch.jl/src/execute.jl:78 [inlined] + [2] macro expansion + @ ~/Projects/Finch.jl/src/util/staging.jl:59 [inlined] + [3] execute_impl(ex::Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{DenseLevel{Int64, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{0.0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_2}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_1}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.DefineInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:src}, Matrix{Int64}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.SieveInstance{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:!}, Finch.FinchNotation.LiteralInstance{!}}, Tuple{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:isequal}, Finch.FinchNotation.LiteralInstance{isequal}}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}, Finch.FinchNotation.LiteralInstance{0.0}}}}}, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{DenseLevel{Int64, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.VariableInstance{:dst}}}}}, algebra::Val{Finch.DefaultAlgebra()}, mode::Val{:safe}) + @ Finch ~/Projects/Finch.jl/src/util/staging.jl:51 + [4] execute(ex::Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{DenseLevel{Int64, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{0.0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_2}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_1}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.DefineInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:src}, Matrix{Int64}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.SieveInstance{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:!}, Finch.FinchNotation.LiteralInstance{!}}, Tuple{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:isequal}, Finch.FinchNotation.LiteralInstance{isequal}}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}, Finch.FinchNotation.LiteralInstance{0.0}}}}}, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{DenseLevel{Int64, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.VariableInstance{:dst}}}}}; algebra::Finch.DefaultAlgebra, mode::Symbol) + @ Finch ~/Projects/Finch.jl/src/execute.jl:56 + [5] execute + @ ~/Projects/Finch.jl/src/execute.jl:56 [inlined] + [6] macro expansion + @ ~/Projects/Finch.jl/src/execute.jl:185 [inlined] + [7] macro expansion + @ ~/Projects/Finch.jl/src/interface/copy.jl:86 [inlined] + [8] macro expansion + @ ~/Projects/Finch.jl/src/util/staging.jl:59 [inlined] + [9] dropfills_helper!(dst::Tensor{DenseLevel{Int64, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}, src::Matrix{Int64}) + @ Finch ~/Projects/Finch.jl/src/util/staging.jl:51 + [10] dropfills! + @ ~/Projects/Finch.jl/src/interface/copy.jl:75 [inlined] + [11] Tensor(lvl::DenseLevel{Int64, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}, arr::Matrix{Int64}) + @ Finch ~/Projects/Finch.jl/src/tensors/fibers.jl:44 + [12] top-level scope + @ none:1 + +julia> Tensor(SparsePoint(Dense(Element(0.0))), [0 0 0; 0 0 30; 0 0 30]) +3×3-Tensor +└─ SparsePoint (0.0) [:,1:3] + └─ Dense [1:3] + ├─ [1]: 0.0 + ├─ [2]: 30.0 + └─ [3]: 30.0 -julia> Tensor(SparsePoint(Dense(Element(0.0))), [0 0 0; 0 0 30; 0 0 30]) -SparsePoint (0.0) [:,1:3] -└─ Dense [1:3] - ├─ [1]: 0.0 - ├─ [2]: 30.0 - └─ [3]: 30.0 - -julia> Tensor(SparsePoint(SparsePoint(Element(0.0))), [0 0 0; 0 0 30; 0 0 30]) +julia> Tensor(SparsePoint(SparsePoint(Element(0.0))), [0 0 0; 0 0 30; 0 0 30]) ERROR: Finch.FinchProtocolError("SparsePointLevels can only be updated once") +Stacktrace: + [1] macro expansion + @ ~/Projects/Finch.jl/src/execute.jl:78 [inlined] + [2] macro expansion + @ ~/Projects/Finch.jl/src/util/staging.jl:59 [inlined] + [3] execute_impl(ex::Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{0.0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_2}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_1}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.DefineInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:src}, Matrix{Int64}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.SieveInstance{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:!}, Finch.FinchNotation.LiteralInstance{!}}, Tuple{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:isequal}, Finch.FinchNotation.LiteralInstance{isequal}}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}, Finch.FinchNotation.LiteralInstance{0.0}}}}}, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.VariableInstance{:dst}}}}}, algebra::Val{Finch.DefaultAlgebra()}, mode::Val{:safe}) + @ Finch ~/Projects/Finch.jl/src/util/staging.jl:51 + [4] execute(ex::Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{0.0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_2}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_1}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.DefineInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:src}, Matrix{Int64}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.SieveInstance{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:!}, Finch.FinchNotation.LiteralInstance{!}}, Tuple{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:isequal}, Finch.FinchNotation.LiteralInstance{isequal}}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}, Finch.FinchNotation.LiteralInstance{0.0}}}}}, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.VariableInstance{:dst}}}}}; algebra::Finch.DefaultAlgebra, mode::Symbol) + @ Finch ~/Projects/Finch.jl/src/execute.jl:56 + [5] execute + @ ~/Projects/Finch.jl/src/execute.jl:56 [inlined] + [6] macro expansion + @ ~/Projects/Finch.jl/src/execute.jl:185 [inlined] + [7] macro expansion + @ ~/Projects/Finch.jl/src/interface/copy.jl:86 [inlined] + [8] macro expansion + @ ~/Projects/Finch.jl/src/util/staging.jl:59 [inlined] + [9] dropfills_helper!(dst::Tensor{SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}, src::Matrix{Int64}) + @ Finch ~/Projects/Finch.jl/src/util/staging.jl:51 + [10] dropfills! + @ ~/Projects/Finch.jl/src/interface/copy.jl:75 [inlined] + [11] Tensor(lvl::SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}, arr::Matrix{Int64}) + @ Finch ~/Projects/Finch.jl/src/tensors/fibers.jl:44 + [12] top-level scope + @ none:1 ``` """ diff --git a/test/runtests.jl b/test/runtests.jl index 866ed3f69..0dbb89f01 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,7 +3,6 @@ if abspath(PROGRAM_FILE) == @__FILE__ using Pkg Pkg.activate(@__DIR__) Pkg.develop(PackageSpec(path = joinpath(@__DIR__, ".."))) - Pkg.resolve() Pkg.instantiate() end From 98e093be90dd5891c74d1b1391629278dfd6912d Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Sun, 19 May 2024 10:55:14 -0400 Subject: [PATCH 20/22] rm --- Project.toml | 3 +-- test/Project.toml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 6be85aebd..4d5c96f5e 100644 --- a/Project.toml +++ b/Project.toml @@ -47,7 +47,6 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" NPZ = "15e1cf62-19b3-5cfa-8e77-841668bca605" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" @@ -57,7 +56,7 @@ TensorMarket = "8b7d4fe7-0b45-4d0d-9dd8-5cc9b23b4b77" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test", "ArgParse", "LinearAlgebra", "Random", "SparseArrays", "Graphs", "SimpleWeightedGraphs", "HDF5", "NPZ", "Pkg", "TensorMarket", "Documenter", "Literate"] +test = ["Test", "ArgParse", "LinearAlgebra", "Random", "SparseArrays", "Graphs", "SimpleWeightedGraphs", "HDF5", "NPZ", "Pkg", "TensorMarket", "Documenter"] [weakdeps] HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" diff --git a/test/Project.toml b/test/Project.toml index fe90cd67c..6422b2b75 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -11,7 +11,6 @@ Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" MatrixDepot = "b51810bb-c9f3-55da-ae3c-350fc1fbce05" MatrixMarket = "4d4711f2-db25-561a-b6b3-d35e7d4047d3" NPZ = "15e1cf62-19b3-5cfa-8e77-841668bca605" From d4f691f5832999d34e64513bda0e2740558feab1 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Sun, 19 May 2024 12:28:07 -0400 Subject: [PATCH 21/22] delete --- src/tensors/levels/sparse_interval_levels.jl | 28 ---------- src/tensors/levels/sparse_point_levels.jl | 56 -------------------- 2 files changed, 84 deletions(-) diff --git a/src/tensors/levels/sparse_interval_levels.jl b/src/tensors/levels/sparse_interval_levels.jl index 04b92d3c0..c7de4f033 100644 --- a/src/tensors/levels/sparse_interval_levels.jl +++ b/src/tensors/levels/sparse_interval_levels.jl @@ -15,34 +15,6 @@ julia> Tensor(SparseInterval(Element(0)), [0, 10, 0]) └─ SparseInterval (0) [1:3] └─ [2:2]: 10 -julia> Tensor(SparseInterval(Element(0)), [0, 10, 10]) -ERROR: Finch.FinchProtocolError("SparseIntervalLevels can only be updated once") -Stacktrace: - [1] macro expansion - @ ~/Projects/Finch.jl/src/execute.jl:78 [inlined] - [2] macro expansion - @ ~/Projects/Finch.jl/src/util/staging.jl:59 [inlined] - [3] execute_impl(ex::Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparseIntervalLevel{Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}, Finch.FinchNotation.LiteralInstance{0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_1}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.DefineInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:src}, Vector{Int64}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}}}, Finch.FinchNotation.SieveInstance{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:!}, Finch.FinchNotation.LiteralInstance{!}}, Tuple{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:isequal}, Finch.FinchNotation.LiteralInstance{isequal}}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}, Finch.FinchNotation.LiteralInstance{0}}}}}, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparseIntervalLevel{Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.VariableInstance{:dst}}}}}, algebra::Val{Finch.DefaultAlgebra()}, mode::Val{:safe}) - @ Finch ~/Projects/Finch.jl/src/util/staging.jl:51 - [4] execute(ex::Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparseIntervalLevel{Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}, Finch.FinchNotation.LiteralInstance{0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_1}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.DefineInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:src}, Vector{Int64}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}}}, Finch.FinchNotation.SieveInstance{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:!}, Finch.FinchNotation.LiteralInstance{!}}, Tuple{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:isequal}, Finch.FinchNotation.LiteralInstance{isequal}}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}, Finch.FinchNotation.LiteralInstance{0}}}}}, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparseIntervalLevel{Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.VariableInstance{:dst}}}}}; algebra::Finch.DefaultAlgebra, mode::Symbol) - @ Finch ~/Projects/Finch.jl/src/execute.jl:56 - [5] execute - @ ~/Projects/Finch.jl/src/execute.jl:56 [inlined] - [6] macro expansion - @ ~/Projects/Finch.jl/src/execute.jl:185 [inlined] - [7] macro expansion - @ ~/Projects/Finch.jl/src/interface/copy.jl:86 [inlined] - [8] macro expansion - @ ~/Projects/Finch.jl/src/util/staging.jl:59 [inlined] - [9] dropfills_helper!(dst::Tensor{SparseIntervalLevel{Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}}, src::Vector{Int64}) - @ Finch ~/Projects/Finch.jl/src/util/staging.jl:51 - [10] dropfills! - @ ~/Projects/Finch.jl/src/interface/copy.jl:75 [inlined] - [11] Tensor(lvl::SparseIntervalLevel{Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, ElementLevel{0, Int64, Int64, Vector{Int64}}}, arr::Vector{Int64}) - @ Finch ~/Projects/Finch.jl/src/tensors/fibers.jl:44 - [12] top-level scope - @ none:1 - julia> x = Tensor(SparseInterval(Element(0)), 10); julia> @finch begin for i = extent(3,6); x[~i] = 1 end end; diff --git a/src/tensors/levels/sparse_point_levels.jl b/src/tensors/levels/sparse_point_levels.jl index cbac0db2d..5c18623f4 100644 --- a/src/tensors/levels/sparse_point_levels.jl +++ b/src/tensors/levels/sparse_point_levels.jl @@ -21,34 +21,6 @@ julia> Tensor(Dense(SparsePoint(Element(0.0))), [10 0 0; 0 20 0; 0 0 30]) └─ [:, 3]: SparsePoint (0.0) [1:3] └─ 30.0 -julia> Tensor(Dense(SparsePoint(Element(0.0))), [10 0 0; 0 20 0; 0 40 30]) -ERROR: Finch.FinchProtocolError("SparsePointLevels can only be updated once") -Stacktrace: - [1] macro expansion - @ ~/Projects/Finch.jl/src/execute.jl:78 [inlined] - [2] macro expansion - @ ~/Projects/Finch.jl/src/util/staging.jl:59 [inlined] - [3] execute_impl(ex::Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{DenseLevel{Int64, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{0.0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_2}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_1}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.DefineInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:src}, Matrix{Int64}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.SieveInstance{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:!}, Finch.FinchNotation.LiteralInstance{!}}, Tuple{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:isequal}, Finch.FinchNotation.LiteralInstance{isequal}}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}, Finch.FinchNotation.LiteralInstance{0.0}}}}}, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{DenseLevel{Int64, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.VariableInstance{:dst}}}}}, algebra::Val{Finch.DefaultAlgebra()}, mode::Val{:safe}) - @ Finch ~/Projects/Finch.jl/src/util/staging.jl:51 - [4] execute(ex::Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{DenseLevel{Int64, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{0.0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_2}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_1}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.DefineInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:src}, Matrix{Int64}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.SieveInstance{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:!}, Finch.FinchNotation.LiteralInstance{!}}, Tuple{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:isequal}, Finch.FinchNotation.LiteralInstance{isequal}}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}, Finch.FinchNotation.LiteralInstance{0.0}}}}}, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{DenseLevel{Int64, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.VariableInstance{:dst}}}}}; algebra::Finch.DefaultAlgebra, mode::Symbol) - @ Finch ~/Projects/Finch.jl/src/execute.jl:56 - [5] execute - @ ~/Projects/Finch.jl/src/execute.jl:56 [inlined] - [6] macro expansion - @ ~/Projects/Finch.jl/src/execute.jl:185 [inlined] - [7] macro expansion - @ ~/Projects/Finch.jl/src/interface/copy.jl:86 [inlined] - [8] macro expansion - @ ~/Projects/Finch.jl/src/util/staging.jl:59 [inlined] - [9] dropfills_helper!(dst::Tensor{DenseLevel{Int64, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}, src::Matrix{Int64}) - @ Finch ~/Projects/Finch.jl/src/util/staging.jl:51 - [10] dropfills! - @ ~/Projects/Finch.jl/src/interface/copy.jl:75 [inlined] - [11] Tensor(lvl::DenseLevel{Int64, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}, arr::Matrix{Int64}) - @ Finch ~/Projects/Finch.jl/src/tensors/fibers.jl:44 - [12] top-level scope - @ none:1 - julia> Tensor(SparsePoint(Dense(Element(0.0))), [0 0 0; 0 0 30; 0 0 30]) 3×3-Tensor └─ SparsePoint (0.0) [:,1:3] @@ -57,34 +29,6 @@ julia> Tensor(SparsePoint(Dense(Element(0.0))), [0 0 0; 0 0 30; 0 0 30]) ├─ [2]: 30.0 └─ [3]: 30.0 -julia> Tensor(SparsePoint(SparsePoint(Element(0.0))), [0 0 0; 0 0 30; 0 0 30]) -ERROR: Finch.FinchProtocolError("SparsePointLevels can only be updated once") -Stacktrace: - [1] macro expansion - @ ~/Projects/Finch.jl/src/execute.jl:78 [inlined] - [2] macro expansion - @ ~/Projects/Finch.jl/src/util/staging.jl:59 [inlined] - [3] execute_impl(ex::Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{0.0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_2}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_1}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.DefineInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:src}, Matrix{Int64}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.SieveInstance{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:!}, Finch.FinchNotation.LiteralInstance{!}}, Tuple{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:isequal}, Finch.FinchNotation.LiteralInstance{isequal}}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}, Finch.FinchNotation.LiteralInstance{0.0}}}}}, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.VariableInstance{:dst}}}}}, algebra::Val{Finch.DefaultAlgebra()}, mode::Val{:safe}) - @ Finch ~/Projects/Finch.jl/src/util/staging.jl:51 - [4] execute(ex::Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.BlockInstance{Tuple{Finch.FinchNotation.DeclareInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{0.0}}, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_2}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.LoopInstance{Finch.FinchNotation.IndexInstance{:i_1}, Finch.FinchNotation.Dimensionless, Finch.FinchNotation.DefineInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:src}, Matrix{Int64}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Reader()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.SieveInstance{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:!}, Finch.FinchNotation.LiteralInstance{!}}, Tuple{Finch.FinchNotation.CallInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:isequal}, Finch.FinchNotation.LiteralInstance{isequal}}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}, Finch.FinchNotation.LiteralInstance{0.0}}}}}, Finch.FinchNotation.AssignInstance{Finch.FinchNotation.AccessInstance{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:dst}, Tensor{SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.Updater()}, Tuple{Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_1}, Finch.FinchNotation.IndexInstance{:i_1}}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:i_2}, Finch.FinchNotation.IndexInstance{:i_2}}}}, Finch.FinchNotation.LiteralInstance{Finch.FinchNotation.initwrite}, Finch.FinchNotation.TagInstance{Finch.FinchNotation.VariableInstance{:tmp}, Finch.FinchNotation.VariableInstance{:tmp}}}}}}}}}, Finch.FinchNotation.YieldBindInstance{Tuple{Finch.FinchNotation.VariableInstance{:dst}}}}}; algebra::Finch.DefaultAlgebra, mode::Symbol) - @ Finch ~/Projects/Finch.jl/src/execute.jl:56 - [5] execute - @ ~/Projects/Finch.jl/src/execute.jl:56 [inlined] - [6] macro expansion - @ ~/Projects/Finch.jl/src/execute.jl:185 [inlined] - [7] macro expansion - @ ~/Projects/Finch.jl/src/interface/copy.jl:86 [inlined] - [8] macro expansion - @ ~/Projects/Finch.jl/src/util/staging.jl:59 [inlined] - [9] dropfills_helper!(dst::Tensor{SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}, src::Matrix{Int64}) - @ Finch ~/Projects/Finch.jl/src/util/staging.jl:51 - [10] dropfills! - @ ~/Projects/Finch.jl/src/interface/copy.jl:75 [inlined] - [11] Tensor(lvl::SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, SparsePointLevel{Int64, Vector{Int64}, Vector{Int64}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}, arr::Matrix{Int64}) - @ Finch ~/Projects/Finch.jl/src/tensors/fibers.jl:44 - [12] top-level scope - @ none:1 - ``` """ struct SparsePointLevel{Ti, Ptr, Idx, Lvl} <: AbstractLevel From 601c7278ed3f3c9aa4dd038842f6b41b0d5e36be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Sok=C3=B3=C5=82?= Date: Tue, 21 May 2024 10:51:58 +0200 Subject: [PATCH 22/22] Bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4d5c96f5e..bd1e7c9e2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ authors = ["Willow Ahrens"] name = "Finch" uuid = "9177782c-1635-4eb9-9bfb-d9dfa25e6bce" -version = "0.6.28" +version = "0.6.29" [compat] AbstractTrees = "0.3.4, 0.4"