Skip to content

Conversation

@romerojosh
Copy link
Collaborator

During recent development, I noticed that the coverage of Fortran interfaces for supervised learning problems is overly restrictive, with respect to supported array dimensioning. In particular, the current interfaces only support input/label and input/output array pairings where both arrays are of equivalent rank. This is too restrictive for something like a classification problem, where the input might be a multi-dimensional field and the label/output might just be a single scalar classifier value. A savvy user could just allocate a Fortran array with singleton dimensions for the label/output in this case, but that is not very convenient.

This PR addresses this limitation by expanding the Fortran supervised learning interfaces to cover all input/label and input/output array dimensions combinations from 1D to 5D arrays. It is a lot of code added, but it is mostly just copy and pasted boilerplate.

Additionally, I updated to Fortran supervised API documentation to reflect this lifting of the rank-equivalent restriction I also removed statements about arrays requiring batch size dimensions or equivalent batch size dimensions at all, since that is not general requirement from TorchFort but instead something that would be imposed by the user model.

…abel and input/output dimension combinations.
Copy link
Collaborator

@azrael417 azrael417 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, this MR almost crashes my browser when I view the diff. However, I think this is fine and mostly boilerplate. I am wondering if there is an elegant way to generate those combinations automatically from some kind of template file. Do you have an idea if that is possible?

@azrael417 azrael417 merged commit 5fdd4fa into master Sep 24, 2025
3 checks passed
@romerojosh romerojosh deleted the expand_fortran_interfaces branch September 25, 2025 17:48
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