lf1-io / padl

Functional deep learning
Apache License 2.0
106 stars 4 forks source link

is `_pd_number_of_inputs` being used? #383

Closed wuhu closed 2 years ago

wuhu commented 2 years ago

@jasonkhadka I don't see it set to anything other than None.

sjrl commented 2 years ago

Yes, it looks like it is set in padl/wrap.py

    # Special checks
    if isinstance(fun, np.ufunc):
        wrapper._pd_number_of_inputs = fun.nin

However, I'm not sure if _pd_number_of_inputs should be set in more places.

jasonkhadka commented 2 years ago

yes, it is used for special case of numpy.ufunc where it is not possible to inspect the signature directly. This allows for checking whether the args for FunctionTransform that wraps ufunc should be unpacked or not.

In Wrap.py https://github.com/lf1-io/padl/blob/8813a8785faac8f67aaf1a2974fa72d7754158f3/padl/wrap.py#L70

Transforms https://github.com/lf1-io/padl/blob/8813a8785faac8f67aaf1a2974fa72d7754158f3/padl/transforms.py#L701

FunctionTransforms https://github.com/lf1-io/padl/blob/8813a8785faac8f67aaf1a2974fa72d7754158f3/padl/transforms.py#L1164

wuhu commented 2 years ago

Ok, thanks.