@@ -214,8 +214,10 @@ class SparseTensorStorageBase {
214
214
// / * `added` a map from `[0..count)` to last-level coordinates for
215
215
// / which `filled` is true and `values` contains the assotiated value.
216
216
// / * `count` the size of `added`.
217
+ // / * `expsz` the size of the expanded vector (verification only).
217
218
#define DECL_EXPINSERT (VNAME, V ) \
218
- virtual void expInsert (uint64_t *, V *, bool *, uint64_t *, uint64_t );
219
+ virtual void expInsert (uint64_t *, V *, bool *, uint64_t *, uint64_t , \
220
+ uint64_t );
219
221
MLIR_SPARSETENSOR_FOREVERY_V (DECL_EXPINSERT)
220
222
#undef DECL_EXPINSERT
221
223
@@ -426,7 +428,7 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
426
428
427
429
// / Partially specialize expanded insertions based on template types.
428
430
void expInsert (uint64_t *lvlCoords, V *values, bool *filled, uint64_t *added,
429
- uint64_t count) final {
431
+ uint64_t count, uint64_t expsz ) final {
430
432
assert ((lvlCoords && values && filled && added) && " Received nullptr" );
431
433
if (count == 0 )
432
434
return ;
@@ -435,6 +437,7 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
435
437
// Restore insertion path for first insert.
436
438
const uint64_t lastLvl = getLvlRank () - 1 ;
437
439
uint64_t c = added[0 ];
440
+ assert (c <= expsz);
438
441
assert (filled[c] && " added coordinate is not filled" );
439
442
lvlCoords[lastLvl] = c;
440
443
lexInsert (lvlCoords, values[c]);
@@ -444,6 +447,7 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
444
447
for (uint64_t i = 1 ; i < count; ++i) {
445
448
assert (c < added[i] && " non-lexicographic insertion" );
446
449
c = added[i];
450
+ assert (c <= expsz);
447
451
assert (filled[c] && " added coordinate is not filled" );
448
452
lvlCoords[lastLvl] = c;
449
453
insPath (lvlCoords, lastLvl, added[i - 1 ] + 1 , values[c]);
0 commit comments