• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019-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_PIPELINE_OP_H_
17 #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_DATASETOPS_PIPELINE_OP_H_
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 #include "minddata/dataset/engine/datasetops/dataset_op.h"
23 
24 namespace mindspore {
25 namespace dataset {
26 // forward declare
27 class ExecutionTree;
28 
29 class PipelineOp : public DatasetOp {
30  public:
31   // Constructor
32   // @param op_connector_size - size of the output connector
33   // @return Builder setter method returns reference to the builder.
34   // @param sampler - The sampler for the op
35   explicit PipelineOp(int32_t op_connector_size, std::shared_ptr<SamplerRT> sampler = nullptr);
36 
37   // Destructor
38   ~PipelineOp() = default;
39 
40   // A print method typically used for debugging
41   // @param out - The output stream to write output to
42   // @param show_all - A bool to control if you want to show all info or just a summary
43   void Print(std::ostream &out, bool show_all) const override;
Name()44   std::string Name() const override { return kPipelineOp; }
45 
46   // << Stream output operator overload
47   // @notes This allows you to write the debug print info using stream operators
48   // @param out - reference to the output stream being overloaded
49   // @param po - reference to the PipelineOp to display
50   // @return - the output stream must be returned
51   friend std::ostream &operator<<(std::ostream &out, const PipelineOp &po) {
52     po.Print(out, false);
53     return out;
54   }
55 
56   // Getter
57   // @return The number of workers inside this op.  Pipeline ops only have a single worker.
NumWorkers()58   int32_t NumWorkers() const override { return 1; }
59 
60   // Getter
61   // @return the number of threads consuming from the previous Connector
NumConsumers()62   int32_t NumConsumers() const override { return 1; }
63 
64   // Getter
65   // @return The number of threads that push data to the output connector
NumProducers()66   int32_t NumProducers() const override { return 1; }
67 
68  protected:
69   // *******************************************************************************
70   // I'm predicting there will be common arguments or functionality for pipeline ops,
71   // just not sure yet what those are.  perhaps this intermediate class between
72   // DatasetOp and the actual ops is not needed at all?
73   // For example, if there's no common code for all of the non-parallel ops, then
74   // they can just inherit from DatasetOp directly and we can put this class into the
75   // trash.
76 };
77 }  // namespace dataset
78 }  // namespace mindspore
79 
80 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_DATASETOPS_PIPELINE_OP_H_
81