diff options
author | 2018-08-21 11:48:37 -0700 | |
---|---|---|
committer | 2018-08-21 11:59:01 -0700 | |
commit | 9158b1b83a0128fc41bfccd80fe26d8231fe958b (patch) | |
tree | 4bb719d17c4284a5b07814ff24113fa5d0b446f0 /tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc | |
parent | e28f9da84b51acdbf3234688daa4c55647041219 (diff) |
[tf.data] Move captured function instantiation to iterator initialization time.
Previously, a function instantiation error (e.g. in `Dataset.map()`) would lead
to an error in each GetNext() call that attempted to use the function. Moving this
to iterator instantiation time has the benefit that the error will be reported
once when the initialization op is executed, which has a more helpful stack
trace, since it should not be conflated with other potential op failures.
PiperOrigin-RevId: 209633511
Diffstat (limited to 'tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc')
-rw-r--r-- | tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc b/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc index be4132a064..4a388645f2 100644 --- a/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc +++ b/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc @@ -190,7 +190,14 @@ class GroupByReducerDatasetOp : public UnaryDatasetOpKernel { : DatasetIterator<Dataset>(params) {} Status Initialize(IteratorContext* ctx) override { - return dataset()->input_->MakeIterator(ctx, prefix(), &input_impl_); + TF_RETURN_IF_ERROR( + dataset()->input_->MakeIterator(ctx, prefix(), &input_impl_)); + TF_RETURN_IF_ERROR(dataset()->captured_key_func_->Instantiate(ctx)); + TF_RETURN_IF_ERROR(dataset()->captured_init_func_->Instantiate(ctx)); + TF_RETURN_IF_ERROR(dataset()->captured_reduce_func_->Instantiate(ctx)); + TF_RETURN_IF_ERROR( + dataset()->captured_finalize_func_->Instantiate(ctx)); + return Status::OK(); } Status GetNextInternal(IteratorContext* ctx, |