Skip to main content

Trainable Vivado Templates

Status:In progress
Tags:Hls4mlTrainableTemplates
Last modified:

What this section covers

This section documents the static C++ headers under hls4ml/templates/vivado/trainable. These are the synthesizable building blocks for the first ENABOL/hls4ml-trainable path: loss endpoint, Dense backpass, raw SGD update proposal, and a no-throttle controller baseline.

Directory Layout​

hls4ml/templates/vivado/trainable
β”œβ”€β”€ backprop
β”‚ └── nnet_dense_backprop.h
β”œβ”€β”€ common
β”‚ └── trainable_trace.h
β”œβ”€β”€ controllers
β”‚ └── global_throttle.h
β”œβ”€β”€ losses
β”‚ └── mse.h
└── optimizers
└── sgd.h

Pages​

AreaHeaderPurpose
Common trace helperscommon/trainable_trace.hMacro-gated trainable tracing through hls4ml's native trace storage.
Dense backpropbackprop/nnet_dense_backprop.hComputes dL/dx, accumulates batch gradients, and emits averaged parameter gradients.
Squared-error losseslosses/mse.hImplements mse and half_mse from the same scalar/gradient core.
SGD optimizeroptimizers/sgd.hProposes raw -learning_rate * gradient updates without mutating parameters.
Global throttle controllerscontrollers/global_throttle.hProvides CTRL-NONE and the shared alpha-scaled Dense update application helper.

Design Rule​

The headers are deliberately static and dumb. They should consume CONFIG_T typedefs, dimensions, constants, and trace names emitted by hls4ml writer/config passes. They should not inspect Python-side dictionaries, infer layer names, or reproduce writer logic.

The generated firmware will decide which headers to include and which config structs to emit when HLSConfig.Model.Training.Trainable=True.