• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 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 
17 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_EPOCH_CTRL_NODE_H_
18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_EPOCH_CTRL_NODE_H_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "minddata/dataset/engine/datasetops/epoch_ctrl_op.h"
25 #include "minddata/dataset/engine/ir/datasetops/dataset_node.h"
26 #include "minddata/dataset/engine/ir/datasetops/repeat_node.h"
27 
28 namespace mindspore {
29 namespace dataset {
30 
31 class EpochCtrlNode : public RepeatNode {
32   // Allow GeneratorNode to access internal members
33   friend class GeneratorNode;
34 
35  public:
36   /// \brief Constructor
EpochCtrlNode(int32_t num_epochs)37   explicit EpochCtrlNode(int32_t num_epochs) : RepeatNode() { repeat_count_ = num_epochs; }
38 
39   /// \brief Constructor
40   EpochCtrlNode(std::shared_ptr<DatasetNode> child, int32_t num_epochs);
41 
42   /// \brief Destructor
43   ~EpochCtrlNode() = default;
44 
45   /// \brief Node name getter
46   /// \return Name of the current node
Name()47   std::string Name() const override { return kEpochCtrlNode; }
48 
49   /// \brief Print the description
50   /// \param out - The output stream to write output to
51   void Print(std::ostream &out) const override;
52 
53   /// \brief Copy the node to a new object
54   /// \return A shared pointer to the new copy
55   std::shared_ptr<DatasetNode> Copy() override;
56 
57   /// \brief a base class override function to create the required runtime dataset op objects for this class
58   /// \param node_ops - A vector containing shared pointer to the Dataset Ops that this object will create
59   /// \return Status Status::OK() if build successfully
60   Status Build(std::vector<std::shared_ptr<DatasetOp>> *const node_ops) override;
61 
62   /// \brief Parameters validation
63   /// \return Status Status::OK() if all the parameters are valid
64   Status ValidateParams() override;
65 
66   /// \brief Base-class override for accepting IRNodePass visitor
67   /// \param[in] p The node to visit
68   /// \param[out] modified Indicator if the node was modified
69   /// \return Status of the node visit
70   Status Accept(IRNodePass *const p, bool *const modified) override;
71 
72   /// \brief Base-class override for accepting IRNodePass visitor
73   /// \param[in] p The node to visit
74   /// \param[out] modified Indicator if the node was modified
75   /// \return Status of the node visit
76   Status AcceptAfter(IRNodePass *const p, bool *const modified) override;
77 };
78 
79 }  // namespace dataset
80 }  // namespace mindspore
81 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_EPOCH_CTRL_NODE_H_
82