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

Aryan contri3 #26488

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/overview/related_work/what_does_ivy_add.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ Firstly, we are adhering to the `Array API Standard`_ defined by Quansight.
In essence, they have written the standard and we have implemented it, which is pretty much as complementary as it gets.
Similarly, OctoML makes it easy for anyone to *deploy* their model anywhere, while Ivy makes it easy for anyone to mix and match any code from any frameworks and versions to *train* their model anywhere.
Again very complementary objectives.
Finally, Modular will perhaps make it possible for developers to make changes at various levels of the stack when creating ML models using their "", and this would also be a great addition to the field.
Finally, Modular will perhaps make it possible for developers to make changes at various levels of the stack when creating ML models using their own, and this would also be a great addition to the field.
Compared to Modular which focuses on the lower levels of the stack, Ivy instead unifies the ML frameworks at the functional API level, enabling code conversions to and from the user-facing APIs themselves, without diving into any of the lower level details.
All of these features are entirely complementary, and together would form a powerful suite of unifying tools for ML practitioners.
5 changes: 5 additions & 0 deletions ivy/data_classes/array/experimental/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ def vstack(
ivy.array([[1, 2],
[5, 6],
[7, 8]])

x = ivy.array([1, 2])
y = [ivy.array([[5, 6]]), ivy.array([[7, 8]])]
ivy.vstack((x, y))
ivy.vstack((x, y, x, y))
"""
Copy link
Contributor

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?

if not isinstance(arrays, (list, tuple)):
arrays = [arrays]
Expand Down
22 changes: 21 additions & 1 deletion ivy/functional/backends/jax/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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 axis argument to 0.

ivy.utils.assertions.check_gather_input_valid(params, indices, axis, batch_dims)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, please make sure to search for all the places that ivy.gather is being used in our codespace and change the axis value as needed.
What I mean is, if ivy.gather is being called using the current default axis value, you will need to set it to axis=-1 to make up for changing the default. I hope this makes sense!

Copy link
Author

Choose a reason for hiding this comment

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

ok will fix it give 2 days

result = []
Expand Down
Loading