• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2019 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 #ifndef TENSORFLOW_CORE_KERNELS_DATA_DATASET_OPS_H_
16 #define TENSORFLOW_CORE_KERNELS_DATA_DATASET_OPS_H_
17 
18 #include "tensorflow/core/platform/platform.h"
19 
20 // On mobile we do not provide this functionality because not all of its
21 // dependencies are available there.
22 #if !defined(IS_MOBILE_PLATFORM)
23 #include "tensorflow/core/framework/dataset.h"
24 #include "tensorflow/core/framework/op_kernel.h"
25 
26 namespace tensorflow {
27 namespace data {
28 
29 class DatasetToGraphOp : public OpKernel {
30  public:
31   static constexpr const char* const kAllowStateful = "allow_stateful";
32   static constexpr const char* const kStripDeviceAssignment =
33       "strip_device_assignment";
34   static constexpr const char* const kExternalStatePolicy =
35       "external_state_policy";
36   static constexpr const char* const kDatasetToGraph = "DatasetToGraph";
37 
38   explicit DatasetToGraphOp(OpKernelConstruction* ctx);
39 
40   void Compute(OpKernelContext* ctx) override;
41 
42  private:
43   const int op_version_;
44   SerializationContext::ExternalStatePolicy external_state_policy_ =
45       SerializationContext::ExternalStatePolicy::kWarn;
46   bool strip_device_assignment_ = false;
47 };
48 
49 class DatasetCardinalityOp : public OpKernel {
50  public:
DatasetCardinalityOp(OpKernelConstruction * ctx)51   explicit DatasetCardinalityOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}
52 
53   void Compute(OpKernelContext* ctx) override;
54 };
55 
56 class DatasetFromGraphOp : public OpKernel {
57  public:
58   static constexpr const char* const kGraphDef = "graph_def";
59   static constexpr const char* const kHandle = "handle";
60 
DatasetFromGraphOp(OpKernelConstruction * ctx)61   explicit DatasetFromGraphOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}
62 
63   void Compute(OpKernelContext* ctx) override;
64 };
65 
66 }  // namespace data
67 }  // namespace tensorflow
68 #endif  // !IS_MOBILE_PLATFORM
69 
70 #endif  // TENSORFLOW_CORE_KERNELS_DATA_DATASET_OPS_H_
71