float_val in a Const node TensorProto is replicated to fill
shape [2^30], forcing TensorFlow to allocate 4,294 MB from a 62-byte file.1import tensorflow as tf
2import resource
3# Limit to 512 MB to safely observe the OOM
4resource.setrlimit(resource.RLIMIT_AS, (512*1024*1024, 512*1024*1024))
5try:
6 tf.saved_model.load('.') # Will attempt 4 GB allocation, OOM
7except MemoryError:
8 print("OOM confirmed")tensorflow/core/kernels/constant_op.cc:83 calls Tensor::FromProto() which
broadcasts float_val[0] to fill all N elements. No size limit on N.