• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-2021 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_DATASETOPS_SKIP_OP_H_
17 #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_DATASETOPS_SKIP_OP_H_
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 #include "minddata/dataset/engine/datasetops/pipeline_op.h"
23 #include "minddata/dataset/engine/dataset_iterator.h"
24 
25 namespace mindspore {
26 namespace dataset {
27 class SkipOp : public PipelineOp {
28  public:
29   // Constructor of the SkipOp.
30   // @note The builder class should be used to call it
31   // @param count - The number of skips to do
32   explicit SkipOp(int32_t count);
33 
34   // Destructor
35   ~SkipOp();
36 
37   // A print method typically used for debugging
38   // @param out - The output stream to write output to
39   // @param show_all - A bool to control if you want to show all info or just a summary
40   void Print(std::ostream &out, bool show_all) const override;
41 
42   // Class functor operator () override.
43   // All dataset ops operate by launching a thread (see ExecutionTree). This class functor will
44   // provide the master loop that drives the logic for performing the work
45   // @return Status The status code returned
46   Status operator()() override;
47 
48   // Op name getter
49   // @return Name of the current Op
Name()50   std::string Name() const override { return kSkipOp; }
51   Status GetNextRow(TensorRow *row, int32_t worker_id, bool retry_if_eoe) override;
52   int32_t NumConsumers() const override;
53   int32_t NumProducers() const override;
54 
55  private:
56   int32_t max_skips_;   // The number of skips that the user requested
57   int32_t skip_count_;  // A counter for the current number of executed skips
58 
59   std::unique_ptr<ChildIterator> child_iterator_;  // An iterator for fetching.
60 };
61 }  // namespace dataset
62 }  // namespace mindspore
63 
64 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_DATASETOPS_SKIP_OP_H_
65