Skip to content

Commit 6ca47eb

Browse files
authored
[mlir][sparse] rename sparse_tensor.(un)pack to sparse_tensor.(dis)as… (#67717)
…semble Pack/Unpack are overridden in many other places, rename the operations to avoid confusion.
1 parent 9f2fc88 commit 6ca47eb

File tree

13 files changed

+62
-58
lines changed

13 files changed

+62
-58
lines changed

mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ def SparseTensor_NewOp : SparseTensor_Op<"new", [Pure]>,
5353
let assemblyFormat = "$source attr-dict `:` type($source) `to` type($result)";
5454
}
5555

56-
def SparseTensor_PackOp : SparseTensor_Op<"pack", [Pure]>,
56+
def SparseTensor_AssembleOp : SparseTensor_Op<"assemble", [Pure]>,
5757
Arguments<(ins TensorOf<[AnyType]>:$values,
5858
Variadic<TensorOf<[AnySignlessIntegerOrIndex]>>:$levels)>,
5959
Results<(outs AnySparseTensor: $result)> {
6060
let summary = "Returns a sparse tensor from the given values, levels";
6161

6262
let description = [{
63-
Packs the values and per-level coordinate or postion arrays into a sparse tensor.
63+
Assembles the values and per-level coordinate or postion arrays into a sparse tensor.
6464
The order and types of provided levels must be consistent with the actual storage
6565
layout of the returned sparse tensor described below.
6666

@@ -87,7 +87,7 @@ def SparseTensor_PackOp : SparseTensor_Op<"pack", [Pure]>,
8787
```mlir
8888
%values = arith.constant dense<[ 1.1, 2.2, 3.3 ]> : tensor<3xf64>
8989
%coordinates = arith.constant dense<[[0,0], [1,2], [1,3]]> : tensor<3x2xindex>
90-
%st = sparse_tensor.pack %values, %coordinates
90+
%st = sparse_tensor.assemble %values, %coordinates
9191
: tensor<3xf64>, tensor<3x2xindex> to tensor<3x4xf64, #COO>
9292
// yields COO format |1.1, 0.0, 0.0, 0.0|
9393
// of 3x4 matrix |0.0, 0.0, 2.2, 3.3|
@@ -102,7 +102,7 @@ def SparseTensor_PackOp : SparseTensor_Op<"pack", [Pure]>,
102102
let hasVerifier = 1;
103103
}
104104

105-
def SparseTensor_UnpackOp : SparseTensor_Op<"unpack", [Pure, SameVariadicResultSize]>,
105+
def SparseTensor_DisassembleOp : SparseTensor_Op<"disassemble", [Pure, SameVariadicResultSize]>,
106106
Arguments<(ins AnySparseTensor:$tensor,
107107
TensorOf<[AnyType]>:$out_values,
108108
Variadic<TensorOf<[AnySignlessIntegerOrIndex]>>:$out_levels)>,
@@ -113,7 +113,7 @@ def SparseTensor_UnpackOp : SparseTensor_Op<"unpack", [Pure, SameVariadicResultS
113113
let summary = "Returns the (values, coordinates) pair unpacked from the input tensor";
114114

115115
let description = [{
116-
The unpack operation is the inverse of `sparse_tensor::pack`. It returns
116+
The disassemble operation is the inverse of `sparse_tensor::assemble`. It returns
117117
the values and per-level position and coordinate array to the user
118118
from the sparse tensor along with the actual length of the memory used in
119119
each returned buffer. This operation can be used for returning an
@@ -132,7 +132,7 @@ def SparseTensor_UnpackOp : SparseTensor_Op<"unpack", [Pure, SameVariadicResultS
132132
// of 3x4 matrix |0.0, 0.0, 2.2, 3.3|
133133
// |0.0, 0.0, 0.0, 0.0|
134134
%v, %p, %c, %v_len, %p_len, %c_len =
135-
sparse_tensor.unpack %sp : tensor<3x4xf64, #COO>
135+
sparse_tensor.disassemble %sp : tensor<3x4xf64, #COO>
136136
outs(%od, %op, %oi : tensor<3xf64>, tensor<2xindex>, tensor<3x2xindex>)
137137
-> tensor<3xf64>, (tensor<2xindex>, tensor<3x2xindex>), index, (index, index)
138138
// %v = arith.constant dense<[ 1.1, 2.2, 3.3 ]> : tensor<3xf64>

mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,14 +974,14 @@ static LogicalResult verifyPackUnPack(Operation *op, bool requiresStaticShape,
974974
return success();
975975
}
976976

977-
LogicalResult PackOp::verify() {
977+
LogicalResult AssembleOp::verify() {
978978
const auto valuesTp = getRankedTensorType(getValues());
979979
const auto lvlsTp = getLevels().getTypes();
980980
const auto resTp = getSparseTensorType(getResult());
981981
return verifyPackUnPack(*this, true, resTp, valuesTp, lvlsTp);
982982
}
983983

984-
LogicalResult UnpackOp::verify() {
984+
LogicalResult DisassembleOp::verify() {
985985
if (getOutValues().getType() != getRetValues().getType())
986986
return emitError("output values and return value type mismatch");
987987

mlir/lib/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ struct NewOpInterface
122122
bool bufferizesToAllocation(Operation *op, Value value) const { return true; }
123123
};
124124

125-
struct PackOpInterface
126-
: public SparseBufferizableOpInterfaceExternalModel<PackOpInterface,
127-
sparse_tensor::PackOp> {
125+
struct AssembleOpInterface
126+
: public SparseBufferizableOpInterfaceExternalModel<
127+
AssembleOpInterface, sparse_tensor::AssembleOp> {
128128
bool bufferizesToAllocation(Operation *op, Value value) const {
129-
// PackOp reuses all the buffers instead of allocating new ones
129+
// AssembleOp reuses all the buffers instead of allocating new ones
130130
return false;
131131
}
132132

@@ -143,7 +143,7 @@ struct PackOpInterface
143143
AliasingValueList getAliasingValues(Operation *op, OpOperand &opOperand,
144144
const AnalysisState &state) const {
145145
assert(op->getNumResults() == 1);
146-
// PackOp reuses the input tensors as values/coordinates instead of
146+
// AssembleOp reuses the input tensors as values/coordinates instead of
147147
// creating new ones when packing into a COO format.
148148
return {{op->getOpResult(0), BufferRelation::Equivalent}};
149149
}
@@ -154,8 +154,9 @@ struct PackOpInterface
154154
}
155155
};
156156

157-
struct UnpackOpInterface : public SparseBufferizableOpInterfaceExternalModel<
158-
UnpackOpInterface, sparse_tensor::UnpackOp> {
157+
struct DisassembleOpInterface
158+
: public SparseBufferizableOpInterfaceExternalModel<
159+
DisassembleOpInterface, sparse_tensor::DisassembleOp> {
159160
bool bufferizesToAllocation(Operation *op, Value value) const {
160161
// The output buffer is pre-allocated by the user.
161162
return false;
@@ -326,8 +327,8 @@ void mlir::sparse_tensor::registerBufferizableOpInterfaceExternalModels(
326327
sparse_tensor::InsertOp::attachInterface<InsertOpInterface>(*ctx);
327328
sparse_tensor::NumberOfEntriesOp::attachInterface<
328329
NumberOfEntriesOpInterface>(*ctx);
329-
sparse_tensor::PackOp::attachInterface<PackOpInterface>(*ctx);
330-
sparse_tensor::UnpackOp::attachInterface<UnpackOpInterface>(*ctx);
330+
sparse_tensor::AssembleOp::attachInterface<AssembleOpInterface>(*ctx);
331+
sparse_tensor::DisassembleOp::attachInterface<DisassembleOpInterface>(*ctx);
331332
sparse_tensor::ToCoordinatesBufferOp::attachInterface<
332333
ToCoordinatesBufferOpInterface>(*ctx);
333334
sparse_tensor::ToCoordinatesOp::attachInterface<ToCoordinatesOpInterface>(

mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,10 +795,10 @@ rewriteSpGEMM(PatternRewriter &rewriter, linalg::GenericOp op, bool enableRT,
795795
Value rowC = e1.getResult(0);
796796
token = e1.getAsyncToken();
797797
auto e2 = genAllocBuffer(rewriter, loc, cTp.getCrdType(), zero, token);
798-
Value colC = e2.getResult(0); // no free needed
798+
Value colC = e2.getResult(0); // no free needed
799799
token = e2.getAsyncToken();
800800
auto e3 = genAllocBuffer(rewriter, loc, dnCType, zero, token);
801-
Value valC = e3.getResult(0); // no free needed
801+
Value valC = e3.getResult(0); // no free needed
802802
token = e3.getAsyncToken();
803803
Operation *spGenC =
804804
genSpMat(rewriter, loc, spmatHandleTp, tokenTp, token, szm, szn, zero,
@@ -900,7 +900,8 @@ rewriteSpGEMM(PatternRewriter &rewriter, linalg::GenericOp op, bool enableRT,
900900
Value vt = rewriter.create<bufferization::ToTensorOp>(loc, valH);
901901
Value rt = rewriter.create<bufferization::ToTensorOp>(loc, rowH);
902902
Value ct = rewriter.create<bufferization::ToTensorOp>(loc, colH);
903-
rewriter.replaceOpWithNewOp<PackOp>(op, c.getType(), vt, ValueRange{rt, ct});
903+
rewriter.replaceOpWithNewOp<AssembleOp>(op, c.getType(), vt,
904+
ValueRange{rt, ct});
904905
return success();
905906
}
906907

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,10 +1244,10 @@ class SparseNumberOfEntriesConverter
12441244
}
12451245
};
12461246

1247-
struct SparsePackOpConverter : public OpConversionPattern<PackOp> {
1247+
struct SparseAssembleOpConverter : public OpConversionPattern<AssembleOp> {
12481248
using OpConversionPattern::OpConversionPattern;
12491249
LogicalResult
1250-
matchAndRewrite(PackOp op, OpAdaptor adaptor,
1250+
matchAndRewrite(AssembleOp op, OpAdaptor adaptor,
12511251
ConversionPatternRewriter &rewriter) const override {
12521252
Location loc = op.getLoc();
12531253
const auto stt = getSparseTensorType(op.getResult());
@@ -1347,13 +1347,15 @@ struct SparsePackOpConverter : public OpConversionPattern<PackOp> {
13471347
}
13481348
};
13491349

1350-
struct SparseUnpackOpConverter : public OpConversionPattern<UnpackOp> {
1350+
struct SparseDisassembleOpConverter
1351+
: public OpConversionPattern<DisassembleOp> {
13511352
using OpConversionPattern::OpConversionPattern;
1352-
SparseUnpackOpConverter(TypeConverter &typeConverter, MLIRContext *context)
1353+
SparseDisassembleOpConverter(TypeConverter &typeConverter,
1354+
MLIRContext *context)
13531355
: OpConversionPattern(typeConverter, context) {}
13541356

13551357
LogicalResult
1356-
matchAndRewrite(UnpackOp op, OpAdaptor adaptor,
1358+
matchAndRewrite(DisassembleOp op, OpAdaptor adaptor,
13571359
ConversionPatternRewriter &rewriter) const override {
13581360
auto desc = getDescriptorFromTensorTuple(adaptor.getTensor());
13591361
Location loc = op.getLoc();
@@ -1571,7 +1573,7 @@ struct SparseNewOpConverter : public OpConversionPattern<NewOp> {
15711573
void mlir::populateSparseTensorCodegenPatterns(
15721574
TypeConverter &typeConverter, RewritePatternSet &patterns,
15731575
bool createSparseDeallocs, bool enableBufferInitialization) {
1574-
patterns.add<SparsePackOpConverter, SparseUnpackOpConverter,
1576+
patterns.add<SparseAssembleOpConverter, SparseDisassembleOpConverter,
15751577
SparseReturnConverter, SparseCallConverter, SparseDimOpConverter,
15761578
SparseCastConverter, SparseExtractSliceConverter,
15771579
SparseTensorLoadConverter, SparseExpandConverter,

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,15 +1493,15 @@ class SparseTensorOutConverter : public OpConversionPattern<OutOp> {
14931493
};
14941494

14951495
/// Sparse conversion rule for the sparse_tensor.pack operator.
1496-
class SparseTensorPackConverter : public OpConversionPattern<PackOp> {
1496+
class SparseTensorAssembleConverter : public OpConversionPattern<AssembleOp> {
14971497
public:
14981498
using OpConversionPattern::OpConversionPattern;
14991499
LogicalResult
1500-
matchAndRewrite(PackOp op, OpAdaptor adaptor,
1500+
matchAndRewrite(AssembleOp op, OpAdaptor adaptor,
15011501
ConversionPatternRewriter &rewriter) const override {
15021502
const Location loc = op->getLoc();
15031503
const auto dstTp = getSparseTensorType(op.getResult());
1504-
// PackOps always returns a static shaped tensor result.
1504+
// AssembleOps always returns a static shaped tensor result.
15051505
assert(dstTp.hasStaticDimShape());
15061506
SmallVector<Value> dimSizes = getDimSizes(rewriter, loc, dstTp);
15071507
Value dst =
@@ -1546,7 +1546,7 @@ void mlir::populateSparseTensorConversionPatterns(
15461546
SparseTensorToValuesConverter, SparseNumberOfEntriesConverter,
15471547
SparseTensorLoadConverter, SparseTensorInsertConverter,
15481548
SparseTensorExpandConverter, SparseTensorCompressConverter,
1549-
SparseTensorOutConverter, SparseTensorPackConverter>(
1549+
SparseTensorOutConverter, SparseTensorAssembleConverter>(
15501550
typeConverter, patterns.getContext());
15511551
patterns.add<SparseTensorConvertConverter>(typeConverter,
15521552
patterns.getContext(), options);

mlir/test/Dialect/SparseTensor/GPU/gpu_spgemm_lib.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
// CHECK: %[[VAL_a2:.*]] = bufferization.to_tensor %[[VAL_83]] : memref<?xf32>
8787
// CHECK: %[[VAL_a3:.*]] = bufferization.to_tensor %[[VAL_81]] : memref<?xindex>
8888
// CHECK: %[[VAL_a4:.*]] = bufferization.to_tensor %[[VAL_82]] : memref<?xindex>
89-
// CHECK: %[[VAL_a5:.*]] = sparse_tensor.pack %[[VAL_a2]], %[[VAL_a3]], %[[VAL_a4]] : tensor<?xf32>, tensor<?xindex>, tensor<?xindex> to tensor<8x8xf32, #{{.*}}>
89+
// CHECK: %[[VAL_a5:.*]] = sparse_tensor.assemble %[[VAL_a2]], %[[VAL_a3]], %[[VAL_a4]] : tensor<?xf32>, tensor<?xindex>, tensor<?xindex> to tensor<8x8xf32, #{{.*}}>
9090
// CHECK: return %[[VAL_a5]] : tensor<8x8xf32, #{{.*}}>
9191
// CHECK: }
9292
func.func @matmulCSR(%A: tensor<8x8xf32, #CSR>,

mlir/test/Dialect/SparseTensor/invalid.mlir

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func.func @invalid_new_dense(%arg0: !llvm.ptr<i8>) -> tensor<32xf32> {
1313
func.func @non_static_pack_ret(%values: tensor<6xf64>, %pos: tensor<2xi32>, %coordinates: tensor<6x1xi32>)
1414
-> tensor<?xf64, #SparseVector> {
1515
// expected-error@+1 {{the sparse-tensor must have static shape}}
16-
%0 = sparse_tensor.pack %values, %pos, %coordinates
16+
%0 = sparse_tensor.assemble %values, %pos, %coordinates
1717
: tensor<6xf64>, tensor<2xi32>, tensor<6x1xi32> to tensor<?xf64, #SparseVector>
1818
return %0 : tensor<?xf64, #SparseVector>
1919
}
@@ -25,7 +25,7 @@ func.func @non_static_pack_ret(%values: tensor<6xf64>, %pos: tensor<2xi32>, %coo
2525
func.func @invalid_pack_type(%values: tensor<6xf64>, %pos: tensor<2xi32>, %coordinates: tensor<6x1xi32>)
2626
-> tensor<100xf32, #SparseVector> {
2727
// expected-error@+1 {{input/output element-types don't match}}
28-
%0 = sparse_tensor.pack %values, %pos, %coordinates
28+
%0 = sparse_tensor.assemble %values, %pos, %coordinates
2929
: tensor<6xf64>, tensor<2xi32>, tensor<6x1xi32> to tensor<100xf32, #SparseVector>
3030
return %0 : tensor<100xf32, #SparseVector>
3131
}
@@ -37,7 +37,7 @@ func.func @invalid_pack_type(%values: tensor<6xf64>, %pos: tensor<2xi32>, %coord
3737
func.func @invalid_pack_type(%values: tensor<6xf64>, %pos: tensor<2xi32>, %coordinates: tensor<6x3xi32>)
3838
-> tensor<100x2xf64, #SparseVector> {
3939
// expected-error@+1 {{input/output trailing COO level-ranks don't match}}
40-
%0 = sparse_tensor.pack %values, %pos, %coordinates
40+
%0 = sparse_tensor.assemble %values, %pos, %coordinates
4141
: tensor<6xf64>, tensor<2xi32>, tensor<6x3xi32> to tensor<100x2xf64, #SparseVector>
4242
return %0 : tensor<100x2xf64, #SparseVector>
4343
}
@@ -49,7 +49,7 @@ func.func @invalid_pack_type(%values: tensor<6xf64>, %pos: tensor<2xi32>, %coord
4949
func.func @invalid_pack_mis_position(%values: tensor<6xf64>, %coordinates: tensor<6xi32>)
5050
-> tensor<2x100xf64, #CSR> {
5151
// expected-error@+1 {{inconsistent number of fields between input/output}}
52-
%0 = sparse_tensor.pack %values, %coordinates
52+
%0 = sparse_tensor.assemble %values, %coordinates
5353
: tensor<6xf64>, tensor<6xi32> to tensor<2x100xf64, #CSR>
5454
return %0 : tensor<2x100xf64, #CSR>
5555
}
@@ -60,7 +60,7 @@ func.func @invalid_pack_mis_position(%values: tensor<6xf64>, %coordinates: tenso
6060

6161
func.func @invalid_unpack_type(%sp: tensor<100xf32, #SparseVector>, %values: tensor<6xf64>, %pos: tensor<2xi32>, %coordinates: tensor<6x1xi32>) {
6262
// expected-error@+1 {{input/output element-types don't match}}
63-
%rv, %rp, %rc, %vl, %pl, %cl = sparse_tensor.unpack %sp : tensor<100xf32, #SparseVector>
63+
%rv, %rp, %rc, %vl, %pl, %cl = sparse_tensor.disassemble %sp : tensor<100xf32, #SparseVector>
6464
outs(%values, %pos, %coordinates : tensor<6xf64>, tensor<2xi32>, tensor<6x1xi32>)
6565
-> tensor<6xf64>, (tensor<2xi32>, tensor<6x1xi32>), index, (index, index)
6666
return
@@ -72,7 +72,7 @@ func.func @invalid_unpack_type(%sp: tensor<100xf32, #SparseVector>, %values: ten
7272

7373
func.func @invalid_unpack_type(%sp: tensor<100x2xf64, #SparseVector>, %values: tensor<6xf64>, %pos: tensor<2xi32>, %coordinates: tensor<6x3xi32>) {
7474
// expected-error@+1 {{input/output trailing COO level-ranks don't match}}
75-
%rv, %rp, %rc, %vl, %pl, %cl = sparse_tensor.unpack %sp : tensor<100x2xf64, #SparseVector>
75+
%rv, %rp, %rc, %vl, %pl, %cl = sparse_tensor.disassemble %sp : tensor<100x2xf64, #SparseVector>
7676
outs(%values, %pos, %coordinates : tensor<6xf64>, tensor<2xi32>, tensor<6x3xi32>)
7777
-> tensor<6xf64>, (tensor<2xi32>, tensor<6x3xi32>), index, (index, index)
7878
return
@@ -84,7 +84,7 @@ func.func @invalid_unpack_type(%sp: tensor<100x2xf64, #SparseVector>, %values: t
8484

8585
func.func @invalid_unpack_mis_position(%sp: tensor<2x100xf64, #CSR>, %values: tensor<6xf64>, %coordinates: tensor<6xi32>) {
8686
// expected-error@+1 {{inconsistent number of fields between input/output}}
87-
%rv, %rc, %vl, %pl = sparse_tensor.unpack %sp : tensor<2x100xf64, #CSR>
87+
%rv, %rc, %vl, %pl = sparse_tensor.disassemble %sp : tensor<2x100xf64, #CSR>
8888
outs(%values, %coordinates : tensor<6xf64>, tensor<6xi32>)
8989
-> tensor<6xf64>, (tensor<6xi32>), index, (index)
9090
return

mlir/test/Dialect/SparseTensor/pack_copy.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func.func @foo(%arg0: tensor<3xf64> {bufferization.writable = false},
3535
//
3636
// Pack the buffers into a sparse tensors.
3737
//
38-
%pack = sparse_tensor.pack %arg0, %arg2, %arg1
38+
%pack = sparse_tensor.assemble %arg0, %arg2, %arg1
3939
: tensor<3xf64>,
4040
tensor<11xi32>,
4141
tensor<3xi32> to tensor<10x10xf64, #CSR>
@@ -76,7 +76,7 @@ func.func @bar(%arg0: tensor<3xf64> {bufferization.writable = true},
7676
//
7777
// Pack the buffers into a sparse tensors.
7878
//
79-
%pack = sparse_tensor.pack %arg0, %arg2, %arg1
79+
%pack = sparse_tensor.assemble %arg0, %arg2, %arg1
8080
: tensor<3xf64>,
8181
tensor<11xi32>,
8282
tensor<3xi32> to tensor<10x10xf64, #CSR>

mlir/test/Dialect/SparseTensor/roundtrip.mlir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ func.func @sparse_new(%arg0: !llvm.ptr<i8>) -> tensor<128xf64, #SparseVector> {
1919
// CHECK-SAME: %[[D:.*]]: tensor<6xf64>,
2020
// CHECK-SAME: %[[P:.*]]: tensor<2xi32>,
2121
// CHECK-SAME: %[[I:.*]]: tensor<6x1xi32>)
22-
// CHECK: %[[R:.*]] = sparse_tensor.pack %[[D]], %[[P]], %[[I]]
22+
// CHECK: %[[R:.*]] = sparse_tensor.assemble %[[D]], %[[P]], %[[I]]
2323
// CHECK: return %[[R]] : tensor<100xf64, #{{.*}}>
2424
func.func @sparse_pack(%data: tensor<6xf64>, %pos: tensor<2xi32>, %index: tensor<6x1xi32>)
2525
-> tensor<100xf64, #SparseVector> {
26-
%0 = sparse_tensor.pack %data, %pos, %index : tensor<6xf64>, tensor<2xi32>, tensor<6x1xi32>
26+
%0 = sparse_tensor.assemble %data, %pos, %index : tensor<6xf64>, tensor<2xi32>, tensor<6x1xi32>
2727
to tensor<100xf64, #SparseVector>
2828
return %0 : tensor<100xf64, #SparseVector>
2929
}
@@ -36,14 +36,14 @@ func.func @sparse_pack(%data: tensor<6xf64>, %pos: tensor<2xi32>, %index: tensor
3636
// CHECK-SAME: %[[OD:.*]]: tensor<6xf64>
3737
// CHECK-SAME: %[[OP:.*]]: tensor<2xindex>
3838
// CHECK-SAME: %[[OI:.*]]: tensor<6x1xi32>
39-
// CHECK: %[[D:.*]], %[[P:.*]]:2, %[[DL:.*]], %[[PL:.*]]:2 = sparse_tensor.unpack %[[T]]
39+
// CHECK: %[[D:.*]], %[[P:.*]]:2, %[[DL:.*]], %[[PL:.*]]:2 = sparse_tensor.disassemble %[[T]]
4040
// CHECK: return %[[D]], %[[P]]#0, %[[P]]#1
4141
func.func @sparse_unpack(%sp : tensor<100xf64, #SparseVector>,
4242
%od : tensor<6xf64>,
4343
%op : tensor<2xindex>,
4444
%oi : tensor<6x1xi32>)
4545
-> (tensor<6xf64>, tensor<2xindex>, tensor<6x1xi32>) {
46-
%rd, %rp, %ri, %vl, %pl, %cl = sparse_tensor.unpack %sp : tensor<100xf64, #SparseVector>
46+
%rd, %rp, %ri, %vl, %pl, %cl = sparse_tensor.disassemble %sp : tensor<100xf64, #SparseVector>
4747
outs(%od, %op, %oi : tensor<6xf64>, tensor<2xindex>, tensor<6x1xi32>)
4848
-> tensor<6xf64>, (tensor<2xindex>, tensor<6x1xi32>), index, (index, index)
4949
return %rd, %rp, %ri : tensor<6xf64>, tensor<2xindex>, tensor<6x1xi32>

mlir/test/Dialect/SparseTensor/sparse_pack.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// CHECK: }
3232
func.func @sparse_pack(%values: tensor<6xf64>, %pos:tensor<2xindex>, %coordinates: tensor<6x2xi32>)
3333
-> tensor<100x100xf64, #COO> {
34-
%0 = sparse_tensor.pack %values, %pos, %coordinates
34+
%0 = sparse_tensor.assemble %values, %pos, %coordinates
3535
: tensor<6xf64>, tensor<2xindex>, tensor<6x2xi32> to tensor<100x100xf64, #COO>
3636
return %0 : tensor<100x100xf64, #COO>
3737
}
@@ -70,7 +70,7 @@ func.func @sparse_unpack(%sp : tensor<100x100xf64, #COO>,
7070
%op : tensor<2xindex>,
7171
%oi : tensor<6x2xi32>)
7272
-> (tensor<6xf64>, tensor<2xindex>, tensor<6x2xi32>) {
73-
%rd, %rp, %ri, %dl, %pl, %il = sparse_tensor.unpack %sp : tensor<100x100xf64, #COO>
73+
%rd, %rp, %ri, %dl, %pl, %il = sparse_tensor.disassemble %sp : tensor<100x100xf64, #COO>
7474
outs(%od, %op, %oi : tensor<6xf64>, tensor<2xindex>, tensor<6x2xi32>)
7575
-> tensor<6xf64>, (tensor<2xindex>, tensor<6x2xi32>), index, (index, index)
7676
return %rd, %rp, %ri : tensor<6xf64>, tensor<2xindex>, tensor<6x2xi32>

0 commit comments

Comments
 (0)