-
Notifications
You must be signed in to change notification settings - Fork 15
Add grblas.op namespace to put all operations together.
#67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Also, `grblas.op.numpy`, which remains lazy. We now have `grblas.ops` and `grblas.op`. Perhaps we should rename `grblas.ops`.
|
Some methods like Should we always convert monoids to binaryop when appropriate? This should always be safe and possible to do, right? This is similar to upgrading builtin binaryops to monoids when possible in ewise_add. |
|
Given users can And yes, auto-converting from monoid to binary or binary to monoid as required by a method seems okay to me. |
We do this by adding unsurprising attributes to all our operators.
All this made this PR much more substantial. Question: can we not allow using a semiring where a binaryop or monoid is expected? For example, with ewise_add. min_plus(A | B) # bad. does this do min or plus?
min_plus.binary(A | B) # better
plus(A | B) # best
min_plus(A & B) # bad
min_plus.monoid(A & B) # better
min(A & B) # best |
| class TypedOpBase: | ||
| def __init__(self, name, type_, return_type, gb_obj, gb_name): | ||
| def __init__(self, parent, name, type_, return_type, gb_obj, gb_name): | ||
| self.parent = parent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is .parent the best attribute name for the untyped version?
binary.plus[int].parent is binary.plus|
I should have said I plan to disallow using semiring where it grabs the binary/monoid from it such as ewise_add. Let me know if you prefer otherwise. |
Although this is part of the spec, it's pretty weird to do in Python. It's also easy to do e.g. `my_semiring.binaryop` if you want the binarop.
| self.name = name | ||
| self._typed_ops = {} | ||
| self.types = {} | ||
| self._anonymous = anonymous |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be private or not?
|
Note that we no longer include Monoids in |
Also, complex monoids still aren't working.
|
@jim22k one more question for you. When users register new operators, we assign them to e.g. |
This is mostly because SuiteSparse doesn't like user-defined binops here. If the user also defined a monoid from the binop, then we can use the monoid instead.
Also, use `GrB` objects when possible over `GxB` objects. I think this may be nicer for the recorder.
| # np.array(values2, dtype=np.complex128), | ||
| # ], | ||
| # ] | ||
| # ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw @jim22k complex monoids still don't work. I apparently added a check in "operators.py" to avoid the segfault.
|
Well, this "small" PR became quite large. Merging! |
Also,
grblas.op.numpy, which remains lazy.We now have
grblas.opsandgrblas.op. Perhaps we should renamegrblas.ops.This was @jim22k's idea to help make
grblaseasier to use.