aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/kernels/range_sampler.cc
diff options
context:
space:
mode:
authorGravatar Vijay Vasudevan <vrv@google.com>2016-06-16 12:23:21 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-06-16 13:33:36 -0700
commit78fc3239d7b53f3150e809f61cc896be57c3db4a (patch)
treed66835c756d7ce9efc9bfeca4f2b263b7334d06c /tensorflow/core/kernels/range_sampler.cc
parent7c9cf4744932bec2e2eee6692c8564813c796575 (diff)
Change ownership of file within InputBuffer to not own the file.
Change callers to manually delete the file. Having InputBuffer own the file makes it difficult to use this low level primitive inside of other libraries that do not own the file (e.g., RecordReader). So we change this implementation to never own its file and rely on the callers to manage lifetime. Change: 125095051
Diffstat (limited to 'tensorflow/core/kernels/range_sampler.cc')
-rw-r--r--tensorflow/core/kernels/range_sampler.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/tensorflow/core/kernels/range_sampler.cc b/tensorflow/core/kernels/range_sampler.cc
index 2fdfa035ab..c2a7c14777 100644
--- a/tensorflow/core/kernels/range_sampler.cc
+++ b/tensorflow/core/kernels/range_sampler.cc
@@ -279,6 +279,8 @@ Status FixedUnigramSampler::LoadFromFile(Env* env, const string& vocab_file,
float distortion) {
RandomAccessFile* file;
TF_RETURN_IF_ERROR(env->NewRandomAccessFile(vocab_file, &file));
+ std::unique_ptr<RandomAccessFile> deleter(file);
+
io::InputBuffer in(file, 262144 /*bytes*/);
string line;
int32 word_id = weights_.size();