convert_from_keras_model
Convert a Keras model to an hls4ml ModelGraph.Parameters
Keras model to convert. Must be a compiled Keras model.
Output directory for the generated HLS project.
Name of the HLS project. Used as the top-level function name.
Path to input test data in
.npy or .dat format for C simulation and co-simulation.Path to expected output data in
.npy or .dat format for verification.Backend to use. Options:
'Vivado', 'Vitis', 'Quartus', 'Catapult'.Target board from
supported_board.json. Overrides part parameter.FPGA part number (e.g.,
'xcvu13p-flga2577-2-e'). Backend-specific defaults used if not provided.Clock period in nanoseconds.
Clock uncertainty percentage. Defaults: 12.5% (Vivado HLS), 27% (Vitis HLS).
Interface type:
'io_parallel' or 'io_stream'.HLS configuration dictionary. See Configuration Guide for details.
Enable model-wise fixed-point precision propagation. If
None, automatically enabled for HGQ models.(Keras v3 only) Allow fallback to direct acyclic graph combinational logic for unsupported layers.
(Keras v3 only) Allow fallback to Keras v2 layer handlers for unsupported layers.
Returns
The converted hls4ml model ready for compilation and synthesis.
Example
Advanced Configuration
parse_yaml_config
Parse conversion configuration from a YAML file.Parameters
Path to the YAML configuration file.
Returns
Parsed configuration dictionary.
Example YAML
Usage
convert_from_config
Convert a model using a configuration dictionary or YAML file path.Parameters
Either a path to a YAML configuration file or a parsed configuration dictionary.
Returns
The converted hls4ml model.
Example
Supported Layers
Keras converter supports the following layer types:Core Layers
Dense- Fully connected layerActivation- Activation functions (ReLU, tanh, sigmoid, etc.)Dropout- Dropout (removed during conversion)Flatten- Flatten layerReshape- Reshape layer
Convolutional Layers
Conv1D- 1D convolutionConv2D- 2D convolutionSeparableConv1D- Depthwise separable convolutionSeparableConv2D- 2D depthwise separable convolutionDepthwiseConv2D- Depthwise convolution
Pooling Layers
MaxPooling1D/MaxPooling2DAveragePooling1D/AveragePooling2DGlobalMaxPooling1D/GlobalMaxPooling2DGlobalAveragePooling1D/GlobalAveragePooling2D
Normalization Layers
BatchNormalizationLayerNormalization
Recurrent Layers
SimpleRNNLSTMGRUBidirectional
Merge Layers
Add,Subtract,MultiplyAverage,Maximum,MinimumConcatenateDot
Other Layers
EmbeddingSoftmaxZeroPadding1D/ZeroPadding2DUpSampling1D/UpSampling2DResize
