Skip to content

Commit 157d808

Browse files
committed
Add support for multiple default configurations of the same type for different node types
1 parent db969e6 commit 157d808

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/qonnx/transformation/general.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,14 @@ def apply(self, model):
340340
used_configurations += [node.name]
341341

342342
# set specified defaults
343-
default_configs = {k: v for k, v in model_config["Defaults"].items() if k not in model_config}
344-
default_configs = {k: v[0] for k, v in default_configs.items() if v[1] == "all" or node.op_type in v[1]}
343+
default_values = []
344+
for key, value in model_config["Defaults"].items():
345+
assert (len(value) % 2 == 0)
346+
if key not in model_config:
347+
for val, op in zip(value[::2], value[1::2]):
348+
default_values.append((key, val, op))
349+
assert (not (op == "all" and len(value) > 2))
350+
default_configs = {key: val for key, val, op in default_values if op == "all" or node.op_type in op}
345351
for attr, value in default_configs.items():
346352
inst.set_nodeattr(attr, value)
347353

0 commit comments

Comments
 (0)