Skip to content

Commit

Permalink
Merge branch 'unifyai:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
roudik authored Sep 16, 2023
2 parents 9ae26ee + 9a36235 commit 58838ad
Show file tree
Hide file tree
Showing 89 changed files with 1,240 additions and 547 deletions.
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,21 @@ Close #

- [ ] Did you add a function?
- [ ] Did you add the tests?
- [ ] Did you run your tests and are your tests passing?
- [ ] Did pre-commit not fail on any check?
- [ ] Did you follow the steps we provided?

<!--
Please mark your PR as a draft if you realise after the fact that your tests are not passing or
that your pre-commit check has some failures.
Here are some relevant resources regarding tests and pre-commit:
https://unify.ai/docs/ivy/overview/deep_dive/ivy_tests.html
https://unify.ai/docs/ivy/overview/deep_dive/formatting.html#pre-commit
-->

### Socials:

<!--
Expand Down
Original file line number Diff line number Diff line change
@@ -1,62 +1,55 @@
name: Check Semantic and welcome new contributors

on:
pull_request_target:
types:
- opened
- edited
- synchronize
- reopened
workflow_call:

permissions:
pull-requests: write

jobs:
semantics:
name: Semantics
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: amannn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

pr-compliance-checks:
name: PR Compliance Checks
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: mtfoley/[email protected]
with:
body-auto-close: false
protected-branch-auto-close: false
body-comment: >
## Issue Reference
In order to be considered for merging, the pull request description must refer to a
specific issue number. This is described in our
[contributing guide](https://unify.ai/docs/ivy/overview/contributing/the_basics.html#todo-list-issues) and our PR template.
This check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue
number that this PR is meant to address.
welcome:
name: Welcome
runs-on: ubuntu-latest
timeout-minutes: 10
needs: semantics
if: github.event.action == 'opened'
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pr-message: |-
Congrats on making your first Pull Request and thanks for supporting Ivy! 🎉
Joing the conversation in our [Discord](https://discord.com/invite/sXyFF8tDtm)
Here are some notes to understand our tests:
- We have merged all the tests in one file called \`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 are passing on main, but fail on the PR Fork.
Please try to make sure that there are no such tests. 💪
name: Check Semantic and welcome new contributors

on:
pull_request_target:
types:
- opened
- edited
- synchronize
- reopened
workflow_call:

permissions:
pull-requests: write

jobs:
pr-compliance-checks:
name: PR Compliance Checks
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: mtfoley/[email protected]
with:
body-auto-close: false
protected-branch-auto-close: false
body-comment: >
## Issue Reference
In order to be considered for merging, the pull request description must refer to a
specific issue number. This is described in our
[contributing guide](https://unify.ai/docs/ivy/overview/contributing/the_basics.html#todo-list-issues) and our PR template.
This check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue
number that this PR is meant to address.
welcome:
name: Welcome
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.event.action == 'opened'
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pr-message: |-
Congrats on making your first Pull Request and thanks for supporting Ivy! 🎉
Join the conversation in our [Discord](https://discord.com/invite/sXyFF8tDtm)
Here are some notes to understand our tests:
- We have merged all the tests in one file called \`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 fails on this PR.
Please make sure they are passing. 💪
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, so be patient.
2 changes: 1 addition & 1 deletion docs/demos
Submodule demos updated from 8163e5 to 14156a
4 changes: 2 additions & 2 deletions docs/overview/contributing/error_handling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Error Handling

This section, "Error Handling" aims to assist you in navigating through some common errors you might encounter while working with the Ivy's Functional API. We'll go through some common errors which you might encounter while working as a contributor or a developer.

#. This is the case where we pass in a dtype to `torch` which is not actually supported by the torch's native framework itself. The function which was
#. This is the case where we pass in a dtype to `torch` which is not actually supported by the torch's native framework itself.

.. code-block:: python
Expand Down Expand Up @@ -64,7 +64,7 @@ This section, "Error Handling" aims to assist you in navigating through some com
E
E You can reproduce this example by temporarily adding @reproduce_failure('6.82.4', b'AXicY2BAABYQwQgiAABDAAY=') as a decorator on your test case
#. This is a similar assertion as stated in point 2 but with torch and ground-truth tensorflow not matching but the matrices are quite different so there should be an issue in the backends rather than a numerical instability here:
#. This is a similar assertion as stated in point 2 but with torch and ground-truth tensorflow not matching but the matrices are quite different so there should be an issue in the backends rather than a numerical instability here.
.. code-block:: python
Expand Down
13 changes: 11 additions & 2 deletions ivy/data_classes/array/activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,23 @@ def mish(
"""
return ivy.mish(self._data, complex_mode=complex_mode, out=out)

def hardswish(self: ivy.Array, /, *, out: Optional[ivy.Array] = None) -> ivy.Array:
def hardswish(
self: ivy.Array,
/,
*,
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Apply the hardswish activation function element-wise.
Parameters
----------
x
input array
complex_mode
optional specifier for how to handle complex data types. See
``ivy.func_wrapper.handle_complex_input`` for more detail.
out
optional output array, for writing the result to. It must have
a shape that the inputs broadcast to.
Expand Down Expand Up @@ -385,4 +394,4 @@ def hardswish(self: ivy.Array, /, *, out: Optional[ivy.Array] = None) -> ivy.Arr
b: ivy.array([0., 5.])
}
"""
return ivy.hardswish(self._data, out=out)
return ivy.hardswish(self._data, complex_mode=complex_mode, out=out)
12 changes: 6 additions & 6 deletions ivy/data_classes/array/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def to_ivy(
the input in its native framework form in the case of ivy.Array or instances.
"""
if nested:
return ivy.nested_map(x, _to_ivy, include_derived, shallow=False)
return ivy.nested_map(_to_ivy, x, include_derived, shallow=False)
return _to_ivy(x)


Expand Down Expand Up @@ -107,8 +107,8 @@ def args_to_ivy(
the same arguments, with any nested arrays converted to ivy.Array or
instances.
"""
native_args = ivy.nested_map(args, _to_ivy, include_derived, shallow=False)
native_kwargs = ivy.nested_map(kwargs, _to_ivy, include_derived, shallow=False)
native_args = ivy.nested_map(_to_ivy, args, include_derived, shallow=False)
native_kwargs = ivy.nested_map(_to_ivy, kwargs, include_derived, shallow=False)
return native_args, native_kwargs


Expand Down Expand Up @@ -147,8 +147,8 @@ def to_native(
"""
if nested:
return ivy.nested_map(
x,
lambda x: _to_native(x, inplace=cont_inplace, to_ignore=to_ignore),
x,
include_derived,
shallow=False,
)
Expand Down Expand Up @@ -188,14 +188,14 @@ def args_to_native(
native form.
"""
native_args = ivy.nested_map(
args,
lambda x: _to_native(x, inplace=cont_inplace, to_ignore=to_ignore),
args,
include_derived,
shallow=False,
)
native_kwargs = ivy.nested_map(
kwargs,
lambda x: _to_native(x, inplace=cont_inplace, to_ignore=to_ignore),
kwargs,
include_derived,
shallow=False,
)
Expand Down
13 changes: 11 additions & 2 deletions ivy/data_classes/array/experimental/activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,23 @@ def prelu(
"""
return ivy.prelu(self._data, slope, out=out)

def relu6(self, /, *, out: Optional[ivy.Array] = None) -> ivy.Array:
def relu6(
self,
/,
*,
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Apply the rectified linear unit 6 function element-wise.
Parameters
----------
self
input array
complex_mode
optional specifier for how to handle complex data types. See
``ivy.func_wrapper.handle_complex_input`` for more detail.
out
optional output array, for writing the result to.
It must have a shape that the inputs broadcast to.
Expand All @@ -156,7 +165,7 @@ def relu6(self, /, *, out: Optional[ivy.Array] = None) -> ivy.Array:
>>> print(y)
ivy.array([0., 0., 1., 2., 3., 4., 5., 6., 6.])
"""
return ivy.relu6(self._data, out=out)
return ivy.relu6(self._data, complex_mode=complex_mode, out=out)

def logsigmoid(
self: ivy.Array,
Expand Down
10 changes: 10 additions & 0 deletions ivy/data_classes/container/activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,7 @@ def _static_hardswish(
to_apply: Union[bool, ivy.Container] = True,
prune_unapplied: Union[bool, ivy.Container] = False,
map_sequences: Union[bool, ivy.Container] = False,
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Container] = None,
) -> ivy.Container:
"""
Expand All @@ -1142,6 +1143,9 @@ def _static_hardswish(
map_sequences
Whether to also map method to sequences (lists, tuples).
Default is ``False``.
complex_mode
optional specifier for how to handle complex data types. See
``ivy.func_wrapper.handle_complex_input`` for more detail.
out
optional output container, for writing the result to. It must have a shape
that the inputs broadcast to.
Expand Down Expand Up @@ -1169,6 +1173,7 @@ def _static_hardswish(
to_apply=to_apply,
prune_unapplied=prune_unapplied,
map_sequences=map_sequences,
complex_mode=complex_mode,
out=out,
)

Expand All @@ -1180,6 +1185,7 @@ def hardswish(
to_apply: Union[bool, ivy.Container] = True,
prune_unapplied: Union[bool, ivy.Container] = False,
map_sequences: Union[bool, ivy.Container] = False,
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Container] = None,
) -> ivy.Container:
"""
Expand All @@ -1202,6 +1208,9 @@ def hardswish(
map_sequences
Whether to also map method to sequences (lists, tuples).
Default is ``False``.
complex_mode
optional specifier for how to handle complex data types. See
``ivy.func_wrapper.handle_complex_input`` for more detail.
out
optional output container, for writing the result to. It must have a shape
that the inputs broadcast to.
Expand All @@ -1228,5 +1237,6 @@ def hardswish(
to_apply=to_apply,
prune_unapplied=prune_unapplied,
map_sequences=map_sequences,
complex_mode=complex_mode,
out=out,
)
2 changes: 1 addition & 1 deletion ivy/data_classes/container/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3265,7 +3265,7 @@ def cont_map(
return_dict[key] = ret
elif isinstance(value, (list, tuple)) and map_sequences:
ret = ivy.nested_map(
value, lambda x: func(x, None), True, shallow=False
lambda x: func(x, None), value, True, shallow=False
)
if prune_unapplied and not ret:
continue
Expand Down
10 changes: 10 additions & 0 deletions ivy/data_classes/container/experimental/activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def static_relu6(
to_apply: Union[bool, ivy.Container] = True,
prune_unapplied: Union[bool, ivy.Container] = False,
map_sequences: Union[bool, ivy.Container] = False,
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Container] = None,
) -> ivy.Container:
"""
Expand All @@ -351,6 +352,9 @@ def static_relu6(
map_sequences
Whether to also map method to sequences (lists, tuples).
Default is ``False``.
complex_mode
optional specifier for how to handle complex data types. See
``ivy.func_wrapper.handle_complex_input`` for more detail.
out
optional output container, for writing the result to. It must have a shape
that the inputs broadcast to.
Expand Down Expand Up @@ -379,6 +383,7 @@ def static_relu6(
to_apply=to_apply,
prune_unapplied=prune_unapplied,
map_sequences=map_sequences,
complex_mode=complex_mode,
out=out,
)

Expand All @@ -390,6 +395,7 @@ def relu6(
to_apply: Union[bool, ivy.Container] = True,
prune_unapplied: Union[bool, ivy.Container] = False,
map_sequences: Union[bool, ivy.Container] = False,
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Container] = None,
) -> ivy.Container:
"""
Expand All @@ -412,6 +418,9 @@ def relu6(
map_sequences
Whether to also map method to sequences (lists, tuples).
Default is ``False``.
complex_mode
optional specifier for how to handle complex data types. See
``ivy.func_wrapper.handle_complex_input`` for more detail.
out
optional output container, for writing the result to. It must have a shape
that the inputs broadcast to.
Expand Down Expand Up @@ -439,6 +448,7 @@ def relu6(
to_apply=to_apply,
prune_unapplied=prune_unapplied,
map_sequences=map_sequences,
complex_mode=complex_mode,
out=out,
)

Expand Down
2 changes: 1 addition & 1 deletion ivy/data_classes/nested_array/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def broadcast_shapes(shapes):

def ragged_map(self, fn):
arg = ivy.copy_nest(self._data)
ivy.nested_map(arg, lambda x: fn(x), shallow=True)
ivy.nested_map(lambda x: fn(x), arg, shallow=True)
# infer dtype, shape, and device from the first array in the ret data
arr0_id = ivy.nested_argwhere(arg, ivy.is_ivy_array, stop_after_n_found=1)[0]
arr0 = ivy.index_nest(arg, arr0_id)
Expand Down
Loading

0 comments on commit 58838ad

Please sign in to comment.