Sparse tensor width sugar mirrors dense tensor sugar with an s prefix.
Syntax: sf32[2, 3] | si64[N] | su32[4]
Category
collection
Related
Examples
examples/corpus/sparsa/decl.fab (canonical · type)
sparsa<T, Figura> declaration shell with all-zero vacua.
# sparsa — declaration shell for sparsa<T, Figura>
#
# sparsa<T, Figura> name ← vacua
# functio f(sparsa<T, Figura> value) → sparsa<T, Figura>
#
# GRAMMAR:
# type :← 'sparsa' '<' type ',' shape '>'
#
# EXPECTED OUTPUT:
# Rank and stored non-zero count after round-trip identity call.
functio identity(sparsa<fractus<f32>, [2, 3]> value) → sparsa<fractus<f32>, [2, 3]> {
redde value
}
incipit {
fixum sparsa<fractus<f32>, [2, 3]> empty ← vacua
fixum sparsa<fractus<f32>, [2, 3]> roundtrip ← identity(empty)
nota roundtrip.longitudo(), roundtrip.nonnihil()
}Expected output:
2 0
examples/corpus/sparsa/sugar.fab (canonical · type)
Sparse tensor width sugar mirrors dense tensor sugar with an s prefix.
# STYLE: sparse tensor sugar (sf32, si64[N]) — see docs/design/numeric-type-sugar.md
incipit {
varia sf32[2, 3] grid ← vacua
grid.ponde([0, 1], 4.0)
fixum _ value ← grid.accipe([0, 1])
fixum _ absent ← grid.accipe([1, 2])
fixum _ count ← grid.nonnihil()
fixum tf32[2, 3] dense ← grid.densata()
nota value, absent, count, dense.longitudo()
}Expected output:
4.0 0.0 1 2