Use the routine for openSparseTensorCOO and getSparseTensorReaderNext.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/ExecutionEngine/SparseTensor/File.h | ||
---|---|---|
222–233 | I think it's better to make this a method of the class rather than a standalone function, since that gives it a more uniform calling syntax in addition to helping avoid breaking encapsulation (since we'd like to avoid having readLine be public). In my suggested edit I've also reordered the arguments to match the prevailing style (we pass the size of arrays/buffers before the pointer for arrays/buffers). And since we have the getRank method already, I've added an assertion to ensure that the caller-provided rank agrees. In my suggested edit I've also lifted the conditional on perm out of the loop. Though really it'd be better to lift it further out in order to avoid checking every time the method is called. That can be easily achieved by passing the permutation to the SparseTensorReader ctor and saving it in the object (and constructing the identity permutation if there is no caller-provided one). |
Following up after the issues addressed by D135811:
Do note that the proposed SparseTensorReader::readCOOElement method can still return the raw V value, since this is a C++ library. It's only the macros that call the method which need to worry about wrapping that V into a memref
mlir/include/mlir/ExecutionEngine/SparseTensor/File.h | ||
---|---|---|
222–233 | Move the routine to the sparse tensor reader. |
mlir/include/mlir/ExecutionEngine/SparseTensor/File.h | ||
---|---|---|
222–233 | Reordered rand and indices from the parameter list. |
mlir/include/mlir/ExecutionEngine/SparseTensor/File.h | ||
---|---|---|
222–233 | The COO file doesn't have a notation for dim permutation, only the SparseTensor encode has the notation for dim permutation. So it doesn't look right to have _mlir_ciface_getSparseTensorReaderNext handle dim perm. With the current change, we only handle dim perm for inserting the read elements to a SparseTensor. |
I think it's better to make this a method of the class rather than a standalone function, since that gives it a more uniform calling syntax in addition to helping avoid breaking encapsulation (since we'd like to avoid having readLine be public).
In my suggested edit I've also reordered the arguments to match the prevailing style (we pass the size of arrays/buffers before the pointer for arrays/buffers). And since we have the getRank method already, I've added an assertion to ensure that the caller-provided rank agrees.
In my suggested edit I've also lifted the conditional on perm out of the loop. Though really it'd be better to lift it further out in order to avoid checking every time the method is called. That can be easily achieved by passing the permutation to the SparseTensorReader ctor and saving it in the object (and constructing the identity permutation if there is no caller-provided one).