You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

config.h 3.6 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_CONFIG_H
  17. #define MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_CONFIG_H
  18. #include <cstdint>
  19. #include <string>
  20. #include <vector>
  21. #include "include/api/dual_abi_helper.h"
  22. namespace mindspore {
  23. namespace dataset {
  24. // Config operations for setting and getting the configuration.
  25. namespace config {
  26. /// \brief Function to set the seed to be used in any random generator. This is used to produce deterministic results.
  27. /// \param[in] seed the default seed to use.
  28. bool set_seed(int32_t seed);
  29. /// \brief Function to get the seed.
  30. /// \return the seed set in the configuration.
  31. uint32_t get_seed();
  32. /// \brief Function to set the number of rows to be prefetched.
  33. /// \param[in] prefetch_size total number of rows to be prefetched.
  34. bool set_prefetch_size(int32_t prefetch_size);
  35. /// \brief Function to get the prefetch size in number of rows.
  36. /// \return total number of rows to be prefetched.
  37. int32_t get_prefetch_size();
  38. /// \brief Function to set the default number of parallel workers.
  39. /// \param[in] num_parallel_workers number of parallel workers to be used as a default for each operation.
  40. bool set_num_parallel_workers(int32_t num_parallel_workers);
  41. /// \brief Function to get the default number of parallel workers.
  42. /// \return number of parallel workers to be used as a default for each operation.
  43. int32_t get_num_parallel_workers();
  44. /// \brief Function to set the default interval (in milliseconds) for monitor sampling.
  45. /// \param[in] interval interval (in milliseconds) to be used for performance monitor sampling.
  46. bool set_monitor_sampling_interval(int32_t interval);
  47. /// \brief Function to get the default interval of performance monitor sampling.
  48. /// \return interval (in milliseconds) for performance monitor sampling.
  49. int32_t get_monitor_sampling_interval();
  50. /// \brief Function to set the default timeout (in seconds) for DSWaitedCallback. In case of a deadlock, the wait
  51. /// function will exit after the timeout period.
  52. /// \param[in] timeout timeout (in seconds) to be used to end the wait in DSWaitedCallback in case of a deadlock.
  53. bool set_callback_timeout(int32_t timeout);
  54. /// \brief Function to get the default timeout for DSWaitedCallback. In case of a deadback, the wait function will exit
  55. /// after the timeout period.
  56. /// \return the duration in seconds.
  57. int32_t get_callback_timeout();
  58. /// \brief Function to load configuration from a file.
  59. /// \param[in] file path of the configuration file to be loaded.
  60. /// \note This api exists because std::string will constrained by ABI compile macro but char don't.
  61. bool load(const std::vector<char> &file);
  62. /// \brief Function to load configuration from a file.
  63. /// \param[in] file path of the configuration file to be loaded.
  64. inline bool load(std::string file) { return load(StringToChar(file)); }
  65. } // namespace config
  66. } // namespace dataset
  67. } // namespace mindspore
  68. #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_CONFIG_H