You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Byte order is not checked when creating a TensorProto with tf.make_tensor_proto() from a numpy.ndarray with non-native byte order. This leads to wrong tensor data.
I would expect that byte order is checked and swapped if necessary before assigning to tensor_proto.tensor_content in [python/framework/tensor_util.py](https://github.com/tensorflow/tensorflow/blob/v2.8.0/tensorflow/python/framework/tensor_util.py#L523)
Standalone code to reproduce the issue
x = np.ones(shape=(1, 2), dtype=np.float32)
x_bswap = x.astype('>f4') # assuming native byte order is little endian
y = tf.make_ndarray(tf.make_tensor_proto(x))
y_bswap = tf.make_ndarray(tf.make_tensor_proto(x_bswap))
print(y)
print(y_bswap)
assert np.array_equal(x, y)
assert np.array_equal(x, y_bswap)
Click to expand!
Issue Type
Bug
Source
binary
Tensorflow Version
tf 2.8
Custom Code
No
OS Platform and Distribution
No response
Mobile device
No response
Python version
No response
Bazel version
No response
GCC/Compiler version
No response
CUDA/cuDNN version
No response
GPU model and memory
No response
Current Behaviour?
Standalone code to reproduce the issue
Relevant log output