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
Add dispatcher capacity to support any type specialisation #2157
Conversation
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.
I left a few small comments, but overall this looks great.
if not output: | ||
out = dispatched(*ins) | ||
out = dispatched[in_types](*ins) | ||
continue |
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.
I'm not sure what is happening with this continue statement. Perhaps we can just do:
if not output:
...
else:
... rest of the current loop without all the `if output:` checks
|
||
def test_Data_low_priority_one_dispatch(): | ||
class func(): | ||
__name__ = "" |
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.
If __name__
has to be here, can we put something in it like __name__ = "dummy name"
rather than leaving it blank which just looks a bit odd.
Co-authored-by: Simon Cross <hodgestar+github@gmail.com>
a01128d
to
932ad81
Compare
Description
Allow the dispatcher to accept specialisations on generic
Data
.This as 2 uses:
inner
defined in term ofmatmul
.The
Data
dispatched functions have less priority than direct specialization. They are used directly (no_constructed_specialisation
) when theData
is in the inputs, but when the output data type is set, there will always be a conversion fromData
to the desired type.In this PR:
Data
.kron_transpose
which iskron(left.T, tright)
. It's commonly used for superoperator and it can be optimized forDense
andJax
by doing it in one operation.Data
specialization forinner
,inner_op
,expect
,expect_super
andtrace_oper_ket
.zeros_like
andidentity_like
as dispatched function so the order is kept during operation for dense.