Skip to content

Commit

Permalink
Add support for multiple default configurations of the same type for …
Browse files Browse the repository at this point in the history
…different node types
  • Loading branch information
klassen9 committed Jun 29, 2024
1 parent db969e6 commit 157d808
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/qonnx/transformation/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,14 @@ def apply(self, model):
used_configurations += [node.name]

# set specified defaults
default_configs = {k: v for k, v in model_config["Defaults"].items() if k not in model_config}
default_configs = {k: v[0] for k, v in default_configs.items() if v[1] == "all" or node.op_type in v[1]}
default_values = []
for key, value in model_config["Defaults"].items():
assert (len(value) % 2 == 0)
if key not in model_config:
for val, op in zip(value[::2], value[1::2]):
default_values.append((key, val, op))
assert (not (op == "all" and len(value) > 2))
default_configs = {key: val for key, val, op in default_values if op == "all" or node.op_type in op}
for attr, value in default_configs.items():
inst.set_nodeattr(attr, value)

Expand Down

0 comments on commit 157d808

Please sign in to comment.