Numba: Add several remaining sparse ops#1896
Numba: Add several remaining sparse ops#1896tomicapretto wants to merge 9 commits intopymc-devs:mainfrom
Conversation
544c7d4 to
bdb79eb
Compare
bdb79eb to
b483003
Compare
b483003 to
4867709
Compare
4867709 to
8df47f9
Compare
69995bb to
45dccc9
Compare
|
I'm starting to thing that it would be a good idea to have many of the implementations be at |
db11067 to
fc1cfe8
Compare
|
Why is Neg its own Op, instead of how other Elemwise are handled? |
I have no idea. Do you mean that we could have something like @structured_elemwise(ptm.neg)
def neg(x):
"""
Compute neg(x) for all non-zero elements of x.
"""? Update: I guess the author tried to follow a consistent pattern at the time of making the linked commit, and we inherited it until now you raise the question. |
|
Yeah let's change it to be structured_elemwise. I don't love how the elemwise look now (there's an open issue) but no reason why this should be special cased. If you implement like the other Elemwise it will work out of the box |
|
|
@ricardoV94, in efc3700 I removed |
| return diag_csc | ||
|
|
||
|
|
||
| @register_funcify_default_op_cache_key(SquareDiagonal) |
There was a problem hiding this comment.
This could be just a helper that builds the equivalent symbolic operations. I don't see the advantage of being its own Op?
def square_diagonal(diag):
n = diag.shape[0]
indices = pt.arange(n, dtype=np.int32)
indptr = pt.arange(n + 1, dtype=np.int32)
... whatever op builds a csc_matrix symbolically)There was a problem hiding this comment.
Or do we even need it? Does it exist in scipy / or is it used anywhere else internally?
There was a problem hiding this comment.
I think we can overload eye and then use it within this Op. Would that make sense?
Description
This PR implements the following sparse ops in numba:
ColScaleCSCRowScaleCSCGetItemListandGetItemListGradGetItem2ListsandGetItem2ListsGradGetItem2dGetItemScalarNegDiagSquareDiagThe following ops are not implemented, but I'm not sure if they should be:
CSMGrad, is it used?EnsureSortedIndices, I see it used in thecleanfunction together withremove0, but I don't seecleanbeing used.Remove0, see previous lineConstructSparseFromListAFAIK it's only used in the gradient ofAdvancedSubtensor1whensparse_gradisTrue. How relevant is this?I've been assisted by Codex to perform the implementations and I've reviewed everything and included modifications when needed. To my best understanding, implementations are OK, but of course this is open to feedback.
Related Issue
Checklist
Type of change