1 | /* Copyright 2021 The TensorFlow Authors. All Rights Reserved. |
---|---|
2 | |
3 | Licensed under the Apache License, Version 2.0 (the "License"); |
4 | you may not use this file except in compliance with the License. |
5 | You may obtain a copy of the License at |
6 | |
7 | http://www.apache.org/licenses/LICENSE-2.0 |
8 | |
9 | Unless required by applicable law or agreed to in writing, software |
10 | distributed under the License is distributed on an "AS IS" BASIS, |
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | See the License for the specific language governing permissions and |
13 | limitations under the License. |
14 | ==============================================================================*/ |
15 | #include "tensorflow/core/data/finalization_utils.h" |
16 | |
17 | #include "tensorflow/core/data/root_dataset.h" |
18 | #include "tensorflow/core/framework/dataset.h" |
19 | #include "tensorflow/core/platform/errors.h" |
20 | #include "tensorflow/core/platform/refcount.h" |
21 | |
22 | namespace tensorflow { |
23 | namespace data { |
24 | |
25 | StatusOr<DatasetBase*> GetFinalizedDataset(OpKernelContext* ctx, |
26 | const DatasetBase* dataset) { |
27 | return dataset->Finalize( |
28 | ctx, [ctx, dataset]() -> StatusOr<core::RefCountPtr<DatasetBase>> { |
29 | core::RefCountPtr<DatasetBase> dataset_ref_ptr; |
30 | DatasetBase* raw_ptr; |
31 | TF_RETURN_IF_ERROR(data::FinalizeDataset(ctx, dataset, &raw_ptr)); |
32 | dataset_ref_ptr.reset(raw_ptr); |
33 | return dataset_ref_ptr; |
34 | }); |
35 | } |
36 | |
37 | } // namespace data |
38 | } // namespace tensorflow |
39 |