brevitas icon indicating copy to clipboard operation
brevitas copied to clipboard

__init__() got multiple values for keyword argument 'tie_input_output_quant'

Open MohamedA95 opened this issue 3 years ago • 0 comments

Hello everyone, I am trying to define a conv layer where input & output quantizers use the same scale factor so the fractional bit_width is equal. I tried setting tie_input_output_quant=True by defining the layer like this:

qnn.QuantConv2d(3,32,kernel_size=3,stride=1,padding=0,dilation=1,groups=1,bias=True, weight_quant=WEIGHT_QUANTIZER,bias_quant=BIAS_QUANTIZER,tie_input_output_quant=True, input_quant=INPUT_QUANTIZER,
weight_bit_width=bit_width,input_bit_width=bit_width, return_quant_tensor=True)

But I got the following error:

Traceback (most recent call last):
  File "train.py", line 88, in <module>
    main(config)
  File "train.py", line 39, in main
    model = config.init_obj('arch', module_arch)
  File "/home/habi/parse_config.py", line 93, in init_obj
    return getattr(module, module_name)(*args, **module_args)
  File "/home/habi/model/testtt.py", line 39, in __init__
    conv0=qnn.QuantConv2d(3,32,kernel_size=3,stride=1,padding=0,dilation=1,groups=1,bias=True,
  File "/home/habi/.local/lib/python3.8/site-packages/brevitas/nn/quant_conv.py", line 181, in __init__
    QuantWBIOL.__init__(
  File "/home/habi/.local/lib/python3.8/site-packages/brevitas/nn/quant_layer.py", line 299, in __init__
    QuantInputOutputLayer.__init__(
TypeError: __init__() got multiple values for keyword argument 'tie_input_output_quant'

As far as I understand from the code, tie_input_output_quant is passed from QuantConv2d to QuantWBIOL and finally to QuantInputOutputLayer in this line where it is already set by default to false but it's also passed in kwargs so QuantInputOutputLayer.__init__ receives it twice. What would be the proper way to set it? should QuantWeightBiasInputOutputLayer solve the conflict before calling QuantInputOutputLayer.__init__ ?

MohamedA95 avatar Feb 22 '22 15:02 MohamedA95