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.

constants.h 3.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**
  2. * Copyright 2019 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_CORE_CONSTANTS_H_
  17. #define MINDSPORE_CCSRC_MINDDATA_DATASET_CORE_CONSTANTS_H_
  18. #include <cstdint>
  19. #include <limits>
  20. #include <random>
  21. namespace mindspore {
  22. namespace dataset {
  23. // Various type defines for convenience
  24. using uchar = unsigned char;
  25. using dsize_t = int64_t;
  26. // Target devices to perform map operation
  27. enum class MapTargetDevice { kCpu, kGpu, kDvpp };
  28. // Possible dataset types for holding the data and client type
  29. enum class DatasetType { kUnknown, kArrow, kTf };
  30. // Possible flavours of Tensor implementations
  31. enum class TensorImpl { kNone, kFlexible, kCv, kNP };
  32. // Possible values for shuffle
  33. enum class ShuffleMode { kFalse = 0, kFiles = 1, kGlobal = 2 };
  34. // Possible values for Border types
  35. enum class BorderType { kConstant = 0, kEdge = 1, kReflect = 2, kSymmetric = 3 };
  36. // Possible values for Image format types in a batch
  37. enum class ImageBatchFormat { kNHWC = 0, kNCHW = 1 };
  38. // Possible values for Image format types
  39. enum class ImageFormat { HWC = 0, CHW = 1, HW = 2 };
  40. // Possible interpolation modes
  41. enum class InterpolationMode { kLinear = 0, kNearestNeighbour = 1, kCubic = 2, kArea = 3 };
  42. // Possible JiebaMode modes
  43. enum class JiebaMode { kMix = 0, kMp = 1, kHmm = 2 };
  44. // Possible values for SPieceTokenizerOutType
  45. enum class SPieceTokenizerOutType { kString = 0, kInt = 1 };
  46. // Possible values for SPieceTokenizerLoadType
  47. enum class SPieceTokenizerLoadType { kFile = 0, kModel = 1 };
  48. // Possible values for SentencePieceModel
  49. enum class SentencePieceModel { kUnigram = 0, kBpe = 1, kChar = 2, kWord = 3 };
  50. // Possible values for NormalizeForm
  51. enum class NormalizeForm {
  52. kNone = 0,
  53. kNfc,
  54. kNfkc,
  55. kNfd,
  56. kNfkd,
  57. };
  58. // convenience functions for 32bit int bitmask
  59. inline bool BitTest(uint32_t bits, uint32_t bitMask) { return (bits & bitMask) == bitMask; }
  60. inline void BitSet(uint32_t *bits, uint32_t bitMask) { *bits |= bitMask; }
  61. inline void BitClear(uint32_t *bits, uint32_t bitMask) { *bits &= (~bitMask); }
  62. constexpr int32_t kDeMaxDim = std::numeric_limits<int32_t>::max(); // 2147483647 or 2^32 -1
  63. constexpr int32_t kDeMaxRank = std::numeric_limits<int32_t>::max();
  64. constexpr int64_t kDeMaxFreq = std::numeric_limits<int64_t>::max(); // 9223372036854775807 or 2^(64-1)
  65. constexpr int64_t kDeMaxTopk = std::numeric_limits<int64_t>::max();
  66. constexpr uint32_t kCfgRowsPerBuffer = 1;
  67. constexpr uint32_t kCfgParallelWorkers = 4;
  68. constexpr uint32_t kCfgWorkerConnectorSize = 16;
  69. constexpr uint32_t kCfgOpConnectorSize = 16;
  70. constexpr int32_t kCfgDefaultRankId = -1;
  71. constexpr uint32_t kCfgDefaultSeed = std::mt19937::default_seed;
  72. constexpr uint32_t kCfgMonitorSamplingInterval = 10;
  73. constexpr uint32_t kCfgCallbackTimeout = 60; // timeout value for callback in seconds
  74. constexpr int32_t kCfgDefaultCachePort = 50052;
  75. constexpr char kCfgDefaultCacheHost[] = "127.0.0.1";
  76. constexpr int32_t kDftPrefetchSize = 20;
  77. constexpr int32_t kDftNumConnections = 12;
  78. constexpr int32_t kDftAutoNumWorkers = false;
  79. // Invalid OpenCV type should not be from 0 to 7 (opencv4/opencv2/core/hal/interface.h)
  80. constexpr uint8_t kCVInvalidType = 255;
  81. using connection_id_type = uint64_t;
  82. using session_id_type = uint32_t;
  83. using row_id_type = int64_t;
  84. } // namespace dataset
  85. } // namespace mindspore
  86. #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_CORE_CONSTANTS_H_