-
Notifications
You must be signed in to change notification settings - Fork 7
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 tensor_view function and show usage in 2D-1 benchmark example. #4
Conversation
cd91468
to
754ce4e
Compare
Ok, nice. Some other examples where this might be useful are Examples 226, 270, 282 and 290. |
Unfortunately, I see lots of allocations in the kernel of Example245 again when using the tensorviews. My guess is, that the compiler has difficulties to infer the return type of the tensorview? I get no allocations when I define a separate function for each rank case, e.g. scalar_view, vector_view, matrix_view. |
``` | ||
# Examples | ||
""" | ||
function tmul!(y, A, x, α = 1.0, β = 0.0) |
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 think you look for LinearAlgebra.BLAS.gemv!('T', alpha, A, x, beta, y)
? It does not to any allocations in my tests.
Julia seems to have a problem with either the rank 3 or the generic rank n version. I will try to figure this out further, one idea we had was to use |
Another thing we should discuss is where the documentation for the helper functions would fit best. |
Instead of Val{k} one could also define abstract types like TScalar, TVector, TMatrix, TRank3, TRank4 (all subtypes of <: TensorType) etc. and use them for dispatch. One could even put the dimensions into the type, i.e., use TVector{3} or TMatrix{2,2} and then use, e.g., tensorview(input, 3, TMatrix{2,2})... Concerning the documentation, I agree. The NonlinearOperator already has an example at the end of the page for which one could add the new possibility. Another example for the BilinearOperator would be good, too. We will think about that when the rest is sorted out. |
Had similar situations where I worked with wrapper structs: Enabled Sparspak for dual numbers by implementing tailored BLAS routines:
Local kernel callback routines in VoronoiFVM: |
Added |
Co-authored-by: Patrick Jaap <[email protected]>
looks good to me now, are we ready to merge? |
From my point of view, yes |
As discussed today I have written a generic function that takes vector and index as well as tensor rank and dimension to construct a matching view.
@pjaap FYI