Lines Matching defs:tensor
1 //===- SparseTensorConversion.cpp - Sparse tensor primitives conversion ---===//
9 // A pass that converts sparse tensor primitives into calls into a runtime
10 // support library. Sparse tensor types are converted into opaque pointers
42 /// Maps each sparse tensor type to an opaque pointer.
52 static Value genLvlSizeCall(OpBuilder &builder, Location loc, Value tensor,
55 SmallVector<Value, 2> params{tensor, constantIndex(builder, loc, lvl)};
64 static Value genDimSizeCall(OpBuilder &builder, Location loc, Value tensor,
67 SmallVector<Value, 2> params{tensor, constantIndex(builder, loc, dim)};
76 SparseTensorType stt, Value tensor,
93 // compute it, but since we already did so to construct the `tensor`
95 return genLvlSizeCall(builder, loc, tensor, lvl);
103 SparseTensorType stt, Value tensor,
109 return genDimSizeCall(builder, loc, tensor, dim);
110 return linalg::createOrFoldDimOp(builder, loc, tensor, dim);
113 /// Populates the array with the dimension-sizes of the given tensor.
115 Value tensor, SmallVectorImpl<Value> &out) {
120 out.push_back(createOrFoldDimCall(builder, loc, stt, tensor, d));
123 /// Returns an array with the dimension-sizes of the given tensor.
124 /// If the *tensor* parameters is null, the tensor type is assumed to have a
128 Value tensor = Value()) {
130 fillDimSizes(builder, loc, stt, tensor, out);
153 /// Extracts the bare (aligned) pointers that point to the tensor.
155 Value tensor) {
156 auto buf = genToMemref(builder, loc, tensor);
346 /// Sparse conversion rule for trivial tensor casts.
347 class SparseCastConverter : public OpConversionPattern<tensor::CastOp> {
351 matchAndRewrite(tensor::CastOp op, OpAdaptor adaptor,
392 Value tensor = NewCallParams(rewriter, loc)
398 rewriter.replaceOp(op, tensor);
429 // Generate the call to construct empty tensor. The sizes are
438 /// Sparse conversion rule for the empty tensor.
439 class SparseTensorEmptyConverter : public OpConversionPattern<tensor::EmptyOp> {
443 matchAndRewrite(tensor::EmptyOp op, OpAdaptor adaptor,
460 // Generate the call to construct empty tensor. The sizes are
600 /// Sparse conversion rule for tensor rematerialization.
620 : public OpConversionPattern<tensor::InsertOp> {
624 matchAndRewrite(tensor::InsertOp op, OpAdaptor adaptor,
632 // Dense tensor insertion.
722 Value tensor = adaptor.getTensor();
730 {tensor, lvlCoords, values, filled, added, count},
870 auto tensor = rewriter.create<bufferization::ToTensorOp>(loc, retVal[i]);
872 rewriter.create<tensor::CastOp>(loc, op.getResultTypes()[i], tensor);
898 // Sparse tensor type conversion into opaque pointer.