xref: /aosp_15_r20/external/tensorflow/tensorflow/core/kernels/data/experimental/sampling_dataset_op.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
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_SAMPLING_DATASET_OP_H_
16 #define TENSORFLOW_CORE_KERNELS_DATA_EXPERIMENTAL_SAMPLING_DATASET_OP_H_
17 
18 #include "tensorflow/core/framework/dataset.h"
19 
20 namespace tensorflow {
21 namespace data {
22 namespace experimental {
23 
24 // See tensorflow/core/api_def/base_api/api_def_SamplingDataset.pbtxt for the
25 // API definition that corresponds to this kernel.
26 class SamplingDatasetOp : public UnaryDatasetOpKernel {
27  public:
28   // Names of op parameters, public so that they can be accessed by test cases.
29   // Make sure that these are kept in sync with the REGISTER_OP call in
30   // tensorflow/core/ops/experimental_dataset_ops.cc
31   static constexpr const char* const kDatasetType = "Sampling";
32   static constexpr const char* const kInputDataset = "input_dataset";
33   static constexpr const char* const kRate = "rate";
34   static constexpr const char* const kSeed = "seed";
35   static constexpr const char* const kSeed2 = "seed2";
36   static constexpr const char* const kOutputTypes = "output_types";
37   static constexpr const char* const kOutputShapes = "output_shapes";
38 
39   explicit SamplingDatasetOp(OpKernelConstruction* ctx);
40 
41  protected:
42   void MakeDataset(OpKernelContext* ctx, DatasetBase* input,
43                    DatasetBase** output) override;
44 
45  private:
46   class Dataset;
47 };
48 
49 }  // namespace experimental
50 }  // namespace data
51 }  // namespace tensorflow
52 
53 #endif  // TENSORFLOW_CORE_KERNELS_DATA_EXPERIMENTAL_SAMPLING_DATASET_OP_H_
54