Performance difference of passing np array vs tf tensor into tf.train.FloatList
Possibly duplicate of https://github.com/tensorflow/tensorflow/issues/37580 (closed due to inactivity) @SuryanarayanaY I was able to replicate the issue on colab, please find the [gist](https://colab.research.google.com/gist/sushreebarsa/9b5c90b9ec2eeaa20c04883f15376123/floatlist_np_vs_tf.ipynb#scrollTo=17nKROKLTO3A) here. Thank you! Thanks @kralka, I think what happens is that the construction of the proto message iterates over the entire array.

This iteration is a lot slower in TF than NumPy because the indexing method in TF is [pretty complicated](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/array_ops.py#L979). We would like to improve the performance but it's not a priority right now.

It seems you already have a workaround for the original example. However if slow indexing is causing you trouble, please feel free to file a separate bug to discuss it. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61671">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61671">No</a>

### Issue type

Performance

### Have you reproduced the bug with TensorFlow Nightly?

Yes

### Source

binary

### TensorFlow version

2.13.0

### Custom code

Yes

### OS platform and distribution

docker tensorflow/tensorflow:latest-gpu and Ubuntu

### Mobile device

_No response_

### Python version

3.8.10

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

CUDA Version: 12.0 NVIDIA_SMI 525.125.06

### GPU model and memory

RTX4090

### Current behavior?

Processing numpy array is much faster than processing the same tensor. This is likely connected to https://github.com/tensorflow/tensorflow/issues/30372 (they also serialize TF tensors). Happy to submit a workaround (conversion from tensor to np array). Both CPU and GPU are affected.

### Standalone code to reproduce the issue

```shell
"""Easily reproducible in Google Colab:
https://colab.research.google.com/drive/1gzI7kYRICSepX7OpC715zYj5_0qwrbPx
"""

import numpy as np
import tensorflow as tf
import timeit


np_val = np.random.random(size=(10_000))
tf_val = tf.constant(np_val)
  
print(timeit.timeit(lambda: tf.train.FloatList(value=np_val), number=10))
print(timeit.timeit(lambda: tf.train.FloatList(value=tf_val), number=10))
print(timeit.timeit(lambda: tf.train.FloatList(value=tf_val.numpy()), number=10))
```


### Relevant log output

```shell
0.02872585691511631
25.905678499955684
0.02939283801242709
```
