@@ -358,6 +358,52 @@ def SparseTensor_ToValuesOp : SparseTensor_Op<"values", [Pure]>,
358
358
let hasVerifier = 1;
359
359
}
360
360
361
+ def SparseTensor_NumberOfEntriesOp : SparseTensor_Op<"number_of_entries", [Pure]>,
362
+ Arguments<(ins AnySparseTensor:$tensor)>,
363
+ Results<(outs Index:$result)> {
364
+ let summary = "Returns the number of entries that are stored in the tensor.";
365
+ let description = [{
366
+ Returns the number of entries that are stored in the given sparse tensor.
367
+ Note that this is typically the number of nonzero elements in the tensor,
368
+ but since explicit zeros may appear in the storage formats, the more
369
+ accurate nomenclature is used.
370
+
371
+ Example:
372
+
373
+ ```mlir
374
+ %noe = sparse_tensor.number_of_entries %tensor : tensor<64x64xf64, #CSR>
375
+ ```
376
+ }];
377
+ let assemblyFormat = "$tensor attr-dict `:` type($tensor)";
378
+ }
379
+
380
+ def SparseTensor_ConcatenateOp : SparseTensor_Op<"concatenate", [Pure]>,
381
+ Arguments<(ins Variadic<AnyRankedTensor>:$inputs, DimensionAttr:$dimension)>,
382
+ Results<(outs AnyRankedTensor:$result)> {
383
+
384
+ let summary = "Concatenates a list of tensors into a single tensor.";
385
+ let description = [{
386
+ Concatenates a list input tensors and the output tensor with the same
387
+ dimension-rank. The concatenation happens on the specified `dimension`
388
+ (0 <= dimension < dimRank). The resulting `dimension` size is the
389
+ sum of all the input sizes for that dimension, while all the other
390
+ dimensions should have the same size in the input and output tensors.
391
+
392
+ Only statically-sized input tensors are accepted, while the output tensor
393
+ can be dynamically-sized.
394
+
395
+ Example:
396
+
397
+ ```mlir
398
+ %0 = sparse_tensor.concatenate %1, %2 { dimension = 0 : index }
399
+ : tensor<64x64xf64, #CSR>, tensor<64x64xf64, #CSR> to tensor<128x64xf64, #CSR>
400
+ ```
401
+ }];
402
+
403
+ let assemblyFormat = "$inputs attr-dict `:` type($inputs) `to` type($result)";
404
+ let hasVerifier = 1;
405
+ }
406
+
361
407
def SparseTensor_ToSliceOffsetOp : SparseTensor_Op<"slice.offset", [Pure]>,
362
408
Arguments<(ins AnySparseTensorSlice:$slice, IndexAttr:$dim)>,
363
409
Results<(outs Index:$offset)> {
@@ -413,7 +459,12 @@ def SparseTensor_ToSliceStrideOp : SparseTensor_Op<"slice.stride", [Pure]>,
413
459
let hasVerifier = 1;
414
460
}
415
461
416
- def SparseTensor_StorageSpecifierInitOp : SparseTensor_Op<"storage_specifier.init", [Pure]>,
462
+ //===----------------------------------------------------------------------===//
463
+ // Sparse Tensor Storage Specifier Operations.
464
+ //===----------------------------------------------------------------------===//
465
+
466
+ def SparseTensor_StorageSpecifierInitOp : SparseTensor_Op<"storage_specifier.init",
467
+ [Pure]>,
417
468
Arguments<(ins Optional<SparseTensorStorageSpecifier>:$source)>,
418
469
Results<(outs SparseTensorStorageSpecifier:$result)> {
419
470
let summary = "";
@@ -501,52 +552,6 @@ def SparseTensor_SetStorageSpecifierOp : SparseTensor_Op<"storage_specifier.set"
501
552
let hasVerifier = 1;
502
553
}
503
554
504
- def SparseTensor_NumberOfEntriesOp : SparseTensor_Op<"number_of_entries", [Pure]>,
505
- Arguments<(ins AnySparseTensor:$tensor)>,
506
- Results<(outs Index:$result)> {
507
- let summary = "Returns the number of entries that are stored in the tensor.";
508
- let description = [{
509
- Returns the number of entries that are stored in the given sparse tensor.
510
- Note that this is typically the number of nonzero elements in the tensor,
511
- but since explicit zeros may appear in the storage formats, the more
512
- accurate nomenclature is used.
513
-
514
- Example:
515
-
516
- ```mlir
517
- %noe = sparse_tensor.number_of_entries %tensor : tensor<64x64xf64, #CSR>
518
- ```
519
- }];
520
- let assemblyFormat = "$tensor attr-dict `:` type($tensor)";
521
- }
522
-
523
- def SparseTensor_ConcatenateOp : SparseTensor_Op<"concatenate", [Pure]>,
524
- Arguments<(ins Variadic<AnyRankedTensor>:$inputs, DimensionAttr:$dimension)>,
525
- Results<(outs AnyRankedTensor:$result)> {
526
-
527
- let summary = "Concatenates a list of tensors into a single tensor.";
528
- let description = [{
529
- Concatenates a list input tensors and the output tensor with the same
530
- dimension-rank. The concatenation happens on the specified `dimension`
531
- (0 <= dimension < dimRank). The resulting `dimension` size is the
532
- sum of all the input sizes for that dimension, while all the other
533
- dimensions should have the same size in the input and output tensors.
534
-
535
- Only statically-sized input tensors are accepted, while the output tensor
536
- can be dynamically-sized.
537
-
538
- Example:
539
-
540
- ```mlir
541
- %0 = sparse_tensor.concatenate %1, %2 { dimension = 0 : index }
542
- : tensor<64x64xf64, #CSR>, tensor<64x64xf64, #CSR> to tensor<128x64xf64, #CSR>
543
- ```
544
- }];
545
-
546
- let assemblyFormat = "$inputs attr-dict `:` type($inputs) `to` type($result)";
547
- let hasVerifier = 1;
548
- }
549
-
550
555
//===----------------------------------------------------------------------===//
551
556
// Sparse Tensor Management Operations. These operations are "impure" in the
552
557
// sense that some behavior is defined by side-effects. These operations provide
@@ -803,6 +808,10 @@ def SparseTensor_OutOp : SparseTensor_Op<"out", []>,
803
808
let assemblyFormat = "$tensor `,` $dest attr-dict `:` type($tensor) `,` type($dest)";
804
809
}
805
810
811
+ //===----------------------------------------------------------------------===//
812
+ // Sparse Tensor Sorting Operations.
813
+ //===----------------------------------------------------------------------===//
814
+
806
815
def SparseTensor_SortOp : SparseTensor_Op<"sort", [AttrSizedOperandSegments]>,
807
816
// TODO: May want to extend tablegen with
808
817
// class NonemptyVariadic<Type type> : Variadic<type> { let minSize = 1; }
0 commit comments