Skip to content

Commit

Permalink
Merge branch 'main' into multi_output_fix_2
Browse files Browse the repository at this point in the history
  • Loading branch information
JanFSchulte authored Nov 13, 2024
2 parents 45f96f6 + b44426d commit f9ccbef
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions hls4ml/backends/catapult/passes/merge_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

merge_config_template = """struct config{index} : nnet::merge_config {{
static const unsigned n_elem = {n_elem};
static const unsigned reuse_factor = {reuse};
}};\n"""

merge_function_template = 'nnet::{merge}<{input1_t}, {input2_t}, {output_t}, {config}>({input1}, {input2}, {output});'
Expand Down
1 change: 1 addition & 0 deletions hls4ml/backends/oneapi/passes/merge_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# Merge templates
merge_config_template = """struct config{index} : nnet::merge_config {{
static const unsigned n_elem = {n_elem};
static const unsigned reuse_factor = {reuse};
}};\n"""

merge_function_template = 'nnet::{merge}<{input1_t}, {input2_t}, {output_t}, {config}>({input1}, {input2}, {output});'
Expand Down
1 change: 1 addition & 0 deletions hls4ml/backends/quartus/passes/merge_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Merge templates
merge_config_template = """struct config{index} : nnet::merge_config {{
static const unsigned n_elem = {n_elem};
static const unsigned reuse_factor = {reuse};
}};\n"""

merge_function_template = 'nnet::{merge}<{input1_t}, {input2_t}, {output_t}, {config}>({input1}, {input2}, {output});'
Expand Down
1 change: 1 addition & 0 deletions hls4ml/backends/vivado/passes/merge_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

merge_config_template = """struct config{index} : nnet::merge_config {{
static const unsigned n_elem = {n_elem};
static const unsigned reuse_factor = {reuse};
}};\n"""

merge_function_template = 'nnet::{merge}<{input1_t}, {input2_t}, {output_t}, {config}>({input1}, {input2}, {output});'
Expand Down
1 change: 1 addition & 0 deletions hls4ml/templates/catapult/nnet_utils/nnet_merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace nnet {

struct merge_config {
static const unsigned n_elem = 10;
static const unsigned reuse_factor = 1;
};

struct dot_config {
Expand Down
1 change: 1 addition & 0 deletions hls4ml/templates/oneapi/firmware/nnet_utils/nnet_merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace nnet {

struct merge_config {
static const unsigned n_elem = 10;
static const unsigned reuse_factor = 1;
};

struct dot_config {
Expand Down
1 change: 1 addition & 0 deletions hls4ml/templates/quartus/firmware/nnet_utils/nnet_merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace nnet {

struct merge_config {
static const unsigned n_elem = 10;
static const unsigned reuse_factor = 1;
};

struct dot_config {
Expand Down
1 change: 1 addition & 0 deletions hls4ml/templates/vivado/nnet_utils/nnet_merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace nnet {

struct merge_config {
static const unsigned n_elem = 10;
static const unsigned reuse_factor = 1;
};

struct dot_config {
Expand Down
11 changes: 9 additions & 2 deletions hls4ml/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def make_layer_config(layer):


def config_from_onnx_model(
model, granularity='name', backend=None, default_precision='ap_fixed<16,6>', default_reuse_factor=1
model, granularity='name', backend=None, default_precision='fixed<16,6>', default_reuse_factor=1, max_precision=None
):
"""Create an HLS conversion config given the ONNX model.
Expand All @@ -435,6 +435,8 @@ def config_from_onnx_model(
backend(str, optional): Name of the backend to use
default_precision (str, optional): Default precision to use. Defaults to 'fixed<16,6>'.
default_reuse_factor (int, optional): Default reuse factor. Defaults to 1.
max_precision (str or None, optional): Maximum width precision to use. Defaults to None, meaning no maximum.
Note: Only integer and fixed precisions are supported
Raises:
Exception: If ONNX model has layers not supported by hls4ml.
Expand All @@ -456,9 +458,14 @@ def config_from_onnx_model(
config = {}

model_config = {}
model_config['Precision'] = default_precision
model_config['Precision'] = {}
model_config['Precision']['default'] = default_precision
if max_precision is not None:
model_config['Precision']['maximum'] = max_precision
model_config['ReuseFactor'] = default_reuse_factor
model_config['Strategy'] = 'Latency'
model_config['BramFactor'] = 1_000_000_000
model_config['TraceOutput'] = False

config['Model'] = model_config

Expand Down

0 comments on commit f9ccbef

Please sign in to comment.