• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-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_INCLUDE_DATASET_CONFIG_H
18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_CONFIG_H
19 
20 #include <cstdint>
21 #include <string>
22 #include <vector>
23 #include "include/api/dual_abi_helper.h"
24 
25 namespace mindspore {
26 namespace dataset {
27 
28 // Config operations for setting and getting the configuration.
29 namespace config {
30 
31 /// \brief A function to set the seed to be used in any random generator. This is used to produce deterministic results.
32 /// \param[in] seed The default seed to be used.
33 bool set_seed(int32_t seed);
34 
35 /// \brief A function to get the seed.
36 /// \return The seed set in the configuration.
37 uint32_t get_seed();
38 
39 /// \brief A function to set the number of rows to be prefetched.
40 /// \param[in] prefetch_size Total number of rows to be prefetched.
41 bool set_prefetch_size(int32_t prefetch_size);
42 
43 /// \brief A function to get the prefetch size in number of rows.
44 /// \return Total number of rows to be prefetched.
45 int32_t get_prefetch_size();
46 
47 /// \brief A function to set the default number of parallel workers.
48 /// \param[in] num_parallel_workers Number of parallel workers to be used as the default for each operation.
49 bool set_num_parallel_workers(int32_t num_parallel_workers);
50 
51 /// \brief A function to get the default number of parallel workers.
52 /// \return Number of parallel workers to be used as the default for each operation.
53 int32_t get_num_parallel_workers();
54 
55 /// \brief A function to set the default interval (in milliseconds) for monitor sampling.
56 /// \param[in] interval Interval (in milliseconds) to be used for performance monitor sampling.
57 bool set_monitor_sampling_interval(int32_t interval);
58 
59 /// \brief A function to get the default interval of performance monitor sampling.
60 /// \return Interval (in milliseconds) for performance monitor sampling.
61 int32_t get_monitor_sampling_interval();
62 
63 /// \brief A function to set the default timeout (in seconds) for DSWaitedCallback. In case of a deadlock, the wait
64 ///    function will exit after the timeout period.
65 /// \param[in] timeout Timeout (in seconds) to be used to end the wait in DSWaitedCallback in case of a deadlock.
66 bool set_callback_timeout(int32_t timeout);
67 
68 /// \brief A function to get the default timeout for DSWaitedCallback. In case of a deadback, the wait function
69 ///    will exit after the timeout period.
70 /// \return The duration in seconds.
71 int32_t get_callback_timeout();
72 
73 /// \brief A function to load the configuration from a file.
74 /// \param[in] file Path of the configuration file to be loaded.
75 /// \note The reason for using this API is that std::string will be constrained by the
76 ///    compiler option '_GLIBCXX_USE_CXX11_ABI' while char is free of this restriction.
77 bool load(const std::vector<char> &file);
78 
79 /// \brief A function to load the configuration from a file.
80 /// \param[in] file Path of the configuration file to be loaded.
load(std::string file)81 inline bool load(std::string file) { return load(StringToChar(file)); }
82 
83 }  // namespace config
84 }  // namespace dataset
85 }  // namespace mindspore
86 
87 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_CONFIG_H
88