-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
feat: added gradient function to numpy frontend #26987
Conversation
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.
PR Compliance Checks
Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.
Protected Branch
In order to be considered for merging, the pull request changes must not be implemented on the "main" branch. This is described in our Contributing Guide. We are closing this pull request and we would suggest that you implement your changes as described in our Contributing Guide and open a new pull request.
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.
Congrats on making your first Pull Request and thanks for supporting Ivy! 🎉
Join the conversation in our Discord.
For every PR opened, we run unit tests and comment the results in the PR to ensure the functionality remains intact.
Please make sure they are passing. 💪
If you want to check them from the action runners, you can open the display_test_results
job. 👀
It contains the following two sections:
- Combined Test Results: This shows the results of all the ivy tests that ran on the PR. ✔️
- New Failures Introduced: This lists the tests that fail on this PR.
Keep in mind that we will assign an engineer for this task and they will look at it based on the workload that they have, kindly be patient 😄.
Thank you for this PR, here is the CI results: This pull request does not result in any additional test failures. Congratulations! |
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.
Hey @michaelbabajide , thanks for creating this PR. I left some comments on the changes, could you please resolve those and add a test for the gradient function as well? Happy to review again once you're done.
@@ -57,6 +57,13 @@ def einsum( | |||
return ivy.einsum(subscripts, *operands, out=out) | |||
|
|||
|
|||
@to_ivy_arrays_and_back | |||
@from_zero_dim_arrays_to_scalar | |||
def gradient(a, /): |
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.
The function signature here should match with that of np.gradient function.
ivy/functional/frontends/numpy/linalg/matrix_and_vector_products.py
Outdated
Show resolved
Hide resolved
@from_zero_dim_arrays_to_scalar | ||
def gradient(a, /): | ||
a = promote_types_of_numpy_inputs(a) | ||
return ivy.gradient(a) |
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.
Please look into the documentation of ivy.gradient to understand the different parameters it takes as input.
Hello, |
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.
Thanks for the making the changes @michaelbabajide ! Just left another comment, let's resolve that next.
Could you also undo all the changes you have made to the docs/demos
, we shouldn't be pushing any local changes to these files to the ivy repo.
Happy to review it again once you are done.
@@ -57,6 +57,12 @@ def einsum( | |||
return ivy.einsum(subscripts, *operands, out=out) | |||
|
|||
|
|||
@to_ivy_arrays_and_back | |||
@from_zero_dim_arrays_to_scalar | |||
def gradient(a, *, axis=None, edge_order=1): |
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.
Could you add the varargs
argument that is present in the np.gradient
function. Also, let's rename a
to f
since in numpy it's the latter :)
26b1973
to
1f6264e
Compare
PR Description
added a gradient function to the numpy frontend
Related Issue
Closes #26249
Checklist
Socials