While debugging my own code, I noticed that CompiledLogicNet cannot be used to compile a model with just a single logic gate:
llkw = {
'connections': 'random',
'implementation': 'python',
'device': 'cpu'
}
model = torch.nn.Sequential(
torch.nn.Flatten(),
LogicLayer(in_dim=2, out_dim=1, **llkw),
GroupSum(1, tau=1)
)
compiled_model = CompiledLogicNet(
model=model,
num_bits=8,
cpu_compiler='gcc',
verbose=False
)
compiled_model.compile(
save_lib_path='minimal_example.so',
verbose=False
)
leads to the following error message:
error: use of undeclared identifier 'v0'
out[0] = (char) (~v0 | v1);
^
error: use of undeclared identifier 'v1'
out[0] = (char) (~v0 | v1);
^
This is because it produces the following c-code:
void logic_gate_net(char const *inp, char *out) {
out[0] = (char) (~v0 | v1);
}
where v0 and v1 are not declared.
While debugging my own code, I noticed that
CompiledLogicNetcannot be used to compile a model with just a single logic gate:leads to the following error message:
This is because it produces the following c-code:
where
v0andv1are not declared.