Skip to content

Generalised Transpose and Reshape support#1419

Merged
auphelia merged 61 commits intodevfrom
feature/shuffle
Nov 7, 2025
Merged

Generalised Transpose and Reshape support#1419
auphelia merged 61 commits intodevfrom
feature/shuffle

Conversation

@STFleming
Copy link
Collaborator

@STFleming STFleming commented Sep 4, 2025

This PR introduces operators and compiler support to enable flexible reshape and transpose operations in FINN, enhancing its capability to handle complex tensor manipulations efficiently.

Motivation: Flexible support for reshape and transpose operations is crucial for supporting Transformer based hardware implementations and improving flexibility in various applications.

Specifically, it adds:

  • Shuffle(HWCustomOp): A new operator designed to capture reshape and transpose operations without a backend. It decomposes into chains of valid InnerShuffle and OuterShuffle operations, which can be implemented via hardware backends.

  • OuterShuffle(HWCustomOp): A HLS-based operator supporting parallel flexible reshape/transposition of N-Dimensional tensors, provided the last dimension remains static. This operator requires that SIMD be divisible into the last dimension of the input tensor, ensuring efficient parallel processing.

  • InnerShuffle(HWCustomOp): An RTL-based operator supporting parallel transposition of N-Dimensional tensors, where only the last two dimensions are swapped. It requires that SIMD be divisible into the second-to-last dimension of the input tensor, facilitating efficient hardware implementation.

  • ONNX-level transformation ShuffleDecomposition: This transformation breaks complex transpositions into chains of InnerShuffle and OuterShuffle operations, supporting general transposition while respecting constraints like dimension movement and SIMD divisibility.

  • Builder Step: Integrates the Shuffle decomposition and inference into the default build flow, ensuring seamless application of these transformations.

  • Testing Suite: Includes a comprehensive suite of tests covering various simple and complex transpose operations involving InnerShuffle, OuterShuffle, and chains of these operations, ensuring robustness and reliability.

STFleming and others added 21 commits August 26, 2025 15:44
… to be made to how simulations are being launched.
…ues, fixed the specialised version so it is compatible with new xsi flow.
…use a ptranspose or a shuffle, this needs to be worked on but just bringing it up for initial testing of the op
…es into simpler transposes. Also added test to ensure the equivalence of these transformations.
…he constraints of the input_generator and ptranspose operators. This is now passing RTL tests with chained operators together.
…ir SIMD values by the minimum amount to satisfy constraints while still meeting the original SIMD performance targets. I'm not sure if this is the best thing to do here, but it is increasing the flexibility of the compilation with less user intervention.
@STFleming STFleming marked this pull request as draft September 4, 2025 14:10
@STFleming STFleming self-assigned this Sep 4, 2025
Copy link
Collaborator

@auphelia auphelia left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you @STFleming

@auphelia auphelia removed the request for review from preusser November 7, 2025 10:18
@auphelia auphelia merged commit a912282 into dev Nov 7, 2025
2 checks passed
@auphelia auphelia deleted the feature/shuffle branch November 7, 2025 11:07
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.

2 participants