-
Notifications
You must be signed in to change notification settings - Fork 56
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
StaticArrays #40
Comments
This package is mostly intended for big arrays with strided memory layout. In principle, the |
It is an interesting question - the syntax provided by TensorOperations is very convenient, even if the array is small (and there's also block matrix structures). |
I am using |
What's the error for StaticArrays here? Is it |
What should the ideal implementation for |
All the code in StaticArrays.jl is manually unrolled by generated functions, which tend to also generate linear (not Cartesian) indices statically (all of this lets LLVM use SIMD). I generally assume or the O(length) operations can be completely unrolled (that would be the equivalent of Is there a generic |
No it's really only Note that this package does not use Over at https://github.com/Jutho/Strided.jl I am actually experimenting with having a multithreaded implementation of my own permute function, which is even much more general (but still assumes a strided memory layout). |
Multithreaded - cool! Did you ever consider contributing your faster code to Base, and putting it in Obviously StaticArrays is the complete opposite end of the spectrum here, and has annoying interface problems as well... |
using TensorOperations, StaticArrays
a = @SVector rand(3)
b = @SMatrix rand(3, 3)
c = @MVector zeros(3)
@tensor c[i] = b[i, j] * a[j] gives the output:
|
and the allocating version: @tensor d[i] := b[i, j] * a[j] leads to
|
with |
The problem is that it's actually quite a bit of code, but once you have it it can immediately do more general things. It's basically a recursive blocking strategy (like the I certainly think that the new code in Base (since the introduction of julia> A=randn(ntuple(n->10,8));
julia> @time B=permutedims(A,(8,7,6,5,4,3,2,1));
3.814514 seconds (80.71 k allocations: 766.801 MiB, 1.30% gc time)
julia> @time permutedims!(B,A,(8,7,6,5,4,3,2,1));
4.298002 seconds (8 allocations: 416 bytes) (this used to be around 2 seconds) julia> @time @tensor B[:] := A[-8,-7,-6,-5,-4,-3,-2,-1];
0.715068 seconds (25 allocations: 762.941 MiB, 0.30% gc time)
julia> @time @tensor B[:] = A[-8,-7,-6,-5,-4,-3,-2,-1];
0.312276 seconds (19 allocations: 1.516 KiB) |
@cortner, |
ok - so what I ask is feasible in principle and possibly not even too difficult? It is not urgent for me, but if you are willing leave this issue open then at some point I might break down and have a go at it. |
Sure, no problem to leave this open. I think it's certainly feasible, I am not sure whether you will be able to get optimal code for Not sure where the implementation needs to go. I haven't worked with conditional dependencies yet, and I would prefer not to require |
This must have been asked before but I couldn’t find a reference: the package doesn’t seem to support StaticArrays, is there a plan / possibility to do so?
The text was updated successfully, but these errors were encountered: