-
Notifications
You must be signed in to change notification settings - Fork 14
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
Matrix multiplication on specified indices #63
Conversation
we definately do want some kind of |
Codecov Report
@@ Coverage Diff @@
## master #63 +/- ##
==========================================
+ Coverage 86.42% 86.47% +0.05%
==========================================
Files 8 8
Lines 221 244 +23
==========================================
+ Hits 191 211 +20
- Misses 30 33 +3
Continue to review full report at Codecov.
|
OK here's a slightly more refined version, still only up to matrices with one contraction. Is this the right sort of thing to test whether constant propagation is working? julia> @code_warntype ((B,AB) -> *(:b, B, AB))(B, AB)
Variables
#self#::Core.Compiler.Const(var"##9#10"(), false)
B::NamedDimsArray{(:b,),Float64,1,Array{Float64,1}}
AB::NamedDimsArray{(:a, :b),Float64,2,Array{Float64,2}}
Body::NamedDimsArray{(:a,),Float64,1,Array{Float64,1}}
1 ─ %1 = (:b * B * AB)::NamedDimsArray{(:a,),Float64,1,Array{Float64,1}}
└── return %1 It seems equally confident if given |
More complicated contractions are now handled by |
Latest draft treats correctly arrays of arrays, and deletes the attempt to use OMEinsum.jl for more general contractions. I now think that overloading Perhaps it would be nicer to write |
At some point we should come back to this idea, |
Yes. I have a version I'm happier with at https://github.com/mcabbott/NamedPlus.jl/blob/master/src/mul.jl but should use it a bit first. |
It would be nice to be able to specify which indices to multiply on, instead of trusting their position (and giving an error if they don't match). Like
sum(A, dims=:k)
, this should let you write code which only works onNamedDimsArray
s, but doesn't care about the order of the underlyingArray
.This PR is a first attempt to add this, to see what you think. For now it's written
*(:k, A, B)
but perhaps*(A,B; dims=:k)
or evenContract{(:k,)}(A,B)
would be better. The docstring example uses #62 to create infix*ⱼ
easily. Ideally something similar would work for\
or/
too, #6.Haven't thought about speed, constant propagation etc. Nor tried to make it work for
ndims(A)==3
etc, which possibly should be handled by@require
ing OMEinsum.jl, or something.