Skip to content
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

tensor_product macro #211

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open

tensor_product macro #211

wants to merge 21 commits into from

Conversation

KnutAM
Copy link
Member

@KnutAM KnutAM commented Oct 25, 2023

Make it easy to define new unrolled tensor expressions based on an index expression,
xref: #205 (comment)

Examples

Tensors.@tensor_product(@inline @inbounds function dcontract(A::Tensor{4,3}, B::Tensor{4,3})
    C[i,j,k,l] = A[i,j,m,n]*B[m,n,k,l]
end, muladd)

Tensors.@tensor_product(@inline @inbounds function otimes(A::Tensor{2,3}, B::Tensor{2,3})
    C[i,j,k,l] = A[i,j]*B[k,l]
end)

TODO

  • Support SymmetricTensor output (need to automatically figure out when based on the input and expression)
  • Replace current functions with the generated functions where that makes sense (e.g. otimes already use index expression, and that approach seems faster than manually unrolling)
  • Document the macro such that users can create their special functions (not public API yet)

@codecov-commenter
Copy link

codecov-commenter commented Oct 25, 2023

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (ce37b01) 96.91% compared to head (62d0fc7) 93.69%.
Report is 3 commits behind head on master.

Files Patch % Lines
src/utilities.jl 92.48% 16 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #211      +/-   ##
==========================================
- Coverage   96.91%   93.69%   -3.23%     
==========================================
  Files          17       17              
  Lines        1490     1522      +32     
==========================================
- Hits         1444     1426      -18     
- Misses         46       96      +50     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@termi-official
Copy link
Member

I think this can also really help users getting #188 functional for their corner cases

@KnutAM KnutAM marked this pull request as ready for review January 1, 2024 18:09
@KnutAM KnutAM changed the title WIP: index expression macro tensor_product macro Jan 1, 2024
@KnutAM
Copy link
Member Author

KnutAM commented Jan 1, 2024

@fredrikekre or @KristofferC - would any of you have time to review?

Feels like there is too much code for "parsing" the user input, but didn't find a way to reduce it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants