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_ZIP_NODE_H_ 18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_ZIP_NODE_H_ 19 20 #include <memory> 21 #include <string> 22 #include <vector> 23 24 #include "minddata/dataset/engine/ir/datasetops/dataset_node.h" 25 26 namespace mindspore { 27 namespace dataset { 28 class ZipNode : public DatasetNode { 29 public: 30 /// \brief Constructor 31 explicit ZipNode(const std::vector<std::shared_ptr<DatasetNode>> &datasets); 32 33 /// \brief Destructor 34 ~ZipNode() override = default; 35 36 /// \brief Node name getter 37 /// \return Name of the current node Name()38 std::string Name() const override { return kZipNode; } 39 40 /// \brief Print the description 41 /// \param out - The output stream to write output to 42 void Print(std::ostream &out) const override; 43 44 /// \brief Copy the node to a new object 45 /// \return A shared pointer to the new copy 46 std::shared_ptr<DatasetNode> Copy() override; 47 48 /// \brief a base class override function to create the required runtime dataset op objects for this class 49 /// \param node_ops - A vector containing shared pointer to the Dataset Ops that this object will create 50 /// \return Status Status::OK() if build successfully 51 Status Build(std::vector<std::shared_ptr<DatasetOp>> *const node_ops) override; 52 53 /// \brief Parameters validation 54 /// \return Status Status::OK() if all the parameters are valid 55 Status ValidateParams() override; 56 57 /// \brief Base-class override for GetDatasetSize 58 /// \param[in] size_getter Shared pointer to DatasetSizeGetter 59 /// \param[in] estimate This is only supported by some of the ops and it's used to speed up the process of getting 60 /// dataset size at the expense of accuracy. 61 /// \param[out] dataset_size the size of the dataset 62 /// \return Status of the function 63 Status GetDatasetSize(const std::shared_ptr<DatasetSizeGetter> &size_getter, bool estimate, 64 int64_t *dataset_size) 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 /// \brief Function to read dataset in json 79 /// \param[in] datasets A vector of datasets for Zip input 80 /// \param[out] result Deserialized dataset 81 /// \return Status The status code returned 82 static Status from_json(std::vector<std::shared_ptr<DatasetNode>> datasets, std::shared_ptr<DatasetNode> *result); 83 84 private: 85 std::vector<std::shared_ptr<DatasetNode>> datasets_; 86 }; 87 } // namespace dataset 88 } // namespace mindspore 89 #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_ZIP_NODE_H_ 90