From 2f8548d3c6ead70f0af65a484156ed2454c2bf0d Mon Sep 17 00:00:00 2001 From: Haris Mahmood <70361308+hmahmood24@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:26:53 +0000 Subject: [PATCH] fix(tensorflow-backend): Fix asarray in tensorflow backend for cases when dtype is not provided and the passed in object is also not a tf.Tensor --- ivy/functional/backends/tensorflow/creation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ivy/functional/backends/tensorflow/creation.py b/ivy/functional/backends/tensorflow/creation.py index 4a96058aa5dff..bdcbddf911f89 100644 --- a/ivy/functional/backends/tensorflow/creation.py +++ b/ivy/functional/backends/tensorflow/creation.py @@ -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)