• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_SOURCE_DIV2K_NODE_H_
18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_SOURCE_DIV2K_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 
29 class DIV2KNode : public MappableSourceNode {
30  public:
31   /// \brief Constructor.
32   DIV2KNode(const std::string &dataset_dir, const std::string &usage, const std::string &downgrade, int32_t scale,
33             bool decode, std::shared_ptr<SamplerObj> sampler, std::shared_ptr<DatasetCache> cache);
34 
35   /// \brief Destructor.
36   ~DIV2KNode() = default;
37 
38   /// \brief Node name getter.
39   /// \return Name of the current node.
Name()40   std::string Name() const override { return kDIV2KNode; }
41 
42   /// \brief Print the description.
43   /// \param[out] out - The output stream to write output to.
44   void Print(std::ostream &out) const override;
45 
46   /// \brief Copy the node to a new object.
47   /// \return A shared pointer to the new copy.
48   std::shared_ptr<DatasetNode> Copy() override;
49 
50   /// \brief a base class override function to create the required runtime dataset op objects for this class.
51   /// \param[out] node_ops - A vector containing shared pointer to the Dataset Ops that this object will create.
52   /// \return Status Status::OK() if build successfully.
53   Status Build(std::vector<std::shared_ptr<DatasetOp>> *const node_ops) override;
54 
55   /// \brief Parameters validation.
56   /// \return Status Status::OK() if all the parameters are valid.
57   Status ValidateParams() override;
58 
59   /// \brief Get the shard id of node.
60   /// \return Status Status::OK() if get shard id successfully.
61   Status GetShardId(int32_t *shard_id) override;
62 
63   /// \brief Base-class override for GetDatasetSize.
64   /// \param[in] size_getter Shared pointer to DatasetSizeGetter.
65   /// \param[in] estimate This is only supported by some of the ops and it's used to speed up the process of getting
66   ///     dataset size at the expense of accuracy.
67   /// \param[out] dataset_size the size of the dataset.
68   /// \return Status of the function.
69   Status GetDatasetSize(const std::shared_ptr<DatasetSizeGetter> &size_getter, bool estimate,
70                         int64_t *dataset_size) override;
71 
72   /// \brief Getter functions.
DatasetDir()73   const std::string &DatasetDir() const { return dataset_dir_; }
74 
75   /// \brief Getter functions.
Usage()76   const std::string &Usage() const { return usage_; }
77 
78   /// \brief Getter functions.
Scale()79   const int32_t &Scale() const { return scale_; }
80 
81   /// \brief Getter functions.
Downgrade()82   const std::string &Downgrade() const { return downgrade_; }
83 
84   /// \brief Getter functions
Decode()85   bool Decode() const { return decode_; }
86 
87   /// \brief Get the arguments of node.
88   /// \param[out] out_json JSON string of all attributes.
89   /// \return Status of the function.
90   Status to_json(nlohmann::json *out_json) override;
91 
92   /// \brief Sampler getter.
93   /// \return SamplerObj of the current node.
Sampler()94   std::shared_ptr<SamplerObj> Sampler() override { return sampler_; }
95 
96   /// \brief Sampler setter.
SetSampler(std::shared_ptr<SamplerObj> sampler)97   void SetSampler(std::shared_ptr<SamplerObj> sampler) override { sampler_ = sampler; }
98 
99  private:
100   std::string dataset_dir_;
101   std::string usage_;
102   int32_t scale_;
103   std::string downgrade_;
104   bool decode_;
105   std::shared_ptr<SamplerObj> sampler_;
106 };
107 }  // namespace dataset
108 }  // namespace mindspore
109 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_SOURCE_DIV2K_NODE_H_
110