aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/kernels/data/scan_dataset_op.cc
diff options
context:
space:
mode:
authorGravatar Rohan Jain <rohanj@google.com>2018-09-18 08:47:31 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-18 08:52:02 -0700
commitb1ff7c2cedcc7d49d430d56655870e6d68a0c8f7 (patch)
tree793efab77e86c90a0d2d152e4219722423b1933f /tensorflow/core/kernels/data/scan_dataset_op.cc
parent18b47f08b13c628ef87d9a99f7fde743baca5300 (diff)
Creating an InstantiatedCapturedFunction that captures the instantiated state of a function to be executed, separating it out from the non instantiated regular state such as function name, captured inputs etc.
This allows us to truly separate Dataset kernel creation from Iterator creation i.e. each time a dataset is created that uses functions, we create only a CapturedFunction whereas we create an InstantiatedCapturedFunction each time a new iterator is created. PiperOrigin-RevId: 213456128
Diffstat (limited to 'tensorflow/core/kernels/data/scan_dataset_op.cc')
-rw-r--r--tensorflow/core/kernels/data/scan_dataset_op.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/tensorflow/core/kernels/data/scan_dataset_op.cc b/tensorflow/core/kernels/data/scan_dataset_op.cc
index dbe31f37b8..d9fdd59bf0 100644
--- a/tensorflow/core/kernels/data/scan_dataset_op.cc
+++ b/tensorflow/core/kernels/data/scan_dataset_op.cc
@@ -144,7 +144,8 @@ class ScanDatasetOp : public UnaryDatasetOpKernel {
Status Initialize(IteratorContext* ctx) override {
TF_RETURN_IF_ERROR(
dataset()->input_->MakeIterator(ctx, prefix(), &input_impl_));
- return dataset()->captured_func_->Instantiate(ctx);
+ return dataset()->captured_func_->Instantiate(
+ ctx, &instantiated_captured_func_);
}
Status GetNextInternal(IteratorContext* ctx,
@@ -169,8 +170,8 @@ class ScanDatasetOp : public UnaryDatasetOpKernel {
state_and_output.reserve(dataset()->state_types_.size() +
output_dtypes().size());
- Status s = dataset()->captured_func_->Run(ctx, std::move(args),
- &state_and_output);
+ Status s = instantiated_captured_func_->Run(ctx, std::move(args),
+ &state_and_output);
if (s.ok()) {
state_.clear();
size_t i = 0;
@@ -247,6 +248,7 @@ class ScanDatasetOp : public UnaryDatasetOpKernel {
mutex mu_;
std::unique_ptr<IteratorBase> input_impl_ GUARDED_BY(mu_);
std::vector<Tensor> state_ GUARDED_BY(mu_);
+ std::unique_ptr<InstantiatedCapturedFunction> instantiated_captured_func_;
};
const DatasetBase* const input_;