Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushal07wick authored Mar 31, 2023
2 parents 07649d5 + 11422d0 commit 6f97872
Show file tree
Hide file tree
Showing 58 changed files with 452 additions and 299 deletions.
7 changes: 4 additions & 3 deletions docker/multicuda_framework_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ def install_pkg(path, pkg, base="fw/"):
f"pip3 install {pkg} --default-timeout=100 --no-cache-dir", shell=True
)

if __name__=="__main__":
arg_lis=sys.argv
directory_generator(arg_lis[1:],"")

if __name__ == "__main__":
arg_lis = sys.argv
directory_generator(arg_lis[1:], "")


# torch_req = ["torch/1.13.1"]
Expand Down
26 changes: 13 additions & 13 deletions docker/multiversion_framework_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,41 @@ def install_pkg(path, pkg, base="fw/"):
)
elif pkg.split("==")[0] == "tensorflow":
subprocess.run(
f"pip3 install tensorflow-cpu=={pkg.split('==')[1]} --default-timeout=100 --target={path} --no-cache-dir", shell=True
f"pip3 install tensorflow-cpu=={pkg.split('==')[1]} --default-timeout=100 --target={path} --no-cache-dir",
shell=True,
)
else:
subprocess.run(
f"pip3 install {pkg} --default-timeout=100 --target={path} --no-cache-dir", shell=True
f"pip3 install {pkg} --default-timeout=100 --target={path} --no-cache-dir",
shell=True,
)


if __name__=="__main__":
arg_lis=sys.argv
if __name__ == "__main__":
arg_lis = sys.argv

if 'backend' in arg_lis:
if "backend" in arg_lis:
for i in arg_lis[2:]:
if i.split('/')[0]=='torch':
if i.split("/")[0] == "torch":
subprocess.run(
f"pip3 install torch=={i.split('/')[1]} --default-timeout=100 --extra-index-url https://download.pytorch.org/whl/cpu --no-cache-dir",
shell=True,
)
elif i.split('/')[0]=='tensorflow':
elif i.split("/")[0] == "tensorflow":
print(i, "heere")
subprocess.run(
f"pip3 install tensorflow-cpu=={i.split('/')[1]} --default-timeout=100 --no-cache-dir",
shell=True
shell=True,
)
elif i.split('/')[0]=='jaxlib':
elif i.split("/")[0] == "jaxlib":
subprocess.run(
f"pip3 install {i} --default-timeout=100 -f https://storage.googleapis.com/jax-releases/jax_releases.html --no-cache-dir",
shell=True,
)
else:
subprocess.run(
f"pip3 install {i.split('/')[0]}=={i.split('/')[1]} --default-timeout=100 --no-cache-dir", shell=True
f"pip3 install {i.split('/')[0]}=={i.split('/')[1]} --default-timeout=100 --no-cache-dir",
shell=True,
)
try:
import tensorflow
Expand Down Expand Up @@ -87,6 +90,3 @@ def install_pkg(path, pkg, base="fw/"):
)
else:
directory_generator(arg_lis[1:])



36 changes: 26 additions & 10 deletions docs/overview/contributing/setting_up.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,22 +185,26 @@ Windows
#. Install `WSL 2 <https://docs.microsoft.com/en-us/windows/wsl/install>`_.
For most, it will only require running the command :code:`wsl --install` in powershell admin mode.
Visit the link if it doesn't.
#. Get the latest Docker Image for Ivy by:

a. Running Docker desktop.
b. Opening cmd, and running the command: :code:`docker pull unifyai/ivy:latest`

#. Install `Pycharm Professional Version <https://www.jetbrains.com/pycharm/>`_, make sure to only install the Professional version of PyCharm, not the Community version.
#. Open pycharm with your cloned Ivy repository.
Add the remote python interpreter by:

a. Going to the settings -> Build, Execution, Deployment -> Docker
Click the "+" on top left and it should add a docker connection.
b. Going to settings -> project -> Python Interpreter
c. Clicking add interpreter (currently by clicking the ⚙ icon by the right side) which should open a new window.
d. Choosing "Docker" from the left panel.
Type python3 (with the number) in python interpreter path and press ok.
e. Opening "Edit Run/Debug configurations" dialog -> "Edit Configurations..." and making sure that "Working directory" is empty in case of getting the "Can't run process: the working directory '\ivy' is invalid, it needs to be an absolute path" error.
c. Clicking add interpreter (currently by clicking the ⚙ icon by the right side) which should open a new small drop down menu. Select "On Docker...".A window will open which will have three steps.
#. It will ask to create a new Docker target, at this step you have to select the following:

a. Docker image -> Docker
b. Image -> Pull
c. Image tag -> unifyai/ivy:latest
d. Select "Next"
#. The image will start pulling. It will take a respectible amount of time to complete. Once you see "Introspection Completed" message, select "Next".
#. Another window will appear, at this step select the following:

