Skip to content

Cannot compile minimal model with one gate #20

@ligerlac

Description

@ligerlac

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions