-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor algorithm selection in type domain #30
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
Codecov ReportAttention: Patch coverage is
🚀 New features to boost your workflow:
|
|
Looks good to me, this will be helpful. |
While I am not opposed to this change, I was wondering if this helps with anything? Semantically, I guess it makes sense that the default algorithm only depends on the type of Furthermore, there might actually be cases where the default algorithm selection does want to depend on properties of
Not really, as the |
|
The main point where this appeared was in trying to select a default algorithm for either TensorMap or BlockSparseArrays: I wanted to reuse the I somehow assumed this solution was the easiest, since both TensorMap and BlockSparseArrays can quite easily tell you their blocktype, but an alternative solution is to simply define a I'll reintroduce the other |
|
EDIT: Sorry for repeating your points you Lukas, I posted this before noticing your post.
The use case we have in mind is a block diagonal matrix, where you might want to extract the type of the block to determine the default algorithm for the blocks, i.e.: default_algorithm(f::typeof(svd_compact!), A::BlockDiagonalMatrix) = BlockDiagonalAlgorithm(default_algorithm(f, blocktype(A))It's a bit easier to reason about working in the type domain, rather than grabbing instances of blocks.
That's true, but from what I can tell this PR still allows customizing based on instances if you want to.
I agree with this, I think it is a bit easier to reason about code like: default_svd_algorithm(A) = LAPACK_DivideAndConquer()
default_algorithm(::typeof(svd_compact!), A) = default_svd_algorithm(A)
default_algorithm(::typeof(svd_full!), A) = default_svd_algorithm(A)rather than: default_algorithm(::typeof(svd_compact!), A) = LAPACK_DivideAndConquer()
default_algorithm(::typeof(svd_full!), A) = default_algorithm(svd_compact!, A)since you can more easily remember that the actual definition is |
A |
|
I see the argument about the type domain, that is indeed a very valid remark. The lack of certain No strong opinions on the |
|
I've reinstated the desired functions and opened an issue to remind myself to add the default algorithm, which I'll implement in a separate PR. |
|
@Jutho do you have any more comments on this? I think it would be nice to merge this, I have some ongoing work that would benefit from this. |
|
Yes looks good to me, feel free to merge. |
This alters the algorithm selection and default algorithms to be implemented in the type domain instead.
While doing this, I also realized that the new
default_algorithm(f, ...)anddefault_f_algare tautologous, so I removed the latter.Given that these were not public, and the implementations in the "value domain" still dispatch to the type domain, I think this is non-breaking, so should be v0.2.1.
Fixes #29.