@@ -413,7 +413,7 @@ def make_layer_config(layer):
413
413
414
414
415
415
def config_from_onnx_model (
416
- model , granularity = 'name' , backend = None , default_precision = 'ap_fixed <16,6>' , default_reuse_factor = 1
416
+ model , granularity = 'name' , backend = None , default_precision = 'fixed <16,6>' , default_reuse_factor = 1 , max_precision = None
417
417
):
418
418
"""Create an HLS conversion config given the ONNX model.
419
419
@@ -435,6 +435,8 @@ def config_from_onnx_model(
435
435
backend(str, optional): Name of the backend to use
436
436
default_precision (str, optional): Default precision to use. Defaults to 'fixed<16,6>'.
437
437
default_reuse_factor (int, optional): Default reuse factor. Defaults to 1.
438
+ max_precision (str or None, optional): Maximum width precision to use. Defaults to None, meaning no maximum.
439
+ Note: Only integer and fixed precisions are supported
438
440
439
441
Raises:
440
442
Exception: If ONNX model has layers not supported by hls4ml.
@@ -456,9 +458,14 @@ def config_from_onnx_model(
456
458
config = {}
457
459
458
460
model_config = {}
459
- model_config ['Precision' ] = default_precision
461
+ model_config ['Precision' ] = {}
462
+ model_config ['Precision' ]['default' ] = default_precision
463
+ if max_precision is not None :
464
+ model_config ['Precision' ]['maximum' ] = max_precision
460
465
model_config ['ReuseFactor' ] = default_reuse_factor
461
466
model_config ['Strategy' ] = 'Latency'
467
+ model_config ['BramFactor' ] = 1_000_000_000
468
+ model_config ['TraceOutput' ] = False
462
469
463
470
config ['Model' ] = model_config
464
471
0 commit comments