-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DependencyError: Sigmoid.__init__ have arbitrary argument list and keyword arguments #624
Comments
Hi, |
Would you mind sending me a minimal script to reproduce the error? |
here is the minimal script: ` import torch from brevitas.nn import QuantConv2d, QuantIdentity from brevitas.quant.scaled_int import Int8ActPerTensorFloat inp = torch.randn(1, 2, 5, 5) return_quant_identity = QuantIdentity(return_quant_tensor=True) out_tensor = return_quant_identity(inp) assert out_tensor.is_valid from brevitas.nn import QuantSigmoid return_disabled_quant_sigmoid = QuantSigmoid(act_quant=None, return_quant_tensor=True) sigmoid_out_tensor = return_disabled_quant_sigmoid(out_tensor) ` |
I found a bug in the code you shared, but it does not match with the DepencyError you shared, which I can't seem to be able to reproduce. What version of brevitas/torch are you using? Have you tried with other brevitas examples? Do they work or do you see the same error elsewhere? |
hi, the torch version that I use is 2.0.1 and yes I also have try the other activation function (QuantReLU and QuantHardTanh), and they work without any error. |
update: I try to reinstall everything and now it work fine. |
Glad to hear! Let us know if you face any other issue with Brevitas. |
Hello, I think I have a similar issue when using Traceback (most recent call last):
File "/home/ninfueng/github/lstm-gru-echo-precision/test.py", line 5, in <module>
QuantSigmoid()
File "/home/ninfueng/miniconda3/lib/python3.10/site-packages/brevitas/nn/quant_activation.py", line 69, in __init__
QuantNLAL.__init__(
File "/home/ninfueng/miniconda3/lib/python3.10/site-packages/brevitas/nn/quant_layer.py", line 36, in __init__
QuantNonLinearActMixin.__init__(self, act_impl, passthrough_act, act_quant, **kwargs)
File "/home/ninfueng/miniconda3/lib/python3.10/site-packages/brevitas/nn/mixin/act.py", line 118, in __init__
QuantProxyMixin.__init__(
File "/home/ninfueng/miniconda3/lib/python3.10/site-packages/brevitas/nn/mixin/base.py", line 69, in __init__
quant_injector = quant_injector.let(**filter_kwargs(kwargs_prefix, kwargs))
File "/home/ninfueng/miniconda3/lib/python3.10/site-packages/_dependencies/injector.py", line 129, in let
return type(cls.__name__, (cls,), kwargs)
File "/home/ninfueng/miniconda3/lib/python3.10/site-packages/brevitas/inject/__init__.py", line 94, in __new__
dependencies[name] = _make_dependency_spec(name, dep)
File "/home/ninfueng/miniconda3/lib/python3.10/site-packages/_dependencies/spec.py", line 26, in _make_dependency_spec
return _make_init_spec(dependency)
File "/home/ninfueng/miniconda3/lib/python3.10/site-packages/_dependencies/classes.py", line 13, in _make_init_spec
args, have_defaults = _make_func_spec(dependency.__init__, name, owner_message)
File "/home/ninfueng/miniconda3/lib/python3.10/site-packages/_dependencies/func.py", line 27, in _make_func_spec
_check_varargs(funcname, varargs, kwargs)
File "/home/ninfueng/miniconda3/lib/python3.10/site-packages/_dependencies/checks/func.py", line 26, in _check_varargs
raise DependencyError(message.format(name))
_dependencies.exceptions.DependencyError: Sigmoid.__init__ have arbitrary argument list and keyword arguments I have tried activations in By trial and error, I able to make class WrapSigmoid(nn.Module):
def __init__(self):
super().__init__()
def forward(self, input):
return F.sigmoid(input)
class QuantSigmoid(QuantNLAL):
def __init__(
self,
act_quant: Optional[ActQuantType] = Uint8ActPerTensorFloat,
input_quant: Optional[ActQuantType] = None,
return_quant_tensor: bool = False,
**kwargs):
QuantNLAL.__init__(
self,
# Original
# act_impl=nn.Sigmoid,
act_impl=WrapSigmoid,
passthrough_act=False,
input_quant=input_quant,
act_quant=act_quant,
return_quant_tensor=return_quant_tensor,
**kwargs) For additional information, I used |
I am experiencing the same issue. It reports error when I define the layer: self.sigmoid11 = qnn.QuantSigmoid(act_quant=Uint8ActPerTensorFloat) Exception has occurred: DependencyError
Sigmoid.__init__ have arbitrary argument list and keyword arguments
File "C:\code\brevitas\inject\__init__.py", line 94, in __new__
dependencies[name] = _make_dependency_spec(name, dep)
File "C:\code\brevitas\nn\mixin\base.py", line 69, in __init__
quant_injector = quant_injector.let(**filter_kwargs(kwargs_prefix, kwargs))
File "C:\code\brevitas\nn\mixin\act.py", line 118, in __init__
QuantProxyMixin.__init__(
File "C:\code\brevitas\nn\quant_layer.py", line 36, in __init__
QuantNonLinearActMixin.__init__(self, act_impl, passthrough_act, act_quant, **kwargs)
File "C:\code\brevitas\nn\quant_activation.py", line 42, in __init__
QuantNLAL.__init__(
File "C:\code\model_brevitas.py", line 97, in __init__
self.sigmoid11 = qnn.QuantSigmoid(act_quant=Uint8ActPerTensorFloat)
File "C:\code\train.py", line 39, in train
model = AADD()
File "C:\code\train.py", line 94, in <module>
train()
_dependencies.exceptions.DependencyError: Sigmoid.__init__ have arbitrary argument list and keyword arguments
|
Hi, I'm new in brevitas. When I try to run these code:
from brevitas.nn import QuantSigmoid return_disabled_quant_sigmoid = QuantSigmoid(act_quant=None, return_quant_tensor=True) sigmoid_out_tensor = return_disabled_quant_sigmoid(out_tensor) sigmoid_out_tensor
I got this error:
`---------------------------------------------------------------------------
DependencyError Traceback (most recent call last)
Cell In[63], line 3
1 from brevitas.nn import QuantSigmoid
----> 3 a = QuantSigmoid()
5 return_disabled_quant_sigmoid = QuantSigmoid(act_quant=None, return_quant_tensor=True)
6 sigmoid_out_tensor = return_disabled_quant_sigmoid(out_tensor)
File ~\anaconda3\lib\site-packages\brevitas\nn\quant_activation.py:42, in QuantSigmoid.init(self, act_quant, input_quant, return_quant_tensor, **kwargs)
36 def init(
37 self,
38 act_quant: Optional[ActQuantType] = Uint8ActPerTensorFloat,
39 input_quant: Optional[ActQuantType] = None,
40 return_quant_tensor: bool = False,
41 **kwargs):
---> 42 QuantNLAL.init(
43 self,
44 act_impl=nn.Sigmoid,
45 passthrough_act=False,
46 input_quant=input_quant,
47 act_quant=act_quant,
48 return_quant_tensor=return_quant_tensor,
49 **kwargs)
File ~\anaconda3\lib\site-packages\brevitas\nn\quant_layer.py:36, in QuantNonLinearActLayer.init(self, act_impl, passthrough_act, input_quant, act_quant, return_quant_tensor, **kwargs)
34 QuantLayerMixin.init(self, return_quant_tensor)
35 QuantInputMixin.init(self, input_quant, **kwargs)
---> 36 QuantNonLinearActMixin.init(self, act_impl, passthrough_act, act_quant, **kwargs)
File ~\anaconda3\lib\site-packages\brevitas\nn\mixin\act.py:118, in QuantNonLinearActMixin.init(self, act_impl, passthrough_act, act_quant, act_proxy_prefix, act_kwargs_prefix, **kwargs)
107 def init(
108 self,
109 act_impl: Optional[Type[Module]],
(...)
113 act_kwargs_prefix='',
114 **kwargs):
115 prefixed_kwargs = {
116 act_kwargs_prefix + 'act_impl': act_impl,
117 act_kwargs_prefix + 'passthrough_act': passthrough_act}
--> 118 QuantProxyMixin.init(
119 self,
120 quant=act_quant,
121 proxy_prefix=act_proxy_prefix,
122 kwargs_prefix=act_kwargs_prefix,
123 proxy_protocol=ActQuantProxyProtocol,
124 none_quant_injector=NoneActQuant,
125 **prefixed_kwargs,
126 **kwargs)
File ~\anaconda3\lib\site-packages\brevitas\nn\mixin\base.py:69, in QuantProxyMixin.init(self, quant, proxy_protocol, none_quant_injector, proxy_prefix, kwargs_prefix, **kwargs)
67 elif isclass(quant) and issubclass(quant, (Injector, ExtendedInjector)):
68 quant_injector = quant
---> 69 quant_injector = quant_injector.let(**filter_kwargs(kwargs_prefix, kwargs))
70 quant = quant_injector.proxy_class(self, quant_injector)
71 else:
File ~\anaconda3\lib\site-packages_dependencies\injector.py:129, in let(cls, **kwargs)
127 def let(cls, **kwargs):
128 """Produce new Injector with some dependencies overwritten."""
--> 129 return type(cls.name, (cls,), kwargs)
File ~\anaconda3\lib\site-packages\brevitas\inject_init_.py:94, in _ExtendedInjectorType.new(cls, class_name, bases, namespace)
92 dependencies.update(base.dependencies)
93 for name, dep in namespace.items():
---> 94 dependencies[name] = _make_dependency_spec(name, dep)
95 _check_loops(class_name, dependencies)
96 _check_circles(dependencies)
File ~\anaconda3\lib\site-packages_dependencies\spec.py:26, in _make_dependency_spec(name, dependency)
24 return _make_nested_injector_spec(dependency)
25 elif inspect.isclass(dependency) and not name.endswith("_class"):
---> 26 return _make_init_spec(dependency)
27 elif isinstance(dependency, This):
28 return _make_this_spec(dependency)
File ~\anaconda3\lib\site-packages_dependencies\classes.py:13, in _make_init_spec(dependency)
11 name = dependency.name + "." + "init"
12 owner_message = "{cls!r} class".format(cls=dependency.name)
---> 13 args, have_defaults = _make_func_spec(dependency.init, name, owner_message)
14 return injectable, dependency, args[1:], have_defaults
File ~\anaconda3\lib\site-packages_dependencies\func.py:27, in _make_func_spec(func, funcname, owner_message)
25 if param.kind is param.VAR_KEYWORD:
26 kwargs = True
---> 27 _check_varargs(funcname, varargs, kwargs)
28 if defaults:
29 _check_cls_arguments(args, defaults, owner_message)
File ~\anaconda3\lib\site-packages_dependencies\checks\func.py:26, in _check_varargs(name, varargs, kwargs)
24 if varargs and kwargs:
25 message = "{0} have arbitrary argument list and keyword arguments"
---> 26 raise DependencyError(message.format(name))
27 elif varargs:
28 message = "{0} have arbitrary argument list"`
Is there something wrong with the code?
The text was updated successfully, but these errors were encountered: