From 3805db6b2fbc7dcdef7d50cf05933928455280ac Mon Sep 17 00:00:00 2001 From: Sam-Armstrong Date: Fri, 19 Jul 2024 10:04:18 +0100 Subject: [PATCH] fix: getting device of KerasVariable --- ivy/functional/backends/tensorflow/device.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ivy/functional/backends/tensorflow/device.py b/ivy/functional/backends/tensorflow/device.py index 6805d3013ca4b..6b5748c757d13 100644 --- a/ivy/functional/backends/tensorflow/device.py +++ b/ivy/functional/backends/tensorflow/device.py @@ -28,6 +28,9 @@ def dev( *, as_native: bool = False, ) -> Union[ivy.Device, str]: + if "keras.src.backend.tensorflow.core.Variable" in str(x.__class__): + # Read the underlying tensor of a KerasVariable to get the device + x = x.value if isinstance(x, tf.TensorArray): # Read the underlying tensor being wrapped to get the device. x = x.stack()