aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/framework/tensor_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/python/framework/tensor_util.py')
-rw-r--r--tensorflow/python/framework/tensor_util.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tensorflow/python/framework/tensor_util.py b/tensorflow/python/framework/tensor_util.py
index 13262a0bd8..c2378ac4b2 100644
--- a/tensorflow/python/framework/tensor_util.py
+++ b/tensorflow/python/framework/tensor_util.py
@@ -355,6 +355,10 @@ def make_tensor_proto(values, dtype=None, shape=None, verify_shape=False):
nparray = values.astype(dtype.as_numpy_dtype)
else:
nparray = values
+ elif callable(getattr(values, "__array__", None)):
+ # If a class has the __array__ method, then it is possible to convert
+ # to numpy array.
+ nparray = np.asarray(values, dtype=dtype)
else:
if values is None:
raise ValueError("None values not supported.")