a. In the left panel select "System Interpreter".
b. For Interpreter, select the default option which will be "/usr/bin/python3" the select "Create".
#. Opening "Edit Run/Debug configurations" dialog -> "Edit Configurations..." and making sure that "Working directory" is empty in case of getting the "Can't run process: the working directory '\ivy' is invalid, it needs to be an absolute path" error.

Once these steps are finished, your interpreter should be set up correctly!
If Docker's latest version causes error, try using an earlier version by visiting `Docker release note <https://docs.docker.com/desktop/release-notes/>`_.
Expand Down Expand Up @@ -316,8 +320,20 @@ Ubuntu
d. Choosing "Docker" from the left panel.
Type python3 (with the number) in python interpreter path and press ok.

For questions, please reach out on `discord`_ in the `docker channel`_!
**Docker Connection not Successfull**

This is a common error which you might face. If you are not successfully able to connect docker with Pycharm(point 4a) and your docker is also running, the issue is that you are not able to use your docker socket. So, executing the below two commands should solve this.

.. code-block:: none
sudo chmod a+rwx /var/run/docker.sock
.. code-block:: none
sudo chmod a+rwx /var/run/docker.pid
For questions, please reach out on `discord`_ in the `docker channel`_!

**Video**

Expand Down
8 changes: 2 additions & 6 deletions docs/partial_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
# Only generate docs for index.rst
# That resolved a bug of autosummary generating docs for code-block examples
# of autosummary
autosummary_generate = ['index.rst']
autosummary_generate = ["index.rst"]

