Simplify _to_tensor()
@@ -279,10 +279,7 @@ def _to_tensor(x, dtype):
# Returns
A tensor.
"""
- x = tf.convert_to_tensor(x)
- if x.dtype != dtype:
- x = tf.cast(x, dtype)
- return x
+ return tf.convert_to_tensor(x, dtype=dtype)
def is_sparse(tensor):
