brevitas icon indicating copy to clipboard operation
brevitas copied to clipboard

weight_quant_type

Open ardeal opened this issue 3 years ago • 2 comments

Hi,

If I create a layer using the following code which works. my question is: key works argument weight_quant_type could not be found in the parent class(QuantLinear, QuantWeightBiasInputOutputLayer, QuantWeightMixin, QuantProxyMixin). according to Python syntax, it should report error, however, it didn't. I get confused..... where is weight_quant_type defined in those classes? or is there any other explanation about the syntax of key word argument weight_quant_type?

        self.fc1 = qnn.QuantLinear(input_size, 128, bias=True,
                                weight_quant_type=QuantType.INT, 
                                weight_bit_width=8) 

ardeal avatar Jul 04 '22 08:07 ardeal

Doesn't it at least produce a warning that a keyword argument is passed but not used?

MohamedA95 avatar Jul 04 '22 10:07 MohamedA95

@MohamedA95 , The code could be run. if the weight_quant_type syntax is wrong, it should report error instead of warning.

You could find the same example syntax in brevitas github readme page on which, both weight_bit_width and 'weight_quant_type' are the same syntax: They are passed to functions when the API is called. however, they are not in argument list of all init function of all class.

I just noticed that those 2 arguments are passed to **kwargs, and there should be no warning nor error.

My further question is: where are those 2 argument used in Brevitas code?

ardeal avatar Jul 05 '22 01:07 ardeal

The arguments are resolved through dependency injection. This page offers some insights on the architecture behind Brevitas.

We are planning to refactor how these arguments are handled to make the quantizer interface clearer.

Feel free to open a new issue or re-open this one if you have more questions.

Giuseppe5 avatar May 07 '23 15:05 Giuseppe5