Skip to content
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

dtype constraints does not work for overloaded functions #300

Open
pranavm-nvidia opened this issue Oct 24, 2024 · 0 comments
Open

dtype constraints does not work for overloaded functions #300

pranavm-nvidia opened this issue Oct 24, 2024 · 0 comments
Labels
good first issue Good for newcomers

Comments

@pranavm-nvidia
Copy link
Collaborator

The dtype constraints decorator doesn't currently work for overloaded functions since it stores the functions by name in the TYPE_VERIFICATION map.

We can make the following changes to make it work for overloaded functions:

  1. Update the docstring directly in the decorator instead of in conf.py. If we do it in conf.py, we need to be able to look up the overloaded functions in the TYPE_VERIFICATION map which will require us to disambiguate them somehow. Note that a naive approach of using the function object as the key doesn't work because decorating a function with other decorators will change the function object - basically, the object seen at the point where the constraints decorator is applied might not be the same one seen during documentation generation (e.g. if there are any further decorators applied at that point).
  2. Update TYPE_VERIFICATION to some type of multimap so that we can generate the tests correctly.
  3. Finally, if we need to access type verification information for other reasons (e.g. to determine which dtypes to use when automatically converting inputs to tensors), we could attach it directly to the function object. We will then need some logic to recurse through the various layers of .__wrapped__ functions to find the dtype information.
@pranavm-nvidia pranavm-nvidia added the good first issue Good for newcomers label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant