• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021-2023 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 #include "minddata/dataset/engine/datasetops/source/wiki_text_op.h"
18 
19 #include "include/common/debug/common.h"
20 #include "minddata/dataset/core/config_manager.h"
21 #include "minddata/dataset/engine/datasetops/source/io_block.h"
22 #include "minddata/dataset/engine/execution_tree.h"
23 
24 namespace mindspore {
25 namespace dataset {
WikiTextOp(int32_t num_workers,int64_t total_rows,int32_t worker_connector_size,std::unique_ptr<DataSchema> schema,const std::vector<std::string> & file_list,int32_t op_connector_size,bool shuffle_files,int32_t num_devices,int32_t device_id)26 WikiTextOp::WikiTextOp(int32_t num_workers, int64_t total_rows, int32_t worker_connector_size,
27                        std::unique_ptr<DataSchema> schema, const std::vector<std::string> &file_list,
28                        int32_t op_connector_size, bool shuffle_files, int32_t num_devices, int32_t device_id)
29     : TextFileOp(num_workers, total_rows, worker_connector_size, std::move(schema), file_list, op_connector_size,
30                  shuffle_files, num_devices, device_id) {}
31 
32 // A print method typically used for debugging.
Print(std::ostream & out,bool show_all) const33 void WikiTextOp::Print(std::ostream &out, bool show_all) const {
34   if (!show_all) {
35     // Call the super class for displaying any common 1-liner info.
36     ParallelOp::Print(out, show_all);
37     // Then show any custom derived-internal 1-liner info for this op.
38     out << "\n";
39   } else {
40     // Call the super class for displaying any common detailed info.
41     ParallelOp::Print(out, show_all);
42     // Then show any custom derived-internal stuff.
43     out << "\nRow count: " << total_rows_ << "\nDevice id: " << device_id_ << "\nNumber of devices: " << num_devices_
44         << "\nShuffle files: " << ((shuffle_files_) ? "yes" : "no") << "\nWikiText files list:\n";
45     for (size_t i = 0; i < text_files_list_.size(); ++i) {
46       out << " " << text_files_list_[i];
47     }
48     out << "\nData Schema:\n";
49     out << *data_schema_ << "\n\n";
50   }
51 }
52 }  // namespace dataset
53 }  // namespace mindspore
54