Skip to content

Commit f68cbf1

Browse files
mrrytensorflower-gardener
authored andcommitted
Use numpy.asarray() instead of numpy.array() when converting feeds.
This reduces the number of unnecessary NumPy array allocations when feeding values into a TensorFlow session, and can reduce heap fragmentation. Fixes tensorflow#2942 (as far as possible). Note that we recommend that you use tcmalloc when running TensorFlow, as it is less susceptible to heap fragmentation with mmany large objects. Change: 125407787
1 parent b675e4b commit f68cbf1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tensorflow/python/client/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ def _feed_fn(feed, feed_val):
616616
' Try explicitly setting the type of the feed tensor'
617617
' to a larger type (e.g. int64).')
618618

619-
np_val = np.array(subfeed_val, dtype=subfeed_dtype)
619+
np_val = np.asarray(subfeed_val, dtype=subfeed_dtype)
620620

621621
if not subfeed_t.get_shape().is_compatible_with(np_val.shape):
622622
raise ValueError(

0 commit comments

Comments
 (0)