Skip to content

Commit

Permalink
fix(tensorflow-backend): Fix asarray in tensorflow backend for cases …
Browse files Browse the repository at this point in the history
…when dtype is not provided and the passed in object is also not a tf.Tensor
  • Loading branch information
hmahmood24 committed Jan 18, 2024
1 parent f09e903 commit 2f8548d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ivy/functional/backends/tensorflow/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ def asarray(
with tf.device(device):
if tf.is_tensor(obj):
ret = tf.cast(obj, dtype) if obj.dtype != dtype else obj
elif dtype.is_integer and np.issubdtype(
(obj_np := np.array(obj)).dtype, np.floating
elif (
dtype is not None
and dtype.is_integer
and np.issubdtype(np.array(obj).dtype, np.floating)
):
obj_np = np.array(obj)
ret = tf.convert_to_tensor(obj_np, dtype)
else:
ret = tf.convert_to_tensor(obj, dtype)
Expand Down

0 comments on commit 2f8548d

Please sign in to comment.