Skip to content

Conversation

@STFleming
Copy link
Collaborator

This PR introduces a HLS Softmax layer into FINN.

Specifically it contains:

  • HWSoftmax - a hardware abstraction layer.
  • HWSoftmax_hls - for instantiating the HLS softmax IP
  • InferHWSoftmax transformations for inferring the HWSoftmax layers.
  • Tests for testing the softmax implementation

The HLS implementation of the softmax unit lives in finn-hlslib and it is structured as a three-stage pipeline with the following stages:

  1. The first stage performs a pass over the input vector to determine the maximum value.
  2. The second stage normalises the input vector to between (0,1] by subtracting the max and applying the exponential.
  3. The last stage performs an elementwise division of the exponential values with the sum of the exponentials.

A template parameter specifies the input datatype; however, the output datatype is fp32. Internally, a fixed point datatype is used after the first stage as the dynamic range of the input floats after this normalisation is well defined. To avoid any loss of accuracy, the fixed point value maintains 23 fractional bits.

…at a branch of finn-hlslib until softmax.hpp is merged into dev
@STFleming STFleming requested a review from auphelia September 26, 2025 10:50
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.

1 participant