Xilinx / logicnets

Apache License 2.0
81 stars 26 forks source link

Neq2LUT.py is not working #22

Closed HumzaSami00 closed 2 years ago

HumzaSami00 commented 2 years ago

I am trying to reproduce the work and facing some errors. I have installed and setup exactly as mentioned in the GitHub readme. I trained the model first and then ran neq2lut.py.I am facing the following error while running the neq2lut.py. I have not changed anything in the code

-------------------------------------- ERROR--------------------------------------------

`Running inference on baseline model...

Baseline accuracy: 81.103338

Converting to NEQs to LUTs...

Calculating truth tables for module_list.0

Traceback (most recent call last):

File "neq2lut.py", line 133, in

generate_truth_tables(lut_model, verbose=True)

File "/home/humza0000/.local/lib/python3.8/site-packages/logicnets/nn.py", line 44, in generate_truth_tables

module.calculate_truth_tables()

File "/home/humza0000/.local/lib/python3.8/site-packages/logicnets/nn.py", line 242, in calculate_truth_tables

neuron_state_space = self.input_quant.get_state_space() # TODO: this call should include the index of the element of interest

File "/home/humza0000/.local/lib/python3.8/site-packages/logicnets/quant.py", line 96, in get_state_space

quant_type = self.get_quant_type()

File "/home/humza0000/.local/lib/python3.8/site-packages/logicnets/quant.py", line 74, in get_quant_type

brevitas_module_type = type(self.brevitas_module.act_quant_proxy.fused_activation_quant_proxy.tensor_quant)

File "/home/humza0000/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1185, in getattr

raise AttributeError("'{}' object has no attribute '{}'".format(

AttributeError: 'QuantRelu' object has no attribute 'act_quant_proxy'`

@nickfraser @maltanar @MattSnow-xlnx

panshi221 commented 2 years ago

Same problem here. AttributeError: 'QuantReLU' object has no attribute 'act_quant_proxy'

HumzaSami00 commented 2 years ago

@panshi221 I assume their code is outdated and we have installed the new version of brevitas and pyverilator packeges. Please let me know if you able to fix this.

nickfraser commented 2 years ago

@HumzaSami00, I think your suspicion is correct. However, the error you're seeing is only related to brevitas, not pyverilator.

Are you running this in docker using the dockerfile provided? Or natively? Can you try docker? Alternately, can you try installing the brevitas commit which is pinned in the dockerfile?

nickfraser commented 2 years ago

@volcacius, are you aware of in which brevitas version this API change was made? If so, I can update the requirements.txt file accordingly... I suspect this is from several years ago, otherwise I will track it down.

HumzaSami00 commented 2 years ago

Hi @nickfraser , I am doing it nativly. I haven't tried the docker approach. I will try it and let you know

HumzaSami00 commented 2 years ago

Hey @nickfraser , I changed brevitas version to the older one (which you mentioned above) and it worked. Thanks man

@panshi221 Please check his answer

panshi221 commented 2 years ago

Thanks for sharing! Now the program is able to calculate truth tables. But I ran into a new problem, the program was stuck at 'Running inference on LUT-based model' for more than an hour. Have you encountered a similar situation? @HumzaSami00

HumzaSami00 commented 2 years ago

@panshi221 Yeah it took a lot of time. To avoid this, I reduced the number of neurons in each layer.