This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] Add rewrite rule for the sparse_tensor.out operator.
ClosedPublic

Authored by bixia on Oct 13 2022, 8:58 AM.

Details

Summary

Also fix the rewrite rule for sparse_tensor.new to reflect the recent change of
the runtime C interface and to use utilities for memref.alloca.

Diff Detail

Event Timeline

bixia created this revision.Oct 13 2022, 8:58 AM
Herald added a project: Restricted Project. · View Herald Transcript
bixia requested review of this revision.Oct 13 2022, 8:58 AM
bixia updated this revision to Diff 468076.Oct 16 2022, 8:23 AM

Rebase.

bixia updated this revision to Diff 468554.Oct 18 2022, 8:14 AM

Fix format.

Peiming added inline comments.Oct 19 2022, 11:06 AM
mlir/test/Dialect/SparseTensor/rewriting_for_codegen.mlir
1

Can we now have an integrate test?

e.g.,

read A -> write to B -> read B

The content of A and B should be same?

bixia added inline comments.Oct 20 2022, 12:49 PM
mlir/test/Dialect/SparseTensor/rewriting_for_codegen.mlir
1

No, we need the convert op to get and e2e case.

aartbik added inline comments.Oct 20 2022, 2:11 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
539

Allocate a temporary buffer ...

614

Allocate a temporary buffer ...

624

Can't you (eventually) query the values array size (not capacity for this), rather than iterating over the full matrix. It is as simple as loading a memSizes field.

Of course, we many have to introduce an op for that since we don't have access here ;-)

mlir/test/Dialect/SparseTensor/rewriting_for_codegen.mlir
43

something went wrong with indentation here

bixia updated this revision to Diff 469375.Oct 20 2022, 3:17 PM
bixia marked 3 inline comments as done.

Fix test format.
Use sparse_tensor.number_of_entries.

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
624

Thanks for D136382!

mlir/test/Dialect/SparseTensor/rewriting_for_codegen.mlir
43

Fixed.

aartbik accepted this revision.Oct 20 2022, 4:33 PM
aartbik added inline comments.
mlir/test/Dialect/SparseTensor/rewriting_for_codegen.mlir
60

can we make this a 10x20 matrix, and then at least check that the outermost loop goes over 10 elements?

This revision is now accepted and ready to land.Oct 20 2022, 4:33 PM
bixia updated this revision to Diff 469647.Oct 21 2022, 9:12 AM
bixia marked an inline comment as done.

Change the test tensor and add test for the outer loop.