This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] Let the SparseTensorReader handle the isSymmetric flag.
AbandonedPublic

Authored by bixia on Nov 17 2022, 4:08 PM.

Diff Detail

Event Timeline

bixia created this revision.Nov 17 2022, 4:08 PM
Herald added a project: Restricted Project. · View Herald Transcript
bixia requested review of this revision.Nov 17 2022, 4:08 PM
bixia updated this revision to Diff 476267.Nov 17 2022, 4:16 PM

Fix FileCheck test.

Peiming added inline comments.Nov 17 2022, 5:11 PM
mlir/include/mlir/ExecutionEngine/SparseTensor/File.h
100

This looks scary, can we use a unique_ptr for this?

wrengr added inline comments.Nov 17 2022, 5:12 PM
mlir/include/mlir/ExecutionEngine/SparseTensor/File.h
98–101

We don't use the trailing underscore style anywhere else, so I don't think we should introduce it here.

wrengr added inline comments.Nov 17 2022, 5:15 PM
mlir/include/mlir/ExecutionEngine/SparseTensor/File.h
183–187

What's the point of having both hasPendingSymmetricValue and also pendingSymmetricValue? Given that the latter is a pointer, you can always check if pendingSymmetricValue is nullptr rather than storing an additional bool

wrengr added inline comments.Nov 17 2022, 5:19 PM
mlir/include/mlir/ExecutionEngine/SparseTensor/File.h
191–192

I'd rather avoid having this extra counter in the object. For the openSparseTensor function we already track this in the for-loop, so why doesn't the codegen-pass do the same?

wrengr added inline comments.Nov 17 2022, 5:25 PM
mlir/include/mlir/ExecutionEngine/SparseTensor/File.h
183–189

Akin to my previous comment, why does this need to be handled in the runtime library at all? Why doesn't the codegen-pass just allocate room for the pendingSymmetricValue and pendingSymmetricIndices and handle all this logic on the codegen side?

For my own work I'm trying to move more of the file processing stuff out of the library, so it seems like a step backward for the codegen-pass to want to add more stuff to the library

bixia added inline comments.Nov 21 2022, 7:44 AM
mlir/include/mlir/ExecutionEngine/SparseTensor/File.h
100

Need to discuss this, I actually have a bug here, as deleting void pointer has undefined behavior.
We may need to add type to SparseTensorReader, such as SparseTensorReader<V>, to resolve this.

183–187

pendingSymmetricValue is a buffer for storing a pending value that we encountered, and the same buffer is shared during the life time of the reader. That is, we always keep such a buffer, and the buffer only has a valid value right after reading an element and not valid right after we use the value.

183–189

Sorry for not making the context of this work clear.
The approach you talked about is https://reviews.llvm.org/D138214
We are trying to comparing these two approaches, and believe handling the isSymmetric flag as in this PR is better for performance because the loop in https://reviews.llvm.org/D138214 has two insert operators, which complicates the loop due to the complexity of the insert operator.

191–192

In openSparseTensor, we use a loop with two add-element function calls to handle symmetric values.
In codegen, we need a loop with two insert ops to do the same. We are trying to avoid two insert ops as explain above.

Are we keeping codegen solution (controlled by expand_symmetry flag proposed in other pending revision)?

bixia abandoned this revision.Nov 22 2022, 12:10 PM