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.

string_ops.h 4.4 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /**
  2. * Copyright 2019-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 GE_OP_STRING_OPS_H_
  17. #define GE_OP_STRING_OPS_H_
  18. #include <sstream>
  19. #include "graph/operator_reg.h"
  20. namespace ge {
  21. REG_OP(StringSplit)
  22. .INPUT(input, TensorType({DT_STRING}))
  23. .INPUT(delimiter, TensorType({DT_STRING}))
  24. .OUTPUT(indices, TensorType({DT_INT64}))
  25. .OUTPUT(values, TensorType({DT_STRING}))
  26. .OUTPUT(shape, TensorType({DT_INT64}))
  27. .ATTR(skip_empty, Bool, true)
  28. .OP_END_FACTORY_REG(StringSplit)
  29. REG_OP(StringSplitV2)
  30. .INPUT(input, TensorType({DT_STRING}))
  31. .INPUT(sep, TensorType({DT_STRING}))
  32. .OUTPUT(indices, TensorType({DT_INT64}))
  33. .OUTPUT(values, TensorType({DT_STRING}))
  34. .OUTPUT(shape, TensorType({DT_INT64}))
  35. .ATTR(maxsplit, Int, -1)
  36. .OP_END_FACTORY_REG(StringSplitV2)
  37. REG_OP(UnicodeScript)
  38. .INPUT(x, TensorType({DT_INT32}))
  39. .OUTPUT(y, TensorType({DT_INT32}))
  40. .OP_END_FACTORY_REG(UnicodeScript)
  41. REG_OP(Substr)
  42. .INPUT(input, TensorType({DT_STRING}))
  43. .INPUT(pos, TensorType({DT_INT32, DT_INT64}))
  44. .INPUT(len, TensorType({DT_INT32, DT_INT64}))
  45. .OUTPUT(output, TensorType({DT_STRING}))
  46. .OP_END_FACTORY_REG(Substr)
  47. REG_OP(StringToHashBucketFast)
  48. .INPUT(x, TensorType({DT_STRING}))
  49. .OUTPUT(y, TensorType({DT_INT64}))
  50. .ATTR(num_buckets, Int, 1)
  51. .OP_END_FACTORY_REG(StringToHashBucketFast)
  52. REG_OP(StringToHashBucketStrong)
  53. .INPUT(x, TensorType({DT_STRING}))
  54. .OUTPUT(y, TensorType({DT_INT64}))
  55. .ATTR(num_buckets, Int, 1)
  56. .REQUIRED_ATTR(key, ListInt)
  57. .OP_END_FACTORY_REG(StringToHashBucketStrong)
  58. REG_OP(StringToHashBucket)
  59. .INPUT(string_tensor, TensorType({DT_STRING}))
  60. .OUTPUT(y, TensorType({DT_INT64}))
  61. .ATTR(num_buckets, Int, 1)
  62. .OP_END_FACTORY_REG(StringToHashBucket)
  63. REG_OP(StringStrip)
  64. .INPUT(x, TensorType({DT_STRING}))
  65. .OUTPUT(y, TensorType({DT_STRING}))
  66. .OP_END_FACTORY_REG(StringStrip)
  67. REG_OP(StringLength)
  68. .INPUT(x, TensorType({DT_STRING}))
  69. .OUTPUT(y, TensorType({DT_INT32}))
  70. .ATTR(unit, String, "BYTE")
  71. .OP_END_FACTORY_REG(StringLength)
  72. REG_OP(StringJoin)
  73. .DYNAMIC_INPUT(x, TensorType({DT_STRING}))
  74. .OUTPUT(y, TensorType({DT_STRING}))
  75. .REQUIRED_ATTR(N, Int)
  76. .ATTR(separator, String, "")
  77. .OP_END_FACTORY_REG(StringJoin)
  78. REG_OP(StringFormat)
  79. .DYNAMIC_INPUT(x, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, \
  80. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_STRING, DT_FLOAT16, \
  81. DT_FLOAT, DT_DOUBLE, DT_BOOL}))
  82. .OUTPUT(y, TensorType({DT_STRING}))
  83. .ATTR(template, String, "%s")
  84. .ATTR(placeholder, String, "%s")
  85. .ATTR(summarize, Int, 3)
  86. .OP_END_FACTORY_REG(StringFormat)
  87. REG_OP(RegexFullMatch)
  88. .INPUT(x, TensorType({DT_STRING}))
  89. .INPUT(pattern, TensorType({DT_STRING}))
  90. .OUTPUT(y, TensorType({DT_BOOL}))
  91. .OP_END_FACTORY_REG(RegexFullMatch)
  92. REG_OP(RegexReplace)
  93. .INPUT(x, TensorType({DT_STRING}))
  94. .INPUT(pattern, TensorType({DT_STRING}))
  95. .INPUT(rewrite, TensorType({DT_STRING}))
  96. .OUTPUT(y, TensorType({DT_STRING}))
  97. .ATTR(replace_global, Bool, true)
  98. .OP_END_FACTORY_REG(RegexReplace)
  99. REG_OP(AsString)
  100. .INPUT(x, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_FLOAT, \
  101. DT_DOUBLE, DT_BOOL}))
  102. .OUTPUT(y, TensorType({DT_STRING}))
  103. .ATTR(precision, Int, -1)
  104. .ATTR(scientific, Bool, false)
  105. .ATTR(shortest, Bool, false)
  106. .ATTR(width, Int, -1)
  107. .ATTR(fill, String, "")
  108. .OP_END_FACTORY_REG(AsString)
  109. REG_OP(EncodeBase64)
  110. .INPUT(x, TensorType({DT_STRING}))
  111. .OUTPUT(y, TensorType({DT_STRING}))
  112. .ATTR(pad, Bool, false)
  113. .OP_END_FACTORY_REG(EncodeBase64)
  114. REG_OP(DecodeBase64)
  115. .INPUT(x, TensorType({DT_STRING}))
  116. .OUTPUT(y, TensorType({DT_STRING}))
  117. .OP_END_FACTORY_REG(DecodeBase64)
  118. } // namespace ge
  119. #endif // GE_OP_STRING_OPS_H_

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示