Skip to content

Commit

Permalink
refactor to SumLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
n28div committed Nov 22, 2024
1 parent 2741252 commit fe5358c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cirkit/symbolic/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,8 @@ def from_logic_circuit(
if weight_factory is None:
# default to unitary weights
def weight_factory(n: tuple[int]) -> Parameter:
# locally import numpy to avoid dependency on the whole file
import numpy as np
return Parameter.from_input(ConstantParameter(*n, value=np.ones(n)))

# map each input literal to a symbolic input layer
Expand Down Expand Up @@ -955,7 +957,7 @@ def weight_factory(n: tuple[int]) -> Parameter:
if not isinstance(i, BottomNode) and i in node_to_layer
]

sum_node = MixingLayer(1, arity=len(sum_inputs), weight_factory=weight_factory)
sum_node = SumLayer(len(sum_inputs), 1, arity=len(sum_inputs), weight_factory=weight_factory)
in_layers[sum_node] = sum_inputs
node_to_layer[node] = sum_node

Expand Down

0 comments on commit fe5358c

Please sign in to comment.