@@ -21,19 +21,22 @@ namespace sparse_tensor {
21
21
22
22
// /===----------------------------------------------------------------------===//
23
23
// / The sparse tensor storage scheme for a tensor is organized as a single
24
- // / compound type with the following fields. Note that every memref with ? size
25
- // / actually behaves as a "vector", i.e. the stored size is the capacity and the
26
- // / used size resides in the storage_specifier struct.
24
+ // / compound type with the following fields. Note that every memref with `?`
25
+ // / size actually behaves as a "vector", i.e. the stored size is the capacity
26
+ // / and the used size resides in the storage_specifier struct.
27
27
// /
28
28
// / struct {
29
29
// / ; per-level l:
30
30
// / ; if dense:
31
31
// / <nothing>
32
- // / ; if compresed:
33
- // / memref<? x pos> positions-l ; positions for sparse level l
34
- // / memref<? x crd> coordinates-l ; coordinates for sparse level l
35
- // / ; if singleton:
36
- // / memref<? x crd> coordinates-l ; coordinates for singleton level l
32
+ // / ; if compressed:
33
+ // / memref<? x pos> positions ; positions for level l
34
+ // / memref<? x crd> coordinates ; coordinates for level l
35
+ // / ; if loose-compressed:
36
+ // / memref<? x pos> positions ; lo/hi position pairs for level l
37
+ // / memref<? x crd> coordinates ; coordinates for level l
38
+ // / ; if singleton/2-out-of-4:
39
+ // / memref<? x crd> coordinates ; coordinates for level l
37
40
// /
38
41
// / memref<? x eltType> values ; values
39
42
// /
@@ -59,25 +62,25 @@ namespace sparse_tensor {
59
62
// / Examples.
60
63
// /
61
64
// / #CSR storage of 2-dim matrix yields
62
- // / memref<?xindex> ; positions-1
63
- // / memref<?xindex> ; coordinates-1
64
- // / memref<?xf64> ; values
65
- // / struct<(array<2 x i64>, array<3 x i64>)>) ; lvl0, lvl1, 3xsizes
65
+ // / memref<?xindex> ; positions-1
66
+ // / memref<?xindex> ; coordinates-1
67
+ // / memref<?xf64> ; values
68
+ // / struct<(array<2 x i64>, array<3 x i64>)>) ; lvl0, lvl1, 3xsizes
66
69
// /
67
70
// / #COO storage of 2-dim matrix yields
68
- // / memref<?xindex>, ; positions-0, essentially
69
- // / [0,sz] memref<?xindex> ; AOS coordinates storage
70
- // / memref<?xf64> ; values
71
- // / struct<(array<2 x i64>, array<3 x i64>)>) ; lvl0, lvl1, 3xsizes
71
+ // / memref<?xindex>, ; positions-0, essentially [0,sz]
72
+ // / memref<?xindex> ; AOS coordinates storage
73
+ // / memref<?xf64> ; values
74
+ // / struct<(array<2 x i64>, array<3 x i64>)>) ; lvl0, lvl1, 3xsizes
72
75
// /
73
76
// / Slice on #COO storage of 2-dim matrix yields
74
- // / ;; Inherited from the original sparse tensors
75
- // / memref<?xindex>, ; positions-0, essentially
76
- // / [0,sz] memref<?xindex> ; AOS coordinates storage
77
- // / memref<?xf64> ; values
78
- // / struct<(array<2 x i64>, array<3 x i64>, ; lvl0, lvl1, 3xsizes
79
- // / ;; Extra slicing-metadata
80
- // / array<2 x i64>, array<2 x i64>)>) ; dim offset, dim stride.
77
+ // / ;; Inherited from the original sparse tensors
78
+ // / memref<?xindex>, ; positions-0, essentially [0,sz]
79
+ // / memref<?xindex> ; AOS coordinates storage
80
+ // / memref<?xf64> ; values
81
+ // / struct<(array<2 x i64>, array<3 x i64>, ; lvl0, lvl1, 3xsizes
82
+ // / ;; Extra slicing-metadata
83
+ // / array<2 x i64>, array<2 x i64>)>) ; dim offset, dim stride.
81
84
// /
82
85
// /===----------------------------------------------------------------------===//
83
86
@@ -107,9 +110,6 @@ using FieldIndex = unsigned;
107
110
// / encoding.
108
111
class StorageLayout {
109
112
public:
110
- // TODO: Functions/methods marked with [NUMFIELDS] should use
111
- // `FieldIndex` for their return type, via the same reasoning for why
112
- // `Dimension`/`Level` are used both for identifiers and ranks.
113
113
explicit StorageLayout (const SparseTensorType &stt)
114
114
: StorageLayout(stt.getEncoding()) {}
115
115
explicit StorageLayout (SparseTensorEncodingAttr enc) : enc(enc) {
@@ -154,12 +154,10 @@ class StorageLayout {
154
154
// Wrapper functions to invoke StorageLayout-related method.
155
155
//
156
156
157
- // See note [NUMFIELDS].
158
157
inline unsigned getNumFieldsFromEncoding (SparseTensorEncodingAttr enc) {
159
158
return StorageLayout (enc).getNumFields ();
160
159
}
161
160
162
- // See note [NUMFIELDS].
163
161
inline unsigned getNumDataFieldsFromEncoding (SparseTensorEncodingAttr enc) {
164
162
return StorageLayout (enc).getNumDataFields ();
165
163
}
0 commit comments