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

WIP: grad #4

Closed
wants to merge 6 commits into from
Closed

WIP: grad #4

wants to merge 6 commits into from

Conversation

nstarman
Copy link
Contributor

@nstarman nstarman commented Jan 2, 2024

Get Quantity working with jax.grad.

@@ -732,7 +732,7 @@ def _infeed_p() -> Quantity:

@register(lax.integer_pow_p)
def _integer_pow_p(x: Quantity, *, y: Any) -> Quantity:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _integer_pow_p(x: Quantity, *, y: Any) -> Quantity:
def _integer_pow_p(x: Quantity, *, y: int) -> Quantity:

def _mul_p_vq(x: Value, y: Quantity) -> Quantity:
return Quantity(lax.mul(x, y.value), unit=y.unit)
def _mul_p_vq(x: DenseArrayValue, y: Quantity) -> Quantity:
return Quantity(lax.mul(x.array, y.value), unit=y.unit)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that the .array is necessary. I was getting an infinite loop, but didn't investigate whether this was the best solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole file will hopefully not be necessary if patrick-kidger/quax#5 is resolved successfully.

Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
@nstarman nstarman closed this Feb 20, 2024
@nstarman nstarman deleted the grad branch February 20, 2024 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant