fix(vivado): Derive softmax layer config name from activation attribute - #1525
Merged
Merged
Conversation
HamzaEzzRa
marked this pull request as ready for review
August 12, 2026 03:29
JanFSchulte
approved these changes
Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Vivado (and Vitis, since it reuses the same pass) backend's SoftmaxFunctionTemplate hardcodes the generated config struct name as lowercase
softmax_config{index}, while SoftmaxConfigTemplate derives it from the layer'sactivationattribute. For standalonekeras.layers.Softmaxin Keras v2, that attribute is'Softmax'(capital), so the generatedparameters.hdeclaresSoftmax_config{index}butmyproject.cppcallssoftmax_config{index}, generating uncompilable code.Activation('softmax')and inlinedDense(..., activation='softmax')work since they carry the lowercase attribute. A simple fix for the standaloneSoftmaxis to makeSoftmaxFunctionTemplatederive the config name from the same attribute asSoftmaxConfigTemplate. This matches how Quartus and Catapult backends handle softmax, and how all the other activations are named. Keras v3 seems unaffected, since it always sets the attribute to lowercase'softmax', regardless of how softmax is called.Type of change
Tests
Extended
test/pytest/test_softmax.py.Both
test_softmaxandtest_softmax_skippedtake a newsoftmax_implparametrization (['activation', 'standalone']) that builds the softmax op with eitherkeras.layers.Activation('softmax')orkeras.layers.Softmax, respectively. Before theSoftmaxFunctionTemplatefix, thestandalonecases would fail on the Vivado backend at C++ compile time with an undeclaredsoftmax_config{index}.After the suggested fix, both paths pass. Quartus and Catapult were unaffected, as their function templates already derive the config name from the layer attribute.
Test Configuration:
Similar pytest configuration as the existing
test_softmax.pytests, with the addedsoftmax_implparametrization.pytest test/pytest/test_softmax.pyChecklist
pre-commiton the files I edited or added.