Skip to content

Commit

Permalink
fix: replaced gpu device error by a warning in the numpy backend to a…
Browse files Browse the repository at this point in the history
…void breaking the code when a gpu is passed as device, similar to the gradients functions (#27197)
  • Loading branch information
vedpatwardhan authored Nov 2, 2023
1 parent f1519ce commit 84092d3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ivy/functional/backends/numpy/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# global
import os
import time
import logging
import numpy as np
from typing import Union, Optional, Any

Expand All @@ -19,20 +20,18 @@ def dev(x: np.ndarray, /, *, as_native: bool = False) -> Union[ivy.Device, str]:

def as_ivy_dev(device: str, /):
if "gpu" in device:
raise ivy.utils.exceptions.IvyException(
logging.warning(
"Native Numpy does not support GPU placement, consider using Jax instead"
)
elif "cpu" in device:
return ivy.Device("cpu")
return ivy.Device("cpu")


def as_native_dev(device: str, /):
if "gpu" in device:
raise ivy.utils.exceptions.IvyException(
logging.warning(
"Native Numpy does not support GPU placement, consider using Jax instead"
)
elif "cpu" in device:
return "cpu"
return "cpu"


def clear_cached_mem_on_dev(device: str, /):
Expand Down

0 comments on commit 84092d3

Please sign in to comment.