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

Generic tensor contraction #48

Open
ivan-pi opened this issue Dec 10, 2021 · 1 comment
Open

Generic tensor contraction #48

ivan-pi opened this issue Dec 10, 2021 · 1 comment

Comments

@ivan-pi
Copy link

ivan-pi commented Dec 10, 2021

The FortranCon 2020 presentation from Patrick Seewald on "Generic Programming Techniques by example of a tensor contraction" contains an excellent demonstration of a generic tensor class which would be difficult to write without a preprocessor.

Full code examples can be found in the fortran-einsum-example GitHub repository.

As Patrick notes at the end of his presentation, the biggest limitations of the current approach are:

  • all templates are explicitly instantiated, leading to large binary sizes and long compilation times
  • the mixture of Fortran and preprocessor syntax is hard to read and debug

Here are some einsum reference pages:

And here are two blog posts with explanations:

@arjenmarkus
Copy link
Collaborator

Slightly abusing this ticket: I experimented a bit with Kronecker products, My intention was to create a concise routine that can be extended to any number of dimensions. The code I attach here is limited to two-dimensional arrays leading to a four-dimensional array, but with the help of assumed-rank arrays I can make it "dimension-agnostic".
kronecker_general.f90.txt

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

No branches or pull requests

2 participants