1 /** 2 * Copyright 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_IR_DATASETOPS_SOURCE_SPEECH_COMMANDS_NODE_H_ 17 #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_SOURCE_SPEECH_COMMANDS_NODE_H_ 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 #include "minddata/dataset/engine/ir/datasetops/dataset_node.h" 24 25 namespace mindspore { 26 namespace dataset { 27 class SpeechCommandsNode : public MappableSourceNode { 28 public: 29 /// \brief Constructor. 30 SpeechCommandsNode(const std::string &dataset_dir, const std::string &usage, std::shared_ptr<SamplerObj> sampler, 31 std::shared_ptr<DatasetCache> cache); 32 33 /// \brief Destructor. 34 ~SpeechCommandsNode() override = default; 35 36 /// \brief Node name getter. 37 /// \return Name of the current node. Name()38 std::string Name() const override { return kSpeechCommandsNode; } 39 40 /// \brief Print the description. 41 /// \param[out] 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 Get the shard id of node. 58 /// \param[in] shard_id The shard id. 59 /// \return Status Status::OK() if get shard id successfully. 60 Status GetShardId(int32_t *shard_id) override; 61 62 /// \brief Base-class override for GetDatasetSize. 63 /// \param[in] size_getter Shared pointer to DatasetSizeGetter. 64 /// \param[in] estimate This is only supported by some of the ops and it's used to speed up the process of getting 65 /// dataset size at the expense of accuracy. 66 /// \param[out] dataset_size the size of the dataset. 67 /// \return Status of the function. 68 Status GetDatasetSize(const std::shared_ptr<DatasetSizeGetter> &size_getter, bool estimate, 69 int64_t *dataset_size) override; 70 71 /// \brief Getter functions. DatasetDir()72 const std::string &DatasetDir() const { return dataset_dir_; } 73 74 /// \brief Getter functions. Usage()75 const std::string &Usage() const { return usage_; } 76 77 /// \brief Get the arguments of node. 78 /// \param[out] out_json JSON string of all attributes. 79 /// \return Status of the function. 80 Status to_json(nlohmann::json *out_json) override; 81 82 /// \brief Sampler getter. 83 /// \return SamplerObj of the current node. Sampler()84 std::shared_ptr<SamplerObj> Sampler() override { return sampler_; } 85 86 /// \brief Sampler setter. 87 /// \param[in] sampler - Specify sampler. SetSampler(std::shared_ptr<SamplerObj> sampler)88 void SetSampler(std::shared_ptr<SamplerObj> sampler) override { sampler_ = sampler; } 89 90 private: 91 std::string dataset_dir_; 92 std::string usage_; 93 std::shared_ptr<SamplerObj> sampler_; 94 }; // class SpeechCommandsNode 95 } // namespace dataset 96 } // namespace mindspore 97 #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_SOURCE_SPEECH_COMMANDS_NODE_H_ 98