-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Aryan contri3 #26488
Aryan contri3 #26488
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,26 @@ def to_list(x: JaxArray, /) -> list: | |
return _to_array(x).tolist() | ||
|
||
|
||
# ivy/utils/assertions.py | ||
|
||
def get_positive_axis_for_gather(axis, ndims): | ||
if not isinstance(axis, int): | ||
raise TypeError(f"{axis} must be an int; got {type(axis).__name__}") | ||
if ndims is not None: | ||
if 0 <= axis < ndims: | ||
return axis | ||
elif -ndims <= axis < 0: | ||
return axis + ndims | ||
else: | ||
raise ValueError(f"{axis}={axis} out of bounds: " | ||
f"expected {-ndims}<={axis}<{ndims}") | ||
elif axis < 0: | ||
raise ValueError(f"{axis} may only be negative " | ||
f"if {ndims} is statically known.") | ||
return axis | ||
|
||
# ivy/functional/backends/jax/general.py | ||
|
||
def gather( | ||
params: JaxArray, | ||
indices: JaxArray, | ||
|
@@ -129,7 +149,7 @@ def gather( | |
batch_dims: int = 0, | ||
out: Optional[JaxArray] = None, | ||
) -> JaxArray: | ||
axis = axis % len(params.shape) | ||
axis = get_positive_axis_for_gather(axis, params.ndim) | ||
batch_dims = batch_dims % len(params.shape) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As was discussed on #26624, you will need to make the same change to all backends and also change the default value of the |
||
ivy.utils.assertions.check_gather_input_valid(params, indices, axis, batch_dims) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, please make sure to search for all the places that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok will fix it give 2 days |
||
result = [] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Aryan8912, I think this docstring edit and the edit in the
rst
file are not related to the PR. We generally want to keep each PR focused on a specific issue. Could you remove those?