Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/unifyai/ivy into max_pool3d
Browse files Browse the repository at this point in the history
sync with upstream
  • Loading branch information
progs2002 committed Aug 31, 2023
2 parents 89b98c5 + 701136e commit 9080772
Show file tree
Hide file tree
Showing 119 changed files with 1,788 additions and 702 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/synchronize-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Synchronize DB
on:
workflow_dispatch:
permissions:
actions: read
jobs:
synchronize-db:
runs-on: ubuntu-latest
steps:
- name: Checkout Ivy 🛎
uses: actions/checkout@v3
with:
path: ivy
persist-credentials: false
submodules: "recursive"
fetch-depth: 1

- name: Synchronize DB
run: |
pip install pymongo
cd ivy
python run_tests_CLI/synchronize_db.py ${{ secrets.MONGODB_PASSWORD }}
2 changes: 2 additions & 0 deletions ivy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ def __deepcopy__(self, memo):
"warning_level_stack": warning_level_stack,
"queue_timeout_stack": general.queue_timeout_stack,
"array_mode_stack": general.array_mode_stack,
"inplace_mode_stack": general.inplace_mode_stack,
"soft_device_mode_stack": device.soft_device_mode_stack,
"shape_array_mode_stack": general.shape_array_mode_stack,
"show_func_wrapper_trace_mode_stack": (
Expand Down Expand Up @@ -1415,6 +1416,7 @@ def cast_data_types(val=True):
"nan_policy",
"array_mode",
"nestable_mode",
"inplace_mode",
"exception_trace_mode",
"show_func_wrapper_trace_mode",
"min_denominator",
Expand Down
40 changes: 21 additions & 19 deletions ivy/data_classes/array/activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def relu(
self: ivy.Array,
/,
*,
out: Optional[ivy.Array] = None,
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.relu. This method simply wraps the
Expand All @@ -26,12 +26,12 @@ def relu(
----------
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.
complex_mode
optional specifier for how to handle complex data types. See
``ivy.func_wrapper.handle_complex_input`` for more detail.
Returns
-------
Expand All @@ -45,15 +45,15 @@ def relu(
>>> print(y)
ivy.array([0., 0., 1.])
"""
return ivy.relu(self._data, out=out, complex_mode=complex_mode)
return ivy.relu(self._data, complex_mode=complex_mode, out=out)

def leaky_relu(
self: ivy.Array,
/,
*,
alpha: float = 0.2,
out: Optional[ivy.Array] = None,
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.leaky_relu. This method simply wraps
Expand All @@ -66,12 +66,12 @@ def leaky_relu(
input array.
alpha
the slope of the negative section.
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.
complex_mode
optional specifier for how to handle complex data types. See
``ivy.func_wrapper.handle_complex_input`` for more detail.
Returns
-------
Expand All @@ -86,16 +86,16 @@ def leaky_relu(
ivy.array([ 0.39, -0.17])
"""
return ivy.leaky_relu(
self._data, alpha=alpha, out=out, complex_mode=complex_mode
self._data, alpha=alpha, complex_mode=complex_mode, out=out
)

def gelu(
self: ivy.Array,
/,
*,
approximate: bool = False,
out: Optional[ivy.Array] = None,
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.gelu. This method simply wraps the
Expand All @@ -108,12 +108,12 @@ def gelu(
input array.
approximate
whether to use the approximate version of the gelu function.
out
optional output array, for writing the result to. It must have a shape
that the inputs broadcast to.
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.
Returns
-------
Expand All @@ -127,7 +127,9 @@ def gelu(
>>> print(y)
ivy.array([-0.138, -0.165, 1.4])
"""
return ivy.gelu(self._data, approximate=approximate, out=out)
return ivy.gelu(
self._data, approximate=approximate, complex_mode=complex_mode, out=out
)

def sigmoid(self: ivy.Array, /, *, out: Optional[ivy.Array] = None) -> ivy.Array:
"""
Expand Down Expand Up @@ -201,8 +203,8 @@ def softplus(
*,
beta: Optional[Union[int, float]] = None,
threshold: Optional[Union[int, float]] = None,
out: Optional[ivy.Array] = None,
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.softplus. This method simply wraps the
Expand All @@ -217,11 +219,11 @@ def softplus(
the beta parameter of the softplus function.
threshold
the threshold parameter of the softplus function.
out
optional output array, for writing the result to. It must have a shape
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
Returns
-------
Expand Down Expand Up @@ -249,8 +251,8 @@ def softplus(
self._data,
beta=beta,
threshold=threshold,
out=out,
complex_mode=complex_mode,
out=out,
)

def log_softmax(
Expand Down
14 changes: 11 additions & 3 deletions ivy/data_classes/array/elementwise.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# global
import abc
from typing import Optional, Union
from typing import Optional, Union, Literal

# local
import ivy
Expand Down Expand Up @@ -2552,7 +2552,12 @@ def tan(self: ivy.Array, *, out: Optional[ivy.Array] = None) -> ivy.Array:
"""
return ivy.tan(self._data, out=out)

def tanh(self: ivy.Array, *, out: Optional[ivy.Array] = None) -> ivy.Array:
def tanh(
self: ivy.Array,
*,
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.tanh. This method simply wraps the
function, and so the docstring for ivy.tanh also applies to this method with
Expand All @@ -2563,6 +2568,9 @@ def tanh(self: ivy.Array, *, out: Optional[ivy.Array] = None) -> ivy.Array:
self
input array whose elements each represent a hyperbolic angle.
Should have a real-valued floating-point data type.
complex_mode
optional specifier for how to handle complex data types. See
``ivy.func_wrapper.handle_complex_input`` for more detail.
out
optional output, for writing the result to. It must have a shape that the
inputs broadcast to.
Expand All @@ -2581,7 +2589,7 @@ def tanh(self: ivy.Array, *, out: Optional[ivy.Array] = None) -> ivy.Array:
>>> print(y)
ivy.array([0., 0.762, 0.964])
"""
return ivy.tanh(self._data, out=out)
return ivy.tanh(self._data, complex_mode=complex_mode, out=out)

def trunc(self: ivy.Array, *, out: Optional[ivy.Array] = None) -> ivy.Array:
"""
Expand Down
Loading

0 comments on commit 9080772

Please sign in to comment.