Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Be sure to add these functions to the SparseTensorUtils.h header as well, and be sure to annotate them with the MLIR_CRUNNERUTILS_EXPORT macro, otherwise the generated code won't actually be allowed to call them.
mlir/lib/ExecutionEngine/SparseTensorUtils.cpp | ||
---|---|---|
545 | I think these various wrappers for calling SparseTensorReader methods should be renamed to getSparseTensorReader{Rank,IsSymmetric,NNZ,...} —both to make it clear that they work on SparseTensorReader objects, and to avoid future/potential name clashes with similarly named method wrappers for other classes. Or if you think those names are too long/ugly, then we should try to come up with some alternative naming scheme and apply it to all the functions exposed by this file. Maybe something like the naming schema st_{class}_{method}, where the st_ very succinctly indicates these are part of the sparse_tensor dialect, and splitting the class vs method names helps avoid some other irregularities in our current function names. Thus, we'd have st_reader_create, st_reader_getRank, etc for the stuff in this differential, but also st_storage_getValues, st_storage_getPointers, etc for stuff that's already there from before. (Or as a slight variation we could use the schema ST{Class}_{method}, i.e.: STReader_create, STStorage_getValues, etc.) |
Oh, also be sure to actually rename the SparseTensorFile class to SparseTensorReader
Update: Ah nevermind. I see that's being done in D135477
Add Reader/Writer to routine names for make it clear that the routines are for SparseTensorReader/Writer.
Add the routines to SparseTensorUtils.h and annotate the routines with MLIR_CRUNNERUTILS_EXPORT.
mlir/lib/ExecutionEngine/SparseTensorUtils.cpp | ||
---|---|---|
545 | Thanks! Add Reader/Writer to the names. |
mlir/lib/ExecutionEngine/SparseTensorUtils.cpp | ||
---|---|---|
617 | minor nit, use index_type for the r var in the for loop as well, just to make sure we don't get issues on platforms with surprising index types | |
617 | can we assert(rank != 0) before doing the rank-1 test? | |
mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_file_io.mlir | ||
166 | Yeah, this is a neat feature to allow this kind of easy testing! |
Beware that you'll need to rebase this for D135613
mlir/include/mlir/ExecutionEngine/SparseTensorUtils.h | ||
---|---|---|
208–209 ↗ | (On Diff #466822) | It's worth mentioning that this not only creates the object itself, but also opens the file and parses the header. (Both so that folks don't go looking for functions to do those steps, but also to make it clear that this can exit due to I/O or parsing errors.) |
229 ↗ | (On Diff #466822) | Might be worth mentioning that this also closes the file (just so folks don't go looking for a function to do that step). |
239 ↗ | (On Diff #466822) | Please switch this to the using syntax instead, to match the style used in the rest of include/mlir/ExecutionEngine/SparseTensor/* |
244 ↗ | (On Diff #466822) | |
mlir/lib/ExecutionEngine/SparseTensorUtils.cpp | ||
581–587 | I'd feel better if this code and its replica in openSparseTensorCOO were consolidated into a single method, in order to avoid the code duplication— especially since there's that 0-indexing vs 1-indexing conversion, so we really want to avoid the potential maintenance issues. I can write up a quick CL for making that change in File.h if you don't want to do it in this CL | |
592 | You shouldn't need this typedef here, since it's already given in the header file. |
Forgot to hit the accept button :) Though do be sure to rebase after addressing the documentation nits
Replace typedef with using. Modify function documentation. Remove an unnecessary typedef.
Sorry about this. Trying to fix it with https://reviews.llvm.org/D135811
mlir/include/mlir/ExecutionEngine/SparseTensorUtils.h | ||
---|---|---|
208–209 ↗ | (On Diff #466822) | Add |
229 ↗ | (On Diff #466822) | Add |
mlir/lib/ExecutionEngine/SparseTensorUtils.cpp | ||
581–587 | Good point. I will do this in a follow up CL. | |
592 | Removed, that was a mistake. |
I think these various wrappers for calling SparseTensorReader methods should be renamed to getSparseTensorReader{Rank,IsSymmetric,NNZ,...} —both to make it clear that they work on SparseTensorReader objects, and to avoid future/potential name clashes with similarly named method wrappers for other classes.
Or if you think those names are too long/ugly, then we should try to come up with some alternative naming scheme and apply it to all the functions exposed by this file. Maybe something like the naming schema st_{class}_{method}, where the st_ very succinctly indicates these are part of the sparse_tensor dialect, and splitting the class vs method names helps avoid some other irregularities in our current function names. Thus, we'd have st_reader_create, st_reader_getRank, etc for the stuff in this differential, but also st_storage_getValues, st_storage_getPointers, etc for stuff that's already there from before. (Or as a slight variation we could use the schema ST{Class}_{method}, i.e.: STReader_create, STStorage_getValues, etc.)