Skip to content

Commit

Permalink
Merge branch 'master' into exp_
Browse files Browse the repository at this point in the history
  • Loading branch information
ArsalanAli915 committed Aug 31, 2023
2 parents 4fd8e01 + 38338fe commit 7fbc69f
Show file tree
Hide file tree
Showing 41 changed files with 477 additions and 274 deletions.
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 7fbc69f

Please sign in to comment.