skippable_method_attributes = [
{
"__qualname__": "_wrap_function.<locals>.new_function"
}
]
skippable_method_attributes = [{"__qualname__": "_wrap_function.<locals>.new_function"}]
4 changes: 3 additions & 1 deletion ivy/data_classes/container/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,9 @@ def cont_map(
"""
return_dict = self if inplace else dict()
for key, value in self.items():
this_key_chain = key if key_chain == "" else (key_chain + "/" + key)
this_key_chain = (
key if key_chain == "" else (str(key_chain) + "/" + str(key))
)
if isinstance(value, ivy.Container):
ret = value.cont_map(
func,
Expand Down
6 changes: 2 additions & 4 deletions ivy/functional/backends/jax/experimental/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,7 @@ def interpolate(
"area",
"nearest_exact",
"tf_area",
"bicubic_tensorflow"
"bicubic",
"bicubic_tensorflow" "bicubic",
"mitchellcubic",
"lanczos3",
"lanczos5",
Expand All @@ -526,8 +525,7 @@ def interpolate(
mode = (
"nearest"
if mode == "nearest-exact"
else "bicubic"
"bicubic"
else "bicubic" "bicubic"
if mode == "bicubic_tensorflow"
else mode
)
Expand Down
2 changes: 1 addition & 1 deletion ivy/functional/backends/jax/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,4 +424,4 @@ def vmap(
func = ivy.output_to_native_arrays(func)
return ivy.inputs_to_native_arrays(
jax.vmap(func, in_axes=in_axes, out_axes=out_axes)
)
)
9 changes: 5 additions & 4 deletions ivy/functional/backends/jax/searching.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ def where(
# ----- #


def argwhere(x: JaxArray,
/,
*,
out: Optional[JaxArray] = None,
def argwhere(
x: JaxArray,
/,
*,
out: Optional[JaxArray] = None,
) -> JaxArray:
return jnp.argwhere(x)
9 changes: 5 additions & 4 deletions ivy/functional/backends/numpy/searching.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ def where(
# ----- #


def argwhere(x: np.ndarray,
/,
*,
out: Optional[np.ndarray] = None,
def argwhere(
x: np.ndarray,
/,
*,
out: Optional[np.ndarray] = None,
) -> np.ndarray:
return np.argwhere(x)
2 changes: 1 addition & 1 deletion ivy/functional/backends/paddle/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def asarray(
if dtype is None:
dtype = ivy.default_dtype(item=obj)
with ivy.ArrayMode(False):
return ivy.squeeze(paddle.to_tensor(obj,dtype=dtype),0)
return ivy.squeeze(paddle.to_tensor(obj, dtype=dtype), 0)

else:
dtype = ivy.as_native_dtype((ivy.default_dtype(dtype=dtype, item=obj)))
Expand Down
4 changes: 1 addition & 3 deletions ivy/functional/backends/paddle/data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ def broadcast_to(
paddle.uint8,
paddle.float16,
]:
return paddle.broadcast_to(x.cast("float32"), shape).cast(
x.dtype
)
return paddle.broadcast_to(x.cast("float32"), shape).cast(x.dtype)
elif x.dtype in [paddle.complex64, paddle.complex128]:
x_real = paddle.broadcast_to(x.real(), shape)
x_imag = paddle.broadcast_to(x.imag(), shape)
Expand Down
36 changes: 22 additions & 14 deletions ivy/functional/backends/paddle/experimental/elementwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ def float_power(

@with_unsupported_device_and_dtypes(
{"2.4.2 and below": {"cpu": ("uint16", "bfloat16")}}, backend_version
)
)
def exp2(
x: Union[paddle.Tensor, float, list, tuple],
/,
*,
out: Optional[paddle.Tensor] = None,
) -> paddle.Tensor:
with ivy.ArrayMode(False):
return ivy.pow(2,x)
return ivy.pow(2, x)


@with_unsupported_device_and_dtypes(
Expand All @@ -107,9 +107,9 @@ def copysign(
out: Optional[paddle.Tensor] = None,
) -> paddle.Tensor:
with ivy.ArrayMode(False):
x2 = ivy.where(ivy.equal(x2, 0),ivy.divide(1, x2),x2)
x2 = ivy.where(ivy.equal(x2, 0), ivy.divide(1, x2), x2)
signs = ivy.sign(x2)
return ivy.multiply(ivy.abs(x1),signs)
return ivy.multiply(ivy.abs(x1), signs)


def count_nonzero(
Expand Down Expand Up @@ -214,24 +214,32 @@ def nan_to_num(
neginf: Optional[Union[float, int]] = None,
out: Optional[paddle.Tensor] = None,
) -> paddle.Tensor:
with ivy.ArrayMode(False):
with ivy.ArrayMode(False):
if ivy.is_int_dtype(x):
if posinf==None:
if posinf == None:
posinf = ivy.iinfo(x).max
if neginf==None:
neginf= ivy.iinfo(x).min
if neginf == None:
neginf = ivy.iinfo(x).min
elif ivy.is_float_dtype(x) or ivy.is_complex_dtype(x):
if posinf==None:
if posinf == None:
posinf = ivy.finfo(x).max
if neginf==None:
neginf=ivy.finfo(x).min
if neginf == None:
neginf = ivy.finfo(x).min
ret = ivy.where(ivy.isnan(x), paddle.to_tensor(nan, dtype=x.dtype), x)
ret = ivy.where(ivy.logical_and(ivy.isinf(ret), ret > 0), paddle.to_tensor(posinf, dtype=x.dtype), ret)
ret = ivy.where(ivy.logical_and(ivy.isinf(ret), ret < 0), paddle.to_tensor(neginf, dtype=x.dtype), ret)
ret = ivy.where(
ivy.logical_and(ivy.isinf(ret), ret > 0),
paddle.to_tensor(posinf, dtype=x.dtype),
ret,
)
ret = ivy.where(
ivy.logical_and(ivy.isinf(ret), ret < 0),
paddle.to_tensor(neginf, dtype=x.dtype),
ret,
)
if copy:
return ret.clone()
else:
x= ret
x = ret
return x


Expand Down
4 changes: 1 addition & 3 deletions ivy/functional/backends/paddle/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ def squeeze(
"tried to squeeze a zero-dimensional input by axis {}".format(axis)
)
if x.dtype in [paddle.int16, paddle.float16]:
return paddle.squeeze(x.cast("float32"), axis=axis).cast(
x.dtype
)
return paddle.squeeze(x.cast("float32"), axis=axis).cast(x.dtype)
return paddle.squeeze(x, axis=axis)


Expand Down
4 changes: 1 addition & 3 deletions ivy/functional/backends/paddle/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,5 @@ def shuffle(
shuffled_real = paddle.index_select(x.real(), indices)
shuffled_imag = paddle.index_select(x.imag(), indices)
return shuffled_real + 1j * shuffled_imag
return paddle.index_select(x.cast("float32"), indices).cast(
x.dtype
)
return paddle.index_select(x.cast("float32"), indices).cast(x.dtype)
return paddle.index_select(x, indices)
9 changes: 5 additions & 4 deletions ivy/functional/backends/torch/searching.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ def where(
# ----- #


def argwhere(x: torch.Tensor,
/,
*,
out: Optional[torch.Tensor] = None,
def argwhere(
x: torch.Tensor,
/,
*,
out: Optional[torch.Tensor] = None,
) -> torch.Tensor:
return torch.argwhere(x)
2 changes: 1 addition & 1 deletion ivy/functional/frontends/jax/_src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flake8: noqa
from . import numpy
from . import array
from . import api
from . import api
19 changes: 10 additions & 9 deletions ivy/functional/frontends/jax/_src/api.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import ivy
from ivy.functional.frontends.jax.func_wrapper import to_ivy_arrays_and_back, outputs_to_native_arrays
def vmap(fun,
in_axes=0,
out_axes=0,
axis_name=None,
axis_size=None,
spmd_axis_name=None
):
from ivy.functional.frontends.jax.func_wrapper import (
to_ivy_arrays_and_back,
outputs_to_native_arrays,
)


def vmap(
fun, in_axes=0, out_axes=0, axis_name=None, axis_size=None, spmd_axis_name=None
):
fun = outputs_to_native_arrays(fun)
return to_ivy_arrays_and_back(ivy.vmap(fun, in_axes=in_axes, out_axes=out_axes))
return to_ivy_arrays_and_back(ivy.vmap(fun, in_axes=in_axes, out_axes=out_axes))
Loading

0 comments on commit 6f97872

Please sign in to comment.