Skip to content

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
STFleming and others added 4 commits September 22, 2025 15:04
…sition transformation to reflect the new changes in the operator names inner_shuffle and outer_shuffle. Also added additional SIMD constraints in the transformation search.
@STFleming STFleming requested a review from auphelia September 23, 2025 09:47
@STFleming STFleming marked this pull request as ready for review September 23, 2025 09:47
@STFleming STFleming requested a review from preusser September 23, 2025 09:47
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