Use SparseTensorDescriptor whenever not calling setters, to avoid needing to create a temporal buffer for simple query purposes.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp | ||
---|---|---|
107 | I removed the optional as it never returns std::nullopt. |
The CL description seems a bit misleading/backwards to me —since it places focus on *using* MutSparseTensorDescriptor, rather than focusing on not using it. So would be better to rephrase it to something like:
"""Use SparseTensorDescriptor whenever not calling setters, to avoid needing to create a temporal buffer for simple query purposes."""
(Though I'm thinking you mean "temporary" here rather than "temporal".)
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorStorageLayout.h | ||
---|---|---|
205 | I'm curious why the change here? To you anticipate needing to define ValueArrayRef to something other than ValueRange or SmallVectorImpl<Value>& ? If there's a valid reason to expect other uses, then I'm all for generalization; but if there'll only ever be those two instantiations, then it'd be better to stick with the bool templating since it explicitly ensures the invariant that those are the only two options. (If you revert to using the bool parameter, I think you should keep the new documentation on the subclasses. Since that documentation is remains valid and helpful under both ways of structuring the code.) | |
259 | The compiler should be smart enough to fix it, but using the helper function here means doing a redundant assertion. |
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorStorageLayout.h | ||
---|---|---|
205 | I think changing it to ValueArrayRef makes it easier for readers to understand what is actually used for storage the array. One reason I used bool at the first place is that I used to implement both mutable/immutable descriptor in this class and using enable_if to only allows setters for mutable descriptor. But the situation is changed, and this class now only holds getters, so I feel like that it make less sense to create a SparseTensorDescriptorImp<true> when it actually provides no setters. | |
259 | Yeah, but should be okay? I would like to reuse the code here (maybe we will, though unlikely, switch to some class that does not provide operator[]). |
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorStorageLayout.h | ||
---|---|---|
205 |
*for storing the array* |
I removed the optional as it never returns std::nullopt.