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_EXPERIMENTAL_MAP_AND_BATCH_DATASET_OP_H_ 16 #define TENSORFLOW_CORE_KERNELS_DATA_EXPERIMENTAL_MAP_AND_BATCH_DATASET_OP_H_ 17 18 #include "tensorflow/core/data/captured_function.h" 19 #include "tensorflow/core/framework/dataset.h" 20 21 namespace tensorflow { 22 namespace data { 23 namespace experimental { 24 25 // See documentation in ../../ops/experimental_dataset_ops.cc for a high-level 26 // description of the following op. 27 28 class MapAndBatchDatasetOp : public UnaryDatasetOpKernel { 29 public: 30 static constexpr const char* const kDatasetType = "MapAndBatch"; 31 static constexpr const char* const kInputDataset = "input_dataset"; 32 static constexpr const char* const kOtherArguments = "other_arguments"; 33 static constexpr const char* const kBatchSize = "batch_size"; 34 static constexpr const char* const kNumParallelCalls = "num_parallel_calls"; 35 static constexpr const char* const kDropRemainder = "drop_remainder"; 36 static constexpr const char* const kFunc = "f"; 37 static constexpr const char* const kTarguments = "Targuments"; 38 static constexpr const char* const kOutputTypes = "output_types"; 39 static constexpr const char* const kOutputShapes = "output_shapes"; 40 static constexpr const char* const kPreserveCardinality = 41 "preserve_cardinality"; 42 43 explicit MapAndBatchDatasetOp(OpKernelConstruction* ctx); 44 45 protected: 46 void MakeDataset(OpKernelContext* ctx, DatasetBase* input, 47 DatasetBase** output) override; 48 49 private: 50 class Dataset; 51 std::shared_ptr<FunctionMetadata> func_metadata_ = nullptr; 52 DataTypeVector output_types_; 53 std::vector<PartialTensorShape> output_shapes_; 54 bool preserve_cardinality_; 55 }; 56 57 } // namespace experimental 58 } // namespace data 59 } // namespace tensorflow 60 61 #endif // TENSORFLOW_CORE_KERNELS_DATA_EXPERIMENTAL_MAP_AND_BATCH_DATASET_OP_H_ 62