@@ -422,7 +422,7 @@ def make_layer_config(layer):
422422
423423
424424def config_from_onnx_model (
425- model , granularity = 'name' , backend = None , default_precision = 'ap_fixed <16,6>' , default_reuse_factor = 1
425+ model , granularity = 'name' , backend = None , default_precision = 'fixed <16,6>' , default_reuse_factor = 1 , max_precision = None
426426):
427427 """Create an HLS conversion config given the ONNX model.
428428
@@ -444,6 +444,8 @@ def config_from_onnx_model(
444444 backend(str, optional): Name of the backend to use
445445 default_precision (str, optional): Default precision to use. Defaults to 'fixed<16,6>'.
446446 default_reuse_factor (int, optional): Default reuse factor. Defaults to 1.
447+ max_precision (str or None, optional): Maximum width precision to use. Defaults to None, meaning no maximum.
448+ Note: Only integer and fixed precisions are supported
447449
448450 Raises:
449451 Exception: If ONNX model has layers not supported by hls4ml.
@@ -465,9 +467,14 @@ def config_from_onnx_model(
465467 config = {}
466468
467469 model_config = {}
468- model_config ['Precision' ] = default_precision
470+ model_config ['Precision' ] = {}
471+ model_config ['Precision' ]['default' ] = default_precision
472+ if max_precision is not None :
473+ model_config ['Precision' ]['maximum' ] = max_precision
469474 model_config ['ReuseFactor' ] = default_reuse_factor
470475 model_config ['Strategy' ] = 'Latency'
476+ model_config ['BramFactor' ] = 1_000_000_000
477+ model_config ['TraceOutput' ] = False
471478
472479 config ['Model' ] = model_config
473480
0 commit comments