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

Add static_argnames to pjit and lower #9452

Closed
rsepassi opened this issue Feb 4, 2022 · 3 comments
Closed

Add static_argnames to pjit and lower #9452

rsepassi opened this issue Feb 4, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@rsepassi
Copy link
Contributor

rsepassi commented Feb 4, 2022

jit has static_argnames. Would be great to also have that for pjit and for the AoT api lower.

@rsepassi rsepassi added the enhancement New feature or request label Feb 4, 2022
@andyehrenberg
Copy link

Would this be as simple as having

def extend_argnums_from_argnames(fun, argnums, argnames) -> Tuple[int, ...]:
    argnums, argnames = _infer_argnums_and_argnames(fun, argnums, argnames)
    if not argnames:
        return argnums
    else:
        try:
            signature = inspect.signature(fun)
        except ValueError:
            parameters: Mapping[str, inspect.Parameter] = {}
        else:
            parameters = signature.parameters
        added_argnums = tuple(
            i for i, (k, param) in enumerate(parameters.items())
            if param.kind == _POSITIONAL_OR_KEYWORD and k in argnames and i not in argnums
        )
        return argnums + added_argnums

And then within pjit, adding static_argnames as an argument and doing:

static_argnums = extend_argnums_from_argnames(fun, static_argnums, static_argnames)

Happy to write a PR if this seems like a reasonable approach!

@apaszke
Copy link
Member

apaszke commented May 4, 2022

That looks approximately right, although I do think that it would be better to reuse _infer_argnums_and_argnames to be consistent with jit. If you have the time, PRs are definitely welcome!

@yashk2810
Copy link
Member

This is fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants