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.

rnn.h 83 kB

5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620
  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. /*!
  17. * \file rnn.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_RNN_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_RNN_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. *@brief: Basic LSTM Cell forward calculation.
  26. *@par Inputs:
  27. *five inputs:
  28. *@li x:A 4D Tensor. Must be one of the following types: float16.
  29. *@li h:A 4D Tensor. Must be one of the following types: float16.
  30. *@li c:A 4D Tensor. Must be one of the following types: float16, float32.
  31. *@li w:A 4D Tensor. Must be one of the following types: float16.
  32. *@li b:A 1D Tensor. Must be one of the following types: float16. The format must be ND . \n
  33. *@li mask:A 1D Tensor. Must be one of the following types: uint8.
  34. *@par Attributes:
  35. *@li keep_prob:An integer identifying the keep prob in the op. Default to 1.
  36. *@li forget_bias:An integer identifying the forget bias in the op. Default to 1.
  37. *@li state_is_tuple:An bool identifying if the hidden state and cell state is tuple. Default to true.
  38. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported . \n
  39. *@par Outputs:
  40. *seven outputs:
  41. *@li ct:A 4D Tensor. Must be one of the following types: float16, float32.
  42. *@li ht:A 4D Tensor. Must be one of the following types: float16.
  43. *@li it:A 4D Tensor. Must be one of the following types: float16, float32.
  44. *@li jt:A 4D Tensor. Must be one of the following types: float16, float32.
  45. *@li ft:A 4D Tensor. Must be one of the following types: float16, float32.
  46. *@li ot:A 4D Tensor. Must be one of the following types: float16, float32.
  47. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32.
  48. */
  49. REG_OP(BasicLSTMCell)
  50. .INPUT(x, TensorType({DT_FLOAT16}))
  51. .INPUT(h, TensorType({DT_FLOAT16}))
  52. .INPUT(c, TensorType({DT_FLOAT16, DT_FLOAT}))
  53. .INPUT(w, TensorType({DT_FLOAT16}))
  54. .INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  55. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  56. .OUTPUT(ct, TensorType({DT_FLOAT16, DT_FLOAT}))
  57. .OUTPUT(ht, TensorType({DT_FLOAT16}))
  58. .OUTPUT(it, TensorType({DT_FLOAT16, DT_FLOAT}))
  59. .OUTPUT(jt, TensorType({DT_FLOAT16, DT_FLOAT}))
  60. .OUTPUT(ft, TensorType({DT_FLOAT16, DT_FLOAT}))
  61. .OUTPUT(ot, TensorType({DT_FLOAT16, DT_FLOAT}))
  62. .OUTPUT(tanhct, TensorType({DT_FLOAT16, DT_FLOAT}))
  63. .ATTR(keep_prob, Float, 1.0)
  64. .ATTR(forget_bias, Float, 1.0)
  65. .ATTR(state_is_tuple, Bool, true)
  66. .ATTR(activation, String, "tanh")
  67. .OP_END_FACTORY_REG(BasicLSTMCell)
  68. /**
  69. *@brief: Dynamic LSTM forward calculation . \n
  70. *@par Inputs:
  71. *@li x:A 4D Tensor. Must be the type float32.
  72. *@li w:A 4D Tensor. Must be the type float32.
  73. *@li b:A 1D Tensor. Must be the type float32. The format must be ND . \n
  74. *@par Outputs:
  75. *output_h:A Tensor of output. Must be the type float32.
  76. *@par Restrictions:
  77. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  78. */
  79. REG_OP(DynamicLSTM)
  80. .INPUT(x, TensorType({DT_FLOAT32}))
  81. .INPUT(w, TensorType({DT_FLOAT32}))
  82. .INPUT(b, TensorType({DT_FLOAT32}))
  83. .OUTPUT(output_h, TensorType({DT_FLOAT32}))
  84. .OP_END_FACTORY_REG(DynamicLSTM)
  85. /**
  86. *@brief: DynamicRNNGrad calculation.
  87. *@par Inputs:
  88. *ten inputs: \n
  89. *@li x:A 4D Tensor. Must be one of the following types: float16, float32.
  90. *@li w:A 4D Tensor. Must be one of the following types: float16, float32.
  91. *@li b:A 1D Tensor. Must be one of the following types: float16, float32.
  92. *@li y:A 1D Tensor. Must be one of the following types: int32.
  93. *@li init_h:A 4D Tensor. Must be one of the following types: float16, float32.
  94. *@li init_c:A 4D Tensor. Must be one of the following types: float16, float32.
  95. *@li h:A 4D Tensor. Must be one of the following types: float16, float32.
  96. *@li c:A 4D Tensor. Must be one of the following types: float16, float32.
  97. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32.
  98. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32.
  99. *@li dc:A 4D Tensor. Must be one of the following types: float16, float32.
  100. *@li i:A 4D Tensor. Must be one of the following types: float16, float32.
  101. *@li j:A 4D Tensor. Must be one of the following types: float16, float32.
  102. *@li f:A 4D Tensor. Must be one of the following types: float16, float32.
  103. *@li o:A 4D Tensor. Must be one of the following types: float16, float32.
  104. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32.
  105. *@li seq_length:A 1D Tensor. Must be one of the following types: int32.
  106. *@li mask:A 1D Tensor. Must be one of the following types: int8.
  107. *@li wci:A 4D Tensor. Must be one of the following types: float16, float32.
  108. *@li wcf:A 4D Tensor. Must be one of the following types: float16, float32.
  109. *@li wco:A 4D Tensor. Must be one of the following types: float16, float32.
  110. *@par Attributes:
  111. *@li cell_type:An string identifying the cell type in the op. Default to "LSTM". Only LSTM is currently supported.
  112. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported.
  113. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  114. *@li use_peephole:An bool identifying if use peephole in the op. Default to false.
  115. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  116. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  117. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  118. *@li time_major:An bool identifying the time major in the op. Default to false.
  119. *@li forget_bias:An float identifying the forget bias in the op. Default to 0.
  120. *@par Outputs:
  121. *eight outputs: \n
  122. *@li dw:A 4D Tensor. Must be one of the following types: float16, float32.
  123. *@li db:A 4D Tensor. Must be one of the following types: float16, float32.
  124. *@li dx:A 4D Tensor. Must be one of the following types: float16, float32.
  125. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32.
  126. *@li dc_prev:A 4D Tensor. Must be one of the following types: float16, float32.
  127. *@li dwci:A 4D Tensor. Must be one of the following types: float16, float32.
  128. *@li dwcf:A 4D Tensor. Must be one of the following types: float16, float32.
  129. *@li dwco:A 4D Tensor. Must be one of the following types: float16, float32.
  130. */
  131. REG_OP(DynamicRNNGrad)
  132. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  133. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  134. .INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  135. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  136. .INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  137. .INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  138. .INPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  139. .INPUT(c, TensorType({DT_FLOAT16, DT_FLOAT}))
  140. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  141. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  142. .INPUT(dc, TensorType({DT_FLOAT16, DT_FLOAT}))
  143. .INPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  144. .INPUT(j, TensorType({DT_FLOAT16, DT_FLOAT}))
  145. .INPUT(f, TensorType({DT_FLOAT16, DT_FLOAT}))
  146. .INPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  147. .OPTIONAL_INPUT(tanhct, TensorType({DT_FLOAT16, DT_FLOAT}))
  148. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32}))
  149. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  150. .OPTIONAL_INPUT(wci, TensorType({DT_FLOAT16, DT_FLOAT}))
  151. .OPTIONAL_INPUT(wcf, TensorType({DT_FLOAT16, DT_FLOAT}))
  152. .OPTIONAL_INPUT(wco, TensorType({DT_FLOAT16, DT_FLOAT}))
  153. .OUTPUT(dw, TensorType({DT_FLOAT16, DT_FLOAT}))
  154. .OUTPUT(db, TensorType({DT_FLOAT16, DT_FLOAT}))
  155. .OUTPUT(dx, TensorType({DT_FLOAT16, DT_FLOAT}))
  156. .OUTPUT(dh_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  157. .OUTPUT(dc_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  158. .DYNAMIC_OUTPUT(dwci, TensorType({DT_FLOAT16, DT_FLOAT}))
  159. .DYNAMIC_OUTPUT(dwcf, TensorType({DT_FLOAT16, DT_FLOAT}))
  160. .DYNAMIC_OUTPUT(dwco, TensorType({DT_FLOAT16, DT_FLOAT}))
  161. .ATTR(cell_type, String, "LSTM")
  162. .ATTR(direction, String, "UNIDIRECTIONAL")
  163. .ATTR(cell_depth, Int, 0)
  164. .ATTR(use_peephole, Bool, false)
  165. .ATTR(keep_prob, Float, -1.0)
  166. .ATTR(cell_clip, Float, -1.0)
  167. .ATTR(num_proj, Int, 0)
  168. .ATTR(time_major, Bool, true)
  169. .ATTR(forget_bias, Float, 0.0)
  170. .OP_END_FACTORY_REG(DynamicRNNGrad)
  171. /**
  172. *@brief: DynamicRNN calculation.
  173. *@par Inputs:
  174. *ten inputs:
  175. *@li x:A required 4D Tensor. Must be one of the following types: float16, float32.
  176. *@li w:A required 4D Tensor. Must be one of the following types: float16, float32.
  177. *@li b:A required 1D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  178. *@li seq_length:A optional Tensor. Only Support int32 in ND.
  179. *@li init_h:A optional 4D Tensor. Must be one of the following types: float16, float32.
  180. *@li init_c:A optional 4D Tensor. Must be one of the following types: float16, float32.
  181. *@li wci:A 4D optional Tensor. Must be one of the following types: float16, float32.
  182. *@li wcf:A 4D optional Tensor. Must be one of the following types: float16, float32.
  183. *@li wco:A 4D optional Tensor. Must be one of the following types: float16, float32.
  184. *@li mask:A 1D optional Tensor. Must be one of the following types: uint8. The format must be ND . \n
  185. *@par Attributes:
  186. *@li cell_type:An string identifying the cell type in the op. Default to "LSTM". Only LSTM is currently supported.
  187. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported.
  188. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  189. *@li use_peephole:An bool identifying if use peephole in the op. Default to false.
  190. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  191. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  192. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  193. *@li time_major:An bool identifying the time major in the op. Default to true.
  194. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported.
  195. *@li forget_bias:An float identifying the forget bias in the op. Default to 0.
  196. *@li gate_order:An string identifying the type of gate order in the op. Support "ijfo" and "ifjo". Default to "ijfo".
  197. *@li is_training:An bool identifying is training in the op. Default to true . \n
  198. *@par Outputs:
  199. *eight outputs:
  200. *@li y:A 4D Tensor. Must be one of the following types: float16, float32.
  201. *@li output_h:A 4D Tensor. Must be one of the following types: float16, float32.
  202. *@li output_c:A 4D Tensor. Must be one of the following types: float16, float32.
  203. *@li i:A 4D Tensor. Must be one of the following types: float16, float32.
  204. *@li j:A 4D Tensor. Must be one of the following types: float16, float32.
  205. *@li f:A 4D Tensor. Must be one of the following types: float16, float32.
  206. *@li o:A 4D Tensor. Must be one of the following types: float16, float32.
  207. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32.
  208. *@par Third-party framework compatibility:
  209. * Compatible with the TF operator LSTM.
  210. */
  211. REG_OP(DynamicRNN)
  212. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  213. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  214. .INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  215. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32, DT_FLOAT16}))
  216. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  217. .OPTIONAL_INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  218. .OPTIONAL_INPUT(wci, TensorType({DT_FLOAT16, DT_FLOAT}))
  219. .OPTIONAL_INPUT(wcf, TensorType({DT_FLOAT16, DT_FLOAT}))
  220. .OPTIONAL_INPUT(wco, TensorType({DT_FLOAT16, DT_FLOAT}))
  221. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  222. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  223. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  224. .OUTPUT(output_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  225. .OUTPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  226. .OUTPUT(j, TensorType({DT_FLOAT16, DT_FLOAT}))
  227. .OUTPUT(f, TensorType({DT_FLOAT16, DT_FLOAT}))
  228. .OUTPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  229. .OUTPUT(tanhc, TensorType({DT_FLOAT16, DT_FLOAT}))
  230. .ATTR(cell_type, String, "LSTM")
  231. .ATTR(direction, String, "UNIDIRECTIONAL")
  232. .ATTR(cell_depth, Int, 1)
  233. .ATTR(use_peephole, Bool, false)
  234. .ATTR(keep_prob, Float, 1.0)
  235. .ATTR(cell_clip, Float, -1.0)
  236. .ATTR(num_proj, Int, 0)
  237. .ATTR(time_major, Bool, true)
  238. .ATTR(activation, String, "tanh")
  239. .ATTR(forget_bias, Float, 0.0)
  240. .ATTR(gate_order, String, "ijfo")
  241. .ATTR(is_training, Bool, true)
  242. .OP_END_FACTORY_REG(DynamicRNN)
  243. /**
  244. *@brief: DynamicRNNV2 calculation.
  245. *@par Inputs:
  246. *ten inputs:
  247. *@li x:A required 4D Tensor. Must be one of the following types: float16, float32.
  248. *@li weight_input:A required 4D Tensor. Must be one of the following types: float16, float32.
  249. *@li weight_hidden:A required 4D Tensor. Must be one of the following types: float16, float32.
  250. *@li b:A required 1D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  251. *@li seq_length:A optional 1D Tensor. Must be one of the following types: float16, int32.
  252. *@li init_h:A optional 4D Tensor. Must be one of the following types: float16, float32.
  253. *@li init_c:A optional 4D Tensor. Must be one of the following types: float16, float32.
  254. *@li wci:A 4D optional Tensor. Must be one of the following types: float16, float32.
  255. *@li wcf:A 4D optional Tensor. Must be one of the following types: float16, float32.
  256. *@li wco:A 4D optional Tensor. Must be one of the following types: float16, float32.
  257. *@li mask:A 1D optional Tensor. Must be one of the following types: uint8. The format must be ND . \n
  258. *@par Attributes:
  259. *@li cell_type:An string identifying the cell type in the op. Default to "LSTM". Only LSTM is currently supported.
  260. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL".
  261. *Only UNIDIRECTIONAL is currently supported.
  262. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  263. *@li use_peephole:An bool identifying if use peephole in the op. Default to false.
  264. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  265. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  266. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  267. *@li time_major:An bool identifying the time major in the op. Default to true.
  268. *@li activation:An string identifying the type of activation function in the op. Default to "tanh".
  269. *Support "tanh" and "clip".
  270. *@li recurrent_activation:An string identifying the type of activation function in the op. Default to "sigmoid".
  271. *Support "sigmoid" and "hard_sigmoid". In general, set "hard_sigmoid" for TF Keras LSTM.
  272. *@li forget_bias:An float identifying the forget bias in the op. Default to 0.
  273. *@li gate_order:An string identifying the type of gate order in the op. Support "ijfo" and "ifco". Default to "ijfo".
  274. *Set "ijfo" for TF operator LSTM, Set "ifco" for TF Keras LSTM.
  275. *@li stateful: An bool identifying the type of stateful in the op. Default to fasle.Only false is currently supported.
  276. *@li merge_mode: An string identifying the type of merge_modein the op. Default to "concat".
  277. *Only "concat" is currently supported
  278. *@li is_training:An bool identifying is training in the op. Default to true . \n
  279. *@par Outputs:
  280. *eight outputs:
  281. *@li y:A 4D Tensor. Must be one of the following types: float16, float32.
  282. *@li output_h:A 4D Tensor. Must be one of the following types: float16, float32.
  283. *Return the last output_h.
  284. *@li output_c:A 4D Tensor. Must be one of the following types: float16, float32.
  285. *Return the last output_c.
  286. *@li i:A 4D Tensor. Must be one of the following types: float16, float32.
  287. *@li j:A 4D Tensor. Must be one of the following types: float16, float32.
  288. *@li f:A 4D Tensor. Must be one of the following types: float16, float32.
  289. *@li o:A 4D Tensor. Must be one of the following types: float16, float32.
  290. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32.
  291. *@par Third-party framework compatibility:
  292. * Compatible with the TF operator LSTM or TF keras operator LSTM.
  293. */
  294. REG_OP(DynamicRNNV2)
  295. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  296. .INPUT(weight_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  297. .INPUT(weight_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  298. .OPTIONAL_INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  299. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32, DT_FLOAT16}))
  300. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  301. .OPTIONAL_INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  302. .OPTIONAL_INPUT(wci, TensorType({DT_FLOAT16, DT_FLOAT}))
  303. .OPTIONAL_INPUT(wcf, TensorType({DT_FLOAT16, DT_FLOAT}))
  304. .OPTIONAL_INPUT(wco, TensorType({DT_FLOAT16, DT_FLOAT}))
  305. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  306. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  307. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  308. .OUTPUT(output_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  309. .OUTPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  310. .OUTPUT(j, TensorType({DT_FLOAT16, DT_FLOAT}))
  311. .OUTPUT(f, TensorType({DT_FLOAT16, DT_FLOAT}))
  312. .OUTPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  313. .OUTPUT(tanhc, TensorType({DT_FLOAT16, DT_FLOAT}))
  314. .ATTR(cell_type, String, "LSTM")
  315. .ATTR(direction, String, "UNIDIRECTIONAL")
  316. .ATTR(cell_depth, Int, 1)
  317. .ATTR(use_peephole, Bool, false)
  318. .ATTR(keep_prob, Float, 1.0)
  319. .ATTR(cell_clip, Float, -1.0)
  320. .ATTR(num_proj, Int, 0)
  321. .ATTR(time_major, Bool, true)
  322. .ATTR(activation, String, "tanh")
  323. .ATTR(recurrent_activation, String, "sigmoid")
  324. .ATTR(forget_bias, Float, 0.0)
  325. .ATTR(gate_order, String, "ijfo")
  326. .ATTR(stateful, Bool, false)
  327. .ATTR(merge_mode, String, "concat")
  328. .ATTR(is_training, Bool, true)
  329. .OP_END_FACTORY_REG(DynamicRNNV2)
  330. /**
  331. * @brief: DynamicRNNV2Grad calculation.
  332. * @par Inputs:
  333. * twenty-one inputs:
  334. * @li x:A required 4D Tensor. Must be one of the following types: float16, float32.
  335. * @li w_x:A required 4D Tensor. Must be one of the following types: float16, float32.
  336. * @li w_h:A required 4D Tensor. Must be one of the following types: float16, float32.
  337. * @li y:A 4D Tensor. Must be one of the following types: float16, float32.
  338. * @li init_h:A 4D Tensor. Must be one of the following types: float16, float32.
  339. * @li init_c:A 4D Tensor. Must be one of the following types: float16, float32.
  340. * @li h:A 4D Tensor. Must be one of the following types: float16, float32.
  341. * @li c:A 4D Tensor. Must be one of the following types: float16, float32.
  342. * @li dy:A 4D Tensor. Must be one of the following types: float16, float32.
  343. * @li dh:A 4D Tensor. Must be one of the following types: float16, float32.
  344. * @li dc:A 4D Tensor. Must be one of the following types: float16, float32.
  345. * @li i:A 4D Tensor. Must be one of the following types: float16, float32.
  346. * @li j:A 4D Tensor. Must be one of the following types: float16, float32.
  347. * @li f:A 4D Tensor. Must be one of the following types: float16, float32.
  348. * @li o:A 4D Tensor. Must be one of the following types: float16, float32.
  349. * @li tanhct:A 4D Tensor. Must be one of the following types: float16, float32.
  350. * @li seq_length:A 1D Tensor. Must be one of the following types: int32.
  351. * @li wci:A 4D Tensor. Must be one of the following types: float16, float32.
  352. * @li wcf:A 4D Tensor. Must be one of the following types: float16, float32.
  353. * @li wco:A 4D Tensor. Must be one of the following types: float16, float32.
  354. * @li mask:A 1D Tensor. Must be one of the following types: int8. \n
  355. * @par Attributes:
  356. * @li cell_type:An string identifying the cell type in the op. Default to "LSTM". Only LSTM is currently supported.
  357. * @li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL".
  358. * Only UNIDIRECTIONAL is currently supported.
  359. * @li cell_depth:An integer identifying the cell depth in the op. Default to 1. Only 1 is currently supported.
  360. * @li use_peephole:An bool identifying if use peephole in the op. Default to false.
  361. * Only false is currently supported.
  362. * @li keep_prob:An float identifying the keep prob in the op. Default to 1. Only 1 is currently supported.
  363. * @li cell_clip:An float identifying the cell clip in the op. Default to -1. Only -1 is currently supported.
  364. * @li num_proj:An integer identifying the num projection in the op. Default to 0. Only 0 is currently supported.
  365. * @li time_major:An bool identifying the time major in the op. Default to true. Only true is currently supported.
  366. * @li activation:An string identifying the type of activation function in the op. Default to "tanh".
  367. * Only "tanh" is currently supported.
  368. * @li recurrent_activation:An string identifying the type of activation function in the op. Default to "sigmoid".
  369. * Only "sigmoid" is currently supported.
  370. * @li gate_order:An string identifying the type of gate order in the op. Support "ijfo" and "ifco". Default to "ijfo".
  371. * Set "ijfo" for TF operator LSTM, Set "ifco" for TF Keras/Pytorch LSTM .
  372. * @li stateful: An bool identifying the type of stateful in the op. Default to fasle.Only false is currently supported.
  373. * @li merge_mode: An string identifying the type of merge_modein the op. Default to "concat".
  374. * Only "concat" is currently supported. \n
  375. * @par Outputs:
  376. * nine outputs:
  377. * @li dw_x:A 4D Tensor. Must be one of the following types: float16, float32.
  378. * @li dw_h:A 4D Tensor. Must be one of the following types: float16, float32.
  379. * @li db:A 4D Tensor. Must be one of the following types: float16, float32.
  380. * @li dx:A 4D Tensor. Must be one of the following types: float16, float32.
  381. * @li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32.
  382. * @li dc_prev:A 4D Tensor. Must be one of the following types: float16, float32.
  383. * @li dwci:A 4D Tensor. Must be one of the following types: float16, float32.
  384. * @li dwcf:A 4D Tensor. Must be one of the following types: float16, float32.
  385. * @li dwco:A 4D Tensor. Must be one of the following types: float16, float32.
  386. * @par Third-party framework compatibility:
  387. * Compatible with the TF operator LSTM or TF keras operator LSTM.
  388. * @par Restrictions:
  389. * Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  390. */
  391. REG_OP(DynamicRNNV2Grad)
  392. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  393. .INPUT(w_x, TensorType({DT_FLOAT16, DT_FLOAT}))
  394. .INPUT(w_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  395. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  396. .INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  397. .INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  398. .INPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  399. .INPUT(c, TensorType({DT_FLOAT16, DT_FLOAT}))
  400. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  401. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  402. .INPUT(dc, TensorType({DT_FLOAT16, DT_FLOAT}))
  403. .INPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  404. .INPUT(j, TensorType({DT_FLOAT16, DT_FLOAT}))
  405. .INPUT(f, TensorType({DT_FLOAT16, DT_FLOAT}))
  406. .INPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  407. .INPUT(tanhct, TensorType({DT_FLOAT16, DT_FLOAT}))
  408. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32}))
  409. .OPTIONAL_INPUT(wci, TensorType({DT_FLOAT16, DT_FLOAT}))
  410. .OPTIONAL_INPUT(wcf, TensorType({DT_FLOAT16, DT_FLOAT}))
  411. .OPTIONAL_INPUT(wco, TensorType({DT_FLOAT16, DT_FLOAT}))
  412. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  413. .OUTPUT(dw_x, TensorType({DT_FLOAT16, DT_FLOAT}))
  414. .OUTPUT(dw_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  415. .OUTPUT(db, TensorType({DT_FLOAT16, DT_FLOAT}))
  416. .OUTPUT(dx, TensorType({DT_FLOAT16, DT_FLOAT}))
  417. .OUTPUT(dh_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  418. .OUTPUT(dc_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  419. .DYNAMIC_OUTPUT(dwci, TensorType({DT_FLOAT16, DT_FLOAT}))
  420. .DYNAMIC_OUTPUT(dwcf, TensorType({DT_FLOAT16, DT_FLOAT}))
  421. .DYNAMIC_OUTPUT(dwco, TensorType({DT_FLOAT16, DT_FLOAT}))
  422. .ATTR(cell_type, String, "LSTM")
  423. .ATTR(direction, String, "UNIDIRECTIONAL")
  424. .ATTR(cell_depth, Int, 1)
  425. .ATTR(use_peephole, Bool, false)
  426. .ATTR(keep_prob, Float, 1.0)
  427. .ATTR(cell_clip, Float, -1.0)
  428. .ATTR(num_proj, Int, 0)
  429. .ATTR(time_major, Bool, true)
  430. .ATTR(activation, String, "tanh")
  431. .ATTR(recurrent_activation, String, "sigmoid")
  432. .ATTR(gate_order, String, "ijfo")
  433. .ATTR(stateful, Bool, false)
  434. .ATTR(merge_mode, String, "concat")
  435. .OP_END_FACTORY_REG(DynamicRNNV2Grad)
  436. /**
  437. *@brief: DynamicRNNV3 calculation.
  438. *@par Inputs:
  439. *ten inputs:
  440. *@li x:A required 4D Tensor. Must be one of the following types: float16, float32.
  441. *@li w:A required 4D Tensor. Must be one of the following types: float16, float32.
  442. *@li b:A required 1D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  443. *@li seq_length:A optional 1D Tensor. Must be one of the following types: int32. The format must be ND.
  444. *@li init_h:A optional 4D Tensor. Must be one of the following types: float16, float32.
  445. *@li init_c:A optional 4D Tensor. Must be one of the following types: float16, float32.
  446. *@li wci:A 4D optional Tensor. Must be one of the following types: float16, float32.
  447. *@li wcf:A 4D optional Tensor. Must be one of the following types: float16, float32.
  448. *@li wco:A 4D optional Tensor. Must be one of the following types: float16, float32.
  449. *@li mask:A 1D optional Tensor. Must be one of the following types: uint8. The format must be ND . \n
  450. *@li real_mask:A 4D optional Tensor. Must be one of the following types: float16, float32.
  451. *@li project:A 4D optional Tensor. Must be one of the following types: float16, float32.
  452. *@par Attributes:
  453. *@li cell_type:An string identifying the cell type in the op. Default to "LSTM". Only LSTM is currently supported.
  454. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported.
  455. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  456. *@li use_peephole:An bool identifying if use peephole in the op. Default to false.
  457. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  458. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  459. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  460. *@li time_major:An bool identifying the time major in the op. Default to true.
  461. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported.
  462. *@li forget_bias:An float identifying the forget bias in the op. Default to 0.
  463. *@li is_training:An bool identifying is training in the op. Default to true . \n
  464. *@par Outputs:
  465. *eight outputs:
  466. *@li y:A 4D Tensor. Must be one of the following types: float16, float32.
  467. *@li output_h:A 4D Tensor. Must be one of the following types: float16, float32.
  468. *@li output_c:A 4D Tensor. Must be one of the following types: float16, float32.
  469. *@li i:A 4D Tensor. Must be one of the following types: float16, float32.
  470. *@li j:A 4D Tensor. Must be one of the following types: float16, float32.
  471. *@li f:A 4D Tensor. Must be one of the following types: float16, float32.
  472. *@li o:A 4D Tensor. Must be one of the following types: float16, float32.
  473. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32.
  474. *@par Third-party framework compatibility:
  475. * Compatible with the TF operator LSTM.
  476. */
  477. REG_OP(DynamicRNNV3)
  478. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  479. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  480. .INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  481. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32}))
  482. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  483. .OPTIONAL_INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  484. .OPTIONAL_INPUT(wci, TensorType({DT_FLOAT16, DT_FLOAT}))
  485. .OPTIONAL_INPUT(wcf, TensorType({DT_FLOAT16, DT_FLOAT}))
  486. .OPTIONAL_INPUT(wco, TensorType({DT_FLOAT16, DT_FLOAT}))
  487. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  488. .OPTIONAL_INPUT(real_mask, TensorType({DT_FLOAT16, DT_FLOAT}))
  489. .OPTIONAL_INPUT(project, TensorType({DT_FLOAT16, DT_FLOAT}))
  490. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  491. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  492. .OUTPUT(output_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  493. .OUTPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  494. .OUTPUT(j, TensorType({DT_FLOAT16, DT_FLOAT}))
  495. .OUTPUT(f, TensorType({DT_FLOAT16, DT_FLOAT}))
  496. .OUTPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  497. .OUTPUT(tanhc, TensorType({DT_FLOAT16, DT_FLOAT}))
  498. .ATTR(cell_type, String, "LSTM")
  499. .ATTR(direction, String, "UNIDIRECTIONAL")
  500. .ATTR(cell_depth, Int, 1)
  501. .ATTR(use_peephole, Bool, false)
  502. .ATTR(keep_prob, Float, 1.0)
  503. .ATTR(cell_clip, Float, -1.0)
  504. .ATTR(num_proj, Int, 0)
  505. .ATTR(time_major, Bool, true)
  506. .ATTR(activation, String, "tanh")
  507. .ATTR(forget_bias, Float, 0.0)
  508. .ATTR(is_training, Bool, true)
  509. .OP_END_FACTORY_REG(DynamicRNNV3)
  510. /**
  511. *@brief: DynamicLSTMV2 calculation.
  512. *@par Inputs:
  513. *ten inputs:
  514. *@li x:A required 4D Tensor. Must be one of the following types: float16, float32.
  515. *@li w:A required 4D Tensor. Must be one of the following types: float16, float32.
  516. *@li b:A required 1D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  517. *@li cont:A required 2D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  518. *@li w_xc_x_static:A optional 2D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  519. *@li h0:A optional 4D Tensor. Must be one of the following types: float16, float32.
  520. *@li c0:A optional 4D Tensor. Must be one of the following types: float16, float32.
  521. *@li wci:A optional 4D Tensor. Must be one of the following types: float16, float32.
  522. *@li wcf:A optional 4D Tensor. Must be one of the following types: float16, float32.
  523. *@li wco:A optional 4D Tensor. Must be one of the following types: float16, float32.
  524. *@li mask:A optional 1D Tensor. Must be one of the following types: uint8. The format must be ND .
  525. *@par Attributes:
  526. *@li num_output:An integer identifying the num projection in the op. Default to 0.
  527. *@li expose_hidden:An bool identifying the expose_hidden in the op. Default to flase.
  528. *@li need_output_last:An bool identifying the time major in the op. Default to true.
  529. *@li forget_bias:An float identifying the forget bias in the op. Default to 0.
  530. *@par Outputs:
  531. *eight outputs:
  532. *@li y:A 4D Tensor. Must be one of the following types: float16, float32.
  533. *@li output_h:A 4D Tensor. Must be one of the following types: float16, float32.
  534. *@li output_c:A 4D Tensor. Must be one of the following types: float16, float32.
  535. *@li last_output_h:A 4D Tensor. Must be one of the following types: float16, float32.
  536. *@li last_output_c:A 4D Tensor. Must be one of the following types: float16, float32.
  537. *@par Third-party framework compatibility:
  538. * Compatible with the Caffe operator LSTM.
  539. *@par Restrictions:
  540. * Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  541. */
  542. REG_OP(DynamicLSTMV2)
  543. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  544. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  545. .INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  546. .INPUT(cont, TensorType({DT_FLOAT16, DT_FLOAT}))
  547. .OPTIONAL_INPUT(w_xc_x_static, TensorType({DT_FLOAT16, DT_FLOAT}))
  548. .OPTIONAL_INPUT(h0, TensorType({DT_FLOAT16, DT_FLOAT}))
  549. .OPTIONAL_INPUT(c0, TensorType({DT_FLOAT16, DT_FLOAT}))
  550. .OPTIONAL_INPUT(wci, TensorType({DT_FLOAT16, DT_FLOAT}))
  551. .OPTIONAL_INPUT(wcf, TensorType({DT_FLOAT16, DT_FLOAT}))
  552. .OPTIONAL_INPUT(wco, TensorType({DT_FLOAT16, DT_FLOAT}))
  553. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  554. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  555. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  556. .OUTPUT(output_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  557. .OUTPUT(last_output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  558. .OUTPUT(last_output_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  559. .ATTR(num_output, Int, 0)
  560. .ATTR(expose_hidden, Bool, false)
  561. .ATTR(need_output_last, Bool, false)
  562. .ATTR(forget_bias, Float, 0.0)
  563. .OP_END_FACTORY_REG(DynamicLSTMV2)
  564. /**
  565. *@brief: LSTMInputGrad calculation.
  566. *@par Inputs:
  567. *ten inputs: \n
  568. *@li w:A 4D Tensor. Must be one of the following types: float16, float32.
  569. *@li init_c:A 4D Tensor. Must be one of the following types: float16, float32.
  570. *@li c:A 4D Tensor. Must be one of the following types: float16, float32.
  571. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32.
  572. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32.
  573. *@li dc:A 4D Tensor. Must be one of the following types: float16, float32.
  574. *@li i:A 4D Tensor. Must be one of the following types: float16, float32.
  575. *@li j:A 4D Tensor. Must be one of the following types: float16, float32.
  576. *@li f:A 4D Tensor. Must be one of the following types: float16, float32.
  577. *@li o:A 4D Tensor. Must be one of the following types: float16, float32.
  578. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32.
  579. *@par Outputs:
  580. *four outputs: \n
  581. *@li dx:A 4D Tensor. Must be one of the following types: float16, float32.
  582. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32.
  583. *@li dc_prev:A 4D Tensor. Must be one of the following types: float16, float32.
  584. *@li dgate:A 4D Tensor. Must be one of the following types: float16.
  585. */
  586. REG_OP(LSTMInputGrad)
  587. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  588. .INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  589. .INPUT(c, TensorType({DT_FLOAT16, DT_FLOAT}))
  590. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  591. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  592. .INPUT(dc, TensorType({DT_FLOAT16, DT_FLOAT}))
  593. .INPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  594. .INPUT(j, TensorType({DT_FLOAT16, DT_FLOAT}))
  595. .INPUT(f, TensorType({DT_FLOAT16, DT_FLOAT}))
  596. .INPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  597. .OPTIONAL_INPUT(tanhct, TensorType({DT_FLOAT16, DT_FLOAT}))
  598. .OUTPUT(dx, TensorType({DT_FLOAT16, DT_FLOAT}))
  599. .OUTPUT(dh_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  600. .OUTPUT(dc_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  601. .OUTPUT(dgate, TensorType({DT_FLOAT16}))
  602. .OP_END_FACTORY_REG(LSTMInputGrad)
  603. /**
  604. *@brief: Dynamic LSTM Cell grad calculation.Calculate the gradient of gates and cell state.
  605. *@par Inputs:
  606. *twelve inputs:
  607. *@li init_c:A 4D Tensor. Must be one of the following types: float16, float32.
  608. *@li c:A 4D Tensor. Must be one of the following types: float16, float32.
  609. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32.
  610. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32.
  611. *@li dc:A 4D Tensor. Must be one of the following types: float16, float32.
  612. *@li i:A 4D Tensor. Must be one of the following types: float16, float32.
  613. *@li j:A 4D Tensor. Must be one of the following types: float16, float32.
  614. *@li f:A 4D Tensor. Must be one of the following types: float16, float32.
  615. *@li o:A 4D Tensor. Must be one of the following types: float16, float32.
  616. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32.
  617. *@li mask:A 4D Tensor. Must be one of the following types: float16, float32.
  618. *@li t_state:A 4D Tensor. Must be one of the following types: float16, float32. . \n
  619. *@par Attributes:
  620. *@li forget_bias:An integer identifying the forget bias in the op. Default to 1.
  621. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported . \n
  622. *@li direction:An string that marks the calculation sequence of the operator. Default to "Forward".
  623. *@li gate_order:An string mark the order of output 4 gate. Default to "ijfo".
  624. *@par Outputs:
  625. *two outputs:
  626. *@li dgate:A 4D Tensor. Must be one of the following types: float16.
  627. *@li dct_1:A 4D Tensor. Must be one of the following types: float16, float32.
  628. *@par Restrictions:
  629. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  630. */
  631. REG_OP(DynamicLSTMGradCell)
  632. .INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  633. .INPUT(c, TensorType({DT_FLOAT16, DT_FLOAT}))
  634. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  635. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  636. .INPUT(dc, TensorType({DT_FLOAT16, DT_FLOAT}))
  637. .INPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  638. .INPUT(j, TensorType({DT_FLOAT16, DT_FLOAT}))
  639. .INPUT(f, TensorType({DT_FLOAT16, DT_FLOAT}))
  640. .INPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  641. .INPUT(tanhct, TensorType({DT_FLOAT16, DT_FLOAT}))
  642. .INPUT(t_state, TensorType({DT_INT32, DT_INT32}))
  643. .INPUT(mask, TensorType({DT_FLOAT16, DT_FLOAT}))
  644. .OUTPUT(dgate, TensorType({DT_FLOAT16, DT_FLOAT}))
  645. .OUTPUT(dct_1, TensorType({DT_FLOAT16, DT_FLOAT}))
  646. .ATTR(forget_bias, Float, 1.0)
  647. .ATTR(activation, String, "tanh")
  648. .ATTR(direction, String, "UNIDIRECTIONAL")
  649. .ATTR(gate_order, String, "ijfo")
  650. .OP_END_FACTORY_REG(DynamicLSTMGradCell)
  651. /**
  652. *@brief: Basic LSTM Cell backward calculation.Calculate the gradient of input and hidden state.
  653. *@par Inputs:
  654. *three inputs:
  655. *@li dgate:A 4D Tensor. Must be one of the following types: float16.
  656. *@li w:A 4D Tensor. Must be one of the following types: float16.
  657. *@li dropout_mask:A 1D Tensor. Must be one of the following types: uint8. The format must be ND . \n
  658. *@par Attributes:
  659. *keep_prob:An integer identifying the keep prob in the op. Default to 1 . \n
  660. *@par Outputs:
  661. *two outputs:
  662. *@li dxt:A 4D Tensor. Must be one of the following types: float16, float32.
  663. *@li dht:A 4D Tensor. Must be one of the following types: float16, float32.
  664. *@par Restrictions:
  665. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  666. */
  667. REG_OP(BasicLSTMCellInputGrad)
  668. .INPUT(dgate, TensorType({DT_FLOAT16}))
  669. .INPUT(w, TensorType({DT_FLOAT16}))
  670. .OPTIONAL_INPUT(dropout_mask, TensorType({DT_UINT8}))
  671. .OUTPUT(dxt, TensorType({DT_FLOAT16, DT_FLOAT32}))
  672. .OUTPUT(dht, TensorType({DT_FLOAT16, DT_FLOAT32}))
  673. .ATTR(keep_prob, Float, 1.0)
  674. .OP_END_FACTORY_REG(BasicLSTMCellInputGrad)
  675. /**
  676. *@brief: Basic LSTM Cell backward calculation.Calculate the gradient of weight and bias.
  677. *@par Inputs:
  678. *three inputs:
  679. *@li x:A 4D Tensor. Must be one of the following types: float16.
  680. *@li h:A 4D Tensor. Must be one of the following types: float16.
  681. *@li dgate:A 4D Tensor. Must be one of the following types: uint8. \n
  682. *@par Outputs:
  683. *two outputs:
  684. *@li dw:A 4D Tensor. Must be one of the following types: float16.
  685. *@li db:A 4D Tensor. Must be one of the following types: float16, float32.
  686. *@par Restrictions:
  687. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  688. */
  689. REG_OP(BasicLSTMCellWeightGrad)
  690. .INPUT(x, TensorType({DT_FLOAT16}))
  691. .INPUT(h, TensorType({DT_FLOAT16}))
  692. .INPUT(dgate, TensorType({DT_FLOAT16}))
  693. .OUTPUT(dw, TensorType({DT_FLOAT16}))
  694. .OUTPUT(db, TensorType({DT_FLOAT16, DT_FLOAT32}))
  695. .OP_END_FACTORY_REG(BasicLSTMCellWeightGrad)
  696. /**
  697. *@brief: Basic LSTM Cell backward calculation.Calculate the gradient of gates and cell state.
  698. *@par Inputs:
  699. *eight inputs:
  700. *@li c:A 4D Tensor. Must be one of the following types: float16, float32.
  701. *@li dht:A 4D Tensor. Must be one of the following types: float16, float32.
  702. *@li dct:A 4D Tensor. Must be one of the following types: float16, float32.
  703. *@li it:A 4D Tensor. Must be one of the following types: float16, float32.
  704. *@li jt:A 4D Tensor. Must be one of the following types: float16, float32.
  705. *@li ft:A 4D Tensor. Must be one of the following types: float16, float32.
  706. *@li ot:A 4D Tensor. Must be one of the following types: float16, float32.
  707. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32. \n
  708. *@par Attributes:
  709. *@li forget_bias:An integer identifying the forget bias in the op. Default to 1.
  710. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported . \n
  711. *@par Outputs:
  712. *two outputs:
  713. *@li dgate:A 4D Tensor. Must be one of the following types: float16.
  714. *@li dct_1:A 4D Tensor. Must be one of the following types: float16, float32.
  715. *@par Restrictions:
  716. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  717. */
  718. REG_OP(BasicLSTMCellCStateGrad)
  719. .INPUT(c, TensorType({DT_FLOAT16, DT_FLOAT}))
  720. .INPUT(dht, TensorType({DT_FLOAT16, DT_FLOAT}))
  721. .INPUT(dct, TensorType({DT_FLOAT16, DT_FLOAT}))
  722. .INPUT(it, TensorType({DT_FLOAT16, DT_FLOAT}))
  723. .INPUT(jt, TensorType({DT_FLOAT16, DT_FLOAT}))
  724. .INPUT(ft, TensorType({DT_FLOAT16, DT_FLOAT}))
  725. .INPUT(ot, TensorType({DT_FLOAT16, DT_FLOAT}))
  726. .INPUT(tanhct, TensorType({DT_FLOAT16, DT_FLOAT}))
  727. .OUTPUT(dgate, TensorType({DT_FLOAT16}))
  728. .OUTPUT(dct_1, TensorType({DT_FLOAT16, DT_FLOAT}))
  729. .ATTR(forget_bias, Float, 1.0)
  730. .ATTR(activation, String, "tanh")
  731. .OP_END_FACTORY_REG(BasicLSTMCellCStateGrad)
  732. /**
  733. *@brief: RNN operator.
  734. *@par Inputs:
  735. *eight inputs:
  736. *@li x:A 4D Tensor. Must be one of the following types: float16.
  737. *@li cont:A 1D Tensor. Must be one of the following types: float16. The format must be ND.
  738. *@li x_static:A 4D Tensor. Must be one of the following types: float16.
  739. *@li h_0:A 4D Tensor. Must be one of the following types: float16, float32.
  740. *@li w_xh:A 4D Tensor. Must be one of the following types: float16.
  741. *@li w_sh:A 4D Tensor. Must be one of the following types: float16.
  742. *@li w_hh:A 4D Tensor. Must be one of the following types: float16.
  743. *@li w_ho:A 4D Tensor. Must be one of the following types: float16.
  744. *@li bias_h:A 1D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  745. *@li bias_o:A 1D Tensor. Must be one of the following types: float16, float32. The format must be ND . \n
  746. *@par Attributes:
  747. *@li expose_hidden:An bool identifying if expose the hidden state of last time step. Default to false.
  748. *@li num_output:An integer identifying the number of output features. Default to 0 . \n
  749. *@par Outputs:
  750. *two outputs:
  751. *@li o:A 4D Tensor. Must be one of the following types: float16, float32.
  752. *@li h_t:A 4D Tensor. Must be one of the following types: float16, float32.
  753. *@par Restrictions:
  754. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  755. */
  756. REG_OP(RNN)
  757. .INPUT(x, TensorType({DT_FLOAT16}))
  758. .INPUT(cont, TensorType({DT_FLOAT16}))
  759. .OPTIONAL_INPUT(x_static, TensorType({DT_FLOAT16}))
  760. .OPTIONAL_INPUT(h_0, TensorType({DT_FLOAT16, DT_FLOAT}))
  761. .INPUT(w_xh, TensorType({DT_FLOAT16}))
  762. .INPUT(bias_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  763. .OPTIONAL_INPUT(w_sh, TensorType({DT_FLOAT16}))
  764. .INPUT(w_hh, TensorType({DT_FLOAT16}))
  765. .INPUT(w_ho, TensorType({DT_FLOAT16}))
  766. .INPUT(bias_o, TensorType({DT_FLOAT16, DT_FLOAT}))
  767. .OUTPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  768. .OUTPUT(h_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  769. .ATTR(num_output, Int, 0)
  770. .ATTR(expose_hidden, Bool, false)
  771. .OP_END_FACTORY_REG(RNN)
  772. /**
  773. *@brief: BasicRNNCell operator.
  774. *@par Inputs:
  775. *eight inputs:
  776. *@li x:A 4D Tensor. Must be one of the following types: float16.
  777. *@li cont:A 1D Tensor. Must be one of the following types: float16. The format must be ND.
  778. *@li w_xh_x_static:A 4D Tensor. Must be one of the following types: float16.
  779. *@li h_0:A 4D Tensor. Must be one of the following types: float16, float32.
  780. *@li w_xh:A 4D Tensor. Must be one of the following types: float16.
  781. *@li w_hh:A 4D Tensor. Must be one of the following types: float16.
  782. *@li w_ho:A 4D Tensor. Must be one of the following types: float16.
  783. *@li bias_h:A 1D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  784. *@li bias_o:A 1D Tensor. Must be one of the following types: float16, float32. The format must be ND . \n
  785. *@par Attributes:
  786. *@li expose_hidden:An bool identifying if expose the hidden state of last time step. Default to false.
  787. *@li num_output:An integer identifying the number of output features. Default to 0 . \n
  788. *@par Outputs:
  789. *two outputs:
  790. *@li o_t:A 4D Tensor. Must be one of the following types: float16, float32.
  791. *@li h_t:A 4D Tensor. Must be one of the following types: float16, float32.
  792. *@par Restrictions:
  793. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  794. */
  795. REG_OP(BasicRNNCell)
  796. .INPUT(x, TensorType({DT_FLOAT16}))
  797. .OPTIONAL_INPUT(cont, TensorType({DT_FLOAT16}))
  798. .OPTIONAL_INPUT(w_xh_x_static, TensorType({DT_FLOAT16, DT_FLOAT}))
  799. .OPTIONAL_INPUT(h_0, TensorType({DT_FLOAT16, DT_FLOAT}))
  800. .INPUT(w_xh, TensorType({DT_FLOAT16}))
  801. .INPUT(bias_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  802. .OPTIONAL_INPUT(w_hh, TensorType({DT_FLOAT16}))
  803. .INPUT(w_ho, TensorType({DT_FLOAT16}))
  804. .INPUT(bias_o, TensorType({DT_FLOAT16, DT_FLOAT}))
  805. .OUTPUT(o_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  806. .OUTPUT(h_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  807. .ATTR(expose_hidden, Bool, false)
  808. .ATTR(num_output, Int, 0)
  809. .OP_END_FACTORY_REG(BasicRNNCell)
  810. /**
  811. *@brief DynamicGRU calculation.
  812. *@par Inputs:
  813. *seven inputs:
  814. *@li x:Must be one of the following types: float16.
  815. *@li w:Must be one of the following types: float16.
  816. *@li b:Must be one of the following types: float16, float32. The format must be ND.
  817. *@li cw:Must be one of the following types: float16.
  818. *@li cb:Must be one of the following types: float16, float32. The format must be ND.
  819. *@li seq_length:Must be one of the following types: int32. The format must be ND.
  820. *@li init_h:Must be one of the following types: float16, float32.
  821. *@par Attributes:
  822. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported.
  823. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  824. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  825. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  826. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  827. *@li time_major:An bool identifying the time major in the op. Default to true.
  828. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported.
  829. *@li is_training:An bool identifying is training in the op. Default to true.
  830. *@par Outputs:
  831. *five outputs:
  832. *@li y:Must be one of the following types: float16, float32.
  833. *@li output_h:Must be one of the following types: float16, float32.
  834. *@li r:Must be one of the following types: float16, float32.
  835. *@li i:Must be one of the following types: float16, float32.
  836. *@li n:Must be one of the following types: float16, float32.
  837. *@par Restrictions:
  838. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  839. */
  840. REG_OP(DynamicGRU)
  841. .INPUT(x, TensorType({DT_FLOAT16}))
  842. .INPUT(w, TensorType({DT_FLOAT16}))
  843. .INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  844. .INPUT(cw, TensorType({DT_FLOAT16}))
  845. .INPUT(cb, TensorType({DT_FLOAT16, DT_FLOAT}))
  846. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32}))
  847. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  848. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  849. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  850. .OUTPUT(r, TensorType({DT_FLOAT16, DT_FLOAT}))
  851. .OUTPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  852. .OUTPUT(n, TensorType({DT_FLOAT16, DT_FLOAT}))
  853. .ATTR(direction, String, "UNIDIRECTIONAL")
  854. .ATTR(cell_depth, Int, 1)
  855. .ATTR(keep_prob, Float, 1.0)
  856. .ATTR(cell_clip, Float, -1.0)
  857. .ATTR(num_proj, Int, 0)
  858. .ATTR(time_major, Bool, true)
  859. .ATTR(activation, String, "tanh")
  860. .ATTR(is_training, Bool, true)
  861. .OP_END_FACTORY_REG(DynamicGRU)
  862. /**
  863. *@brief DynamicGRUV2 calculation.
  864. *@par Inputs:
  865. *seven inputs:
  866. *@li x:Must be one of the following types: float16.
  867. *@li weight_input:Must be one of the following types: float16.
  868. *@li weight_hidden:Must be one of the following types: float16.
  869. *@li bias_input:Must be one of the following types: float16, float32. The format must be ND.
  870. *@li bias_hidden:Must be one of the following types: float16, float32. The format must be ND.
  871. *@li seq_length:Must be one of the following types: int32 in ND.
  872. *@li init_h:Must be one of the following types: float16, float32.
  873. *@par Attributes:
  874. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Support "UNIDIRECTIONAL" and "REDIRECTIONAL".
  875. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  876. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  877. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  878. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  879. *@li time_major:An bool identifying the time major in the op. Default to true.
  880. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported.
  881. *@li gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  882. *@li reset_after:An bool identifying whether to apply reset gate after matrix multiplication. Default to true.
  883. *@li is_training:An bool identifying is training in the op. Default to true.
  884. *@par Outputs:
  885. *six outputs:
  886. *@li y:Must be one of the following types: float16, float32.
  887. *@li output_h:Must be one of the following types: float16, float32.
  888. *@li update:Must be one of the following types: float16, float32.
  889. *@li reset:Must be one of the following types: float16, float32.
  890. *@li new:Must be one of the following types: float16, float32.
  891. *@li hidden_new:Must be one of the following types: float16, float32.
  892. */
  893. REG_OP(DynamicGRUV2)
  894. .INPUT(x, TensorType({DT_FLOAT16}))
  895. .INPUT(weight_input, TensorType({DT_FLOAT16}))
  896. .INPUT(weight_hidden, TensorType({DT_FLOAT16}))
  897. .OPTIONAL_INPUT(bias_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  898. .OPTIONAL_INPUT(bias_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  899. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32, DT_FLOAT16}))
  900. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  901. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  902. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  903. .OUTPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  904. .OUTPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  905. .OUTPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  906. .OUTPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  907. .ATTR(direction, String, "UNIDIRECTIONAL")
  908. .ATTR(cell_depth, Int, 1)
  909. .ATTR(keep_prob, Float, 1.0)
  910. .ATTR(cell_clip, Float, -1.0)
  911. .ATTR(num_proj, Int, 0)
  912. .ATTR(time_major, Bool, true)
  913. .ATTR(activation, String, "tanh")
  914. .ATTR(gate_order, String, "zrh")
  915. .ATTR(reset_after, Bool, true)
  916. .ATTR(is_training, Bool, true)
  917. .OP_END_FACTORY_REG(DynamicGRUV2)
  918. /**
  919. *@brief DynamicGRUV2Hidden calculation.
  920. *@par Inputs:
  921. *five inputs:
  922. *@li x_weight_input:Must be one of the following types: float32.
  923. *@li weight_hidden:Must be one of the following types: float16.
  924. *@li bias_hidden:Must be one of the following types: float16, float32. The format must be ND.
  925. *@li seq_length:Must be one of the following types: int32 in ND.
  926. *@li init_h:Must be one of the following types: float16, float32.
  927. *@par Attributes:
  928. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Support "UNIDIRECTIONAL" and "REDIRECTIONAL".
  929. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  930. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  931. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  932. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  933. *@li time_major:An bool identifying the time major in the op. Default to true.
  934. *@li activation:An string identifying the type of activation function in the op. Default to "tanh".
  935. Only tanh is currently supported.
  936. *@li gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  937. *@li reset_after:An bool identifying whether to apply reset gate after matrix multiplication. Default to true.
  938. *@li is_training:An bool identifying is training in the op. Default to true.
  939. *@par Outputs:
  940. *six outputs:
  941. *@li y:Must be one of the following types: float16, float32.
  942. *@li output_h:Must be one of the following types: float16, float32.
  943. *@li update:Must be one of the following types: float16, float32.
  944. *@li reset:Must be one of the following types: float16, float32.
  945. *@li new:Must be one of the following types: float16, float32.
  946. *@li hidden_new:Must be one of the following types: float16, float32.
  947. *@par Restrictions:
  948. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  949. */
  950. REG_OP(DynamicGRUV2Hidden)
  951. .INPUT(x_weight_input, TensorType({DT_FLOAT32}))
  952. .INPUT(weight_hidden, TensorType({DT_FLOAT16}))
  953. .OPTIONAL_INPUT(bias_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  954. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32, DT_FLOAT16}))
  955. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  956. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  957. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  958. .OUTPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  959. .OUTPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  960. .OUTPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  961. .OUTPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  962. .ATTR(direction, String, "UNIDIRECTIONAL")
  963. .ATTR(cell_depth, Int, 1)
  964. .ATTR(keep_prob, Float, 1.0)
  965. .ATTR(cell_clip, Float, -1.0)
  966. .ATTR(num_proj, Int, 0)
  967. .ATTR(time_major, Bool, true)
  968. .ATTR(activation, String, "tanh")
  969. .ATTR(gate_order, String, "zrh")
  970. .ATTR(reset_after, Bool, true)
  971. .ATTR(is_training, Bool, true)
  972. .OP_END_FACTORY_REG(DynamicGRUV2Hidden)
  973. /**
  974. *@brief DynamicAUGRU calculation.
  975. *@par Inputs:
  976. *eight inputs:
  977. *@li x:Must be one of the following types: float16.
  978. *@li weight_input:Must be one of the following types: float16.
  979. *@li weight_hidden:Must be one of the following types: float16.
  980. *@li weight_attr:Must be one of the following types: float16.
  981. *@li bias_input:Must be one of the following types: float16, float32. The format must be ND.
  982. *@li bias_hidden:Must be one of the following types: float16, float32. The format must be ND.
  983. *@li seq_length:Must be one of the following types: int32 in ND.
  984. *@li init_h:Must be one of the following types: float16, float32.
  985. *@par Attributes:
  986. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported.
  987. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  988. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  989. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  990. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  991. *@li time_major:An bool identifying the time major in the op. Default to true.
  992. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported.
  993. *@li gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  994. *@li reset_after:An bool identifying whether to apply reset gate after matrix multiplication. Default to true.
  995. *@li is_training:An bool identifying is training in the op. Default to true.
  996. *@par Outputs:
  997. *seven outputs:
  998. *@li y:Must be one of the following types: float16, float32.
  999. *@li output_h:Must be one of the following types: float16, float32.
  1000. *@li update:Must be one of the following types: float16, float32.
  1001. *@li update_att:Must be one of the following types: float16, float32.
  1002. *@li reset:Must be one of the following types: float16, float32.
  1003. *@li new:Must be one of the following types: float16, float32.
  1004. *@li hidden_new:Must be one of the following types: float16, float32.
  1005. */
  1006. REG_OP(DynamicAUGRU)
  1007. .INPUT(x, TensorType({DT_FLOAT16}))
  1008. .INPUT(weight_input, TensorType({DT_FLOAT16}))
  1009. .INPUT(weight_hidden, TensorType({DT_FLOAT16}))
  1010. .INPUT(weight_att, TensorType({DT_FLOAT16}))
  1011. .OPTIONAL_INPUT(bias_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  1012. .OPTIONAL_INPUT(bias_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  1013. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32, DT_FLOAT16}))
  1014. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1015. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1016. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1017. .OUTPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  1018. .OUTPUT(update_att, TensorType({DT_FLOAT16, DT_FLOAT}))
  1019. .OUTPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  1020. .OUTPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1021. .OUTPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1022. .ATTR(direction, String, "UNIDIRECTIONAL")
  1023. .ATTR(cell_depth, Int, 1)
  1024. .ATTR(keep_prob, Float, 1.0)
  1025. .ATTR(cell_clip, Float, -1.0)
  1026. .ATTR(num_proj, Int, 0)
  1027. .ATTR(time_major, Bool, true)
  1028. .ATTR(activation, String, "tanh")
  1029. .ATTR(gate_order, String, "zrh")
  1030. .ATTR(reset_after, Bool, true)
  1031. .ATTR(is_training, Bool, true)
  1032. .OP_END_FACTORY_REG(DynamicAUGRU)
  1033. /**
  1034. *@brief: DynamicAUGRUGrad calculation.
  1035. *@par Inputs:
  1036. *sixteen inputs: \n
  1037. *@li x:A 4D Tensor. Must be one of the following types: float16, float32.
  1038. *@li weight_input:A 4D Tensor. Must be one of the following types: float16, float32.
  1039. *@li weight_hidden:A 4D Tensor. Must be one of the following types: float16, float32.
  1040. *@li weight_att:A 4D Tensor. Must be one of the following types: float16, float32.
  1041. *@li y:A 4D Tensor. Must be one of the following types: float16, float32.
  1042. *@li init_h:A 4D Tensor. Must be one of the following types: float16, float32.
  1043. *@li h:A 4D Tensor. Must be one of the following types: float16, float32.
  1044. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32.
  1045. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32.
  1046. *@li update:A 4D Tensor. Must be one of the following types: float16, float32.
  1047. *@li update_att:A 4D Tensor. Must be one of the following types: float16, float32.
  1048. *@li reset:A 4D Tensor. Must be one of the following types: float16, float32.
  1049. *@li new:A 4D Tensor. Must be one of the following types: float16, float32.
  1050. *@li hidden_new:A 4D Tensor. Must be one of the following types: float16, float32.
  1051. *@li seq_length:A 4D Tensor. Must be one of the following types: float16, float32.
  1052. *@li mask:A 4D Tensor. Must be one of the following types: float16, float32.
  1053. *@par Attributes:
  1054. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported.
  1055. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  1056. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  1057. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  1058. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  1059. *@li time_major:An bool identifying the time major in the op. Default to true.
  1060. *@li gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  1061. *@li reset_after:An bool identifying whether to apply reset gate after matrix multiplication. Default to true.
  1062. *@par Outputs:
  1063. *seven outputs: \n
  1064. *@li dw_input:A 4D Tensor. Must be one of the following types: float16, float32.
  1065. *@li dw_hidden:A 4D Tensor. Must be one of the following types: float16, float32.
  1066. *@li db_input:A 4D Tensor. Must be one of the following types: float16, float32.
  1067. *@li db_hidden:A 4D Tensor. Must be one of the following types: float16, float32.
  1068. *@li dx:A 4D Tensor. Must be one of the following types: float16, float32.
  1069. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32.
  1070. *@li dw_att:A 4D Tensor. Must be one of the following types: float16, float32.
  1071. *@par Restrictions:
  1072. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1073. */
  1074. REG_OP(DynamicAUGRUGrad)
  1075. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1076. .INPUT(weight_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  1077. .INPUT(weight_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  1078. .INPUT(weight_att, TensorType({DT_FLOAT16, DT_FLOAT}))
  1079. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1080. .INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1081. .INPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1082. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  1083. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  1084. .INPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  1085. .INPUT(update_att, TensorType({DT_FLOAT16, DT_FLOAT}))
  1086. .INPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  1087. .INPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1088. .INPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1089. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32}))
  1090. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  1091. .OUTPUT(dw_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  1092. .OUTPUT(dw_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  1093. .OUTPUT(db_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  1094. .OUTPUT(db_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  1095. .OUTPUT(dx, TensorType({DT_FLOAT16, DT_FLOAT}))
  1096. .OUTPUT(dh_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  1097. .OUTPUT(dw_att, TensorType({DT_FLOAT16, DT_FLOAT}))
  1098. .ATTR(direction, String, "UNIDIRECTIONAL")
  1099. .ATTR(cell_depth, Int, 1)
  1100. .ATTR(keep_prob, Float, -1.0)
  1101. .ATTR(cell_clip, Float, -1.0)
  1102. .ATTR(num_proj, Int, 0)
  1103. .ATTR(time_major, Bool, true)
  1104. .ATTR(gate_order, String, "zrh")
  1105. .ATTR(reset_after, Bool, true)
  1106. .OP_END_FACTORY_REG(DynamicAUGRUGrad)
  1107. /**
  1108. *@brief: AUGRUHiddenGrad calculation.
  1109. *@par Inputs:
  1110. *eleven inputs: \n
  1111. *@li weight_att:A 4D Tensor. Must be one of the following types: float16, float32.
  1112. *@li dh_pre_t:A 4D Tensor. Must be one of the following types: float16, float32.
  1113. *@li init_h:A 4D Tensor. Must be one of the following types: float16, float32.
  1114. *@li h:A 4D Tensor. Must be one of the following types: float16, float32.
  1115. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32.
  1116. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32.
  1117. *@li update:A 4D Tensor. Must be one of the following types: float16, float32.
  1118. *@li update_att:A 4D Tensor. Must be one of the following types: float16, float32.
  1119. *@li reset:A 4D Tensor. Must be one of the following types: float16, float32.
  1120. *@li new:A 4D Tensor. Must be one of the following types: float16, float32.
  1121. *@li hidden_new:A 4D Tensor. Must be one of the following types: float16, float32.
  1122. *@par Attributes:
  1123. *@li t_state:An Int identifying the current t state. Default to [0, 4].
  1124. *@li gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  1125. *@par Outputs:
  1126. *four outputs: \n
  1127. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32.
  1128. *@li dgate_h:A 4D Tensor. Must be one of the following types: float16, float32.
  1129. *@li dnt_x:A 4D Tensor. Must be one of the following types: float16, float32.
  1130. *@li dw_att_t:A 4D Tensor. Must be one of the following types: float16, float32.
  1131. *@par Restrictions:
  1132. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1133. */
  1134. REG_OP(AUGRUHiddenGradCell)
  1135. .INPUT(weight_att, TensorType({DT_FLOAT16, DT_FLOAT}))
  1136. .INPUT(dh_pre_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1137. .INPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1138. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  1139. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  1140. .INPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  1141. .INPUT(update_att, TensorType({DT_FLOAT16, DT_FLOAT}))
  1142. .INPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  1143. .INPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1144. .INPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1145. .OUTPUT(dh_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  1146. .OUTPUT(dgate_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1147. .OUTPUT(dnt_x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1148. .OUTPUT(dw_att_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1149. .ATTR(t_state, Int, 0)
  1150. .ATTR(gate_order, String, "zrh")
  1151. .OP_END_FACTORY_REG(AUGRUHiddenGradCell)
  1152. /**
  1153. *@brief: DynamicGRUV2Grad calculation.
  1154. *@par Inputs:
  1155. *fourteen inputs: \n
  1156. *@li x:A 4D Tensor. Must be one of the following types: float16, float32.
  1157. *@li weight_input:A 4D Tensor. Must be one of the following types: float16, float32.
  1158. *@li weight_hidden:A 4D Tensor. Must be one of the following types: float16, float32.
  1159. *@li y:A 4D Tensor. Must be one of the following types: float16, float32.
  1160. *@li init_h:A 4D Tensor. Must be one of the following types: float16, float32.
  1161. *@li h:A 4D Tensor. Must be one of the following types: float16, float32.
  1162. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32.
  1163. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32.
  1164. *@li update:A 4D Tensor. Must be one of the following types: float16, float32.
  1165. *@li reset:A 4D Tensor. Must be one of the following types: float16, float32.
  1166. *@li new:A 4D Tensor. Must be one of the following types: float16, float32.
  1167. *@li hidden_new:A 4D Tensor. Must be one of the following types: float16, float32.
  1168. *@li seq_length:A 4D Tensor. Must be one of the following types: float16, float32.
  1169. *@li mask:A 4D Tensor. Must be one of the following types: float16, float32.
  1170. *@par Attributes:
  1171. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported.
  1172. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  1173. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  1174. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  1175. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  1176. *@li time_major:An bool identifying the time major in the op. Default to true.
  1177. *@li gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  1178. *@li reset_after:An bool identifying whether to apply reset gate after matrix multiplication. Default to true.
  1179. *@par Outputs:
  1180. *six outputs: \n
  1181. *@li dw_input:A 4D Tensor. Must be one of the following types: float16, float32.
  1182. *@li dw_hidden:A 4D Tensor. Must be one of the following types: float16, float32.
  1183. *@li db_input:A 4D Tensor. Must be one of the following types: float16, float32.
  1184. *@li db_hidden:A 4D Tensor. Must be one of the following types: float16, float32.
  1185. *@li dx:A 4D Tensor. Must be one of the following types: float16, float32.
  1186. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32.
  1187. *@par Restrictions:
  1188. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1189. */
  1190. REG_OP(DynamicGRUV2Grad)
  1191. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1192. .INPUT(weight_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  1193. .INPUT(weight_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  1194. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1195. .INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1196. .INPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1197. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  1198. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  1199. .INPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  1200. .INPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  1201. .INPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1202. .INPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1203. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32}))
  1204. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  1205. .OUTPUT(dw_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  1206. .OUTPUT(dw_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  1207. .OUTPUT(db_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  1208. .OUTPUT(db_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  1209. .OUTPUT(dx, TensorType({DT_FLOAT16, DT_FLOAT}))
  1210. .OUTPUT(dh_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  1211. .ATTR(direction, String, "UNIDIRECTIONAL")
  1212. .ATTR(cell_depth, Int, 0)
  1213. .ATTR(keep_prob, Float, -1.0)
  1214. .ATTR(cell_clip, Float, -1.0)
  1215. .ATTR(num_proj, Int, 0)
  1216. .ATTR(time_major, Bool, true)
  1217. .ATTR(gate_order, String, "zrh")
  1218. .ATTR(reset_after, Bool, true)
  1219. .OP_END_FACTORY_REG(DynamicGRUV2Grad)
  1220. /**
  1221. *@brief: GRUV2HiddenGrad calculation.
  1222. *@par Inputs:
  1223. *nine inputs: \n
  1224. *@li dh_pre_t:A 4D Tensor. Must be one of the following types: float16, float32.
  1225. *@li init_h:A 4D Tensor. Must be one of the following types: float16, float32.
  1226. *@li h:A 4D Tensor. Must be one of the following types: float16, float32.
  1227. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32.
  1228. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32.
  1229. *@li update:A 4D Tensor. Must be one of the following types: float16, float32.
  1230. *@li reset:A 4D Tensor. Must be one of the following types: float16, float32.
  1231. *@li new:A 4D Tensor. Must be one of the following types: float16, float32.
  1232. *@li hidden_new:A 4D Tensor. Must be one of the following types: float16, float32.
  1233. *@par Attributes:
  1234. *@li t_state:An Int identifying the current t state. Default to [0, 4].
  1235. *@li gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  1236. *@par Outputs:
  1237. *three outputs: \n
  1238. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32.
  1239. *@li dgate_h:A 4D Tensor. Must be one of the following types: float16, float32.
  1240. *@li dnt_x:A 4D Tensor. Must be one of the following types: float16, float32.
  1241. *@par Restrictions:
  1242. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1243. */
  1244. REG_OP(GRUV2HiddenGradCell)
  1245. .INPUT(dh_pre_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1246. .INPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1247. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  1248. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  1249. .INPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  1250. .INPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  1251. .INPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1252. .INPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1253. .OUTPUT(dh_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  1254. .OUTPUT(dgate_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1255. .OUTPUT(dnt_x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1256. .ATTR(t_state, Int, 0)
  1257. .ATTR(gate_order, String, "zrh")
  1258. .OP_END_FACTORY_REG(GRUV2HiddenGradCell)
  1259. /**
  1260. *@brief: DynamicGRUCellGrad calculation.
  1261. *@par Inputs:
  1262. *ten inputs: \n
  1263. *@li dh_pre_t:A 4D Tensor. Must be one of the following types: float16, float32.
  1264. *@li h:A 4D Tensor. Must be one of the following types: float16, float32.
  1265. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32.
  1266. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32.
  1267. *@li update:A 4D Tensor. Must be one of the following types: float16, float32.
  1268. *@li reset:A 4D Tensor. Must be one of the following types: float16, float32.
  1269. *@li new:A 4D Tensor. Must be one of the following types: float16, float32.
  1270. *@li hidden_new:A 4D Tensor. Must be one of the following types: float16, float32.+
  1271. *@li init_h:A 4D Tensor. Must be one of the following types: float16, float32.
  1272. *@li t_state:A 1D Tensor. Must be one of the following types: int32. The format must be ND.
  1273. *@par Attributes:
  1274. *gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  1275. *@par Outputs:
  1276. *three outputs: \n
  1277. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32.
  1278. *@li dgate_h:A 4D Tensor. Must be one of the following types: float16, float32.
  1279. *@li dnt_x:A 4D Tensor. Must be one of the following types: float16, float32.
  1280. *@par Restrictions:
  1281. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1282. */
  1283. REG_OP(DynamicGRUCellGrad)
  1284. .INPUT(dh_pre_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1285. .INPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1286. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  1287. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  1288. .INPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  1289. .INPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  1290. .INPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1291. .INPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1292. .INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1293. .INPUT(t_state, TensorType({DT_INT32, DT_INT32}))
  1294. .OUTPUT(dh_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  1295. .OUTPUT(dgate_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1296. .OUTPUT(dnt_x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1297. .ATTR(gate_order, String, "zrh")
  1298. .OP_END_FACTORY_REG(DynamicGRUCellGrad)
  1299. /**
  1300. * @brief Calculates the reversed outputs of the function "embedding". \n
  1301. * @par Inputs:
  1302. * Two inputs, including:
  1303. * @li grad: A mutable Tensor of word grad. Must be one of the following types:
  1304. * float32.
  1305. * @li indices: A mutable word index Tensor of the int32 type.\n
  1306. * @par Attributes:
  1307. * @li num_weights: An int attr which use to judge how many words in dict. \n
  1308. * @li padding_idx: An int attr judge which word to fill zeros. Defaults to "-1". \n
  1309. * @li scale_grad_by_freq: An optional bool. Defaults to "False".
  1310. * If "True", "grad_weight" will be scale by word_frequency.
  1311. * If "False", "grad_weight" will not be scale by word_frequency. \n
  1312. * @par Outputs:
  1313. * y: A mutable output Tensor of new word grad has the same type as "grads". \n
  1314. * @par Third-party framework compatibility
  1315. * Compatible with the Pytorch operator EmbeddingDenseGrad.
  1316. */
  1317. REG_OP(EmbeddingDenseGrad)
  1318. .INPUT(grad, TensorType({ DT_FLOAT32 })) /* "First operand." */
  1319. .INPUT(indices, TensorType({ DT_INT32 })) /* "Second operand." */
  1320. .OUTPUT(y, TensorType({ DT_FLOAT32 })) /* "Result, has same element type as two inputs" */
  1321. .REQUIRED_ATTR(num_weights, Int)
  1322. .ATTR(padding_idx, Int, -1)
  1323. .ATTR(scale_grad_by_freq, Bool, false)
  1324. .OP_END_FACTORY_REG(EmbeddingDenseGrad)
  1325. /**
  1326. *@brief CommonLSTM calculation.
  1327. *@par Inputs:
  1328. *eight inputs: \n
  1329. *@li x:Each time step is a 4D Tensor. Must be one of the following types: float16, float32.
  1330. *@li w:Each direction is a 4D Tensor. Must be one of the following types: float16, float32.
  1331. *@li r:Each direction is a 4D Tensor. Must be one of the following types: float16, float32.
  1332. *@li b:An optional input. Each direction is a 1D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  1333. *@li sequence_lens:An optional input. A 1D Tensor.Must be one of the following types: int32. The format must be ND.
  1334. *@li initial_h:An optional input. Each direction is a 4D Tensor. Must be one of the following types: float16, float32.
  1335. *@li initial_c:An optional input. Each direction is a 4D Tensor. Must be one of the following types: float16, float32.
  1336. *@li p:An optional input. Each direction is a 1D Tensor.Must be one of the following types: float16, float32. The format must be ND.
  1337. *@par Attributes:
  1338. *@li activation_alpha:Optional scaling values used by some activation functions. Empty is currently supported.
  1339. *@li activation_beta:Optional scaling values used by some activation functions. Empty is currently supported.
  1340. *@li activations:The list of activation functions. Empty is currently supported.
  1341. *@li clip:An float identifying the cell clip in the op. Default to -1.
  1342. *@li direction:Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward(default), reverse, or bidirectional.
  1343. *@li hidden_size:Number of neurons in the hidden layer. Reserved.
  1344. *@li input_forget:Couple the input and forget gates if 1. Reserved.
  1345. *@par Outputs:
  1346. *three outputs: \n
  1347. *@li y:First dimension is time step, second dimension is direction, others is a 4D Tensor. Must be one of the following types: float16, float32.
  1348. *@li y_h:Each direction is a 4D Tensor. Must be one of the following types: float16, float32.
  1349. *@li y_c:Each direction is a 4D Tensor. Must be one of the following types: float16, float32.
  1350. */
  1351. REG_OP(CommonLSTM)
  1352. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1353. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  1354. .INPUT(r, TensorType({DT_FLOAT16, DT_FLOAT}))
  1355. .OPTIONAL_INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  1356. .OPTIONAL_INPUT(sequence_lens, TensorType({DT_INT32}))
  1357. .OPTIONAL_INPUT(initial_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1358. .OPTIONAL_INPUT(initial_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  1359. .OPTIONAL_INPUT(p, TensorType({DT_FLOAT16, DT_FLOAT}))
  1360. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1361. .OUTPUT(y_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1362. .OUTPUT(y_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  1363. .ATTR(activation_alpha, ListFloat, {})
  1364. .ATTR(activation_beta, ListFloat, {})
  1365. .ATTR(activations, ListString, {})
  1366. .ATTR(clip, Float, -1.0)
  1367. .ATTR(direction, String, "forward")
  1368. .REQUIRED_ATTR(hidden_size, Int)
  1369. .ATTR(input_forget, Int, 0)
  1370. .OP_END_FACTORY_REG(CommonLSTM)
  1371. /**
  1372. * @brief Calculate the mask. According to hidden_size and num_step, convert seq_length to mask.
  1373. *
  1374. * @par Inputs:
  1375. * @li seq_length: A 1D Tensor. Must be one of the following types: int32. Record the current length of each batch. [batch_size].
  1376. * @li x: A 3D Tensor. Must be one of the following types: fp16/fp32. Record the num_step/batch_size/input_size. [num_step, batch_size, input_size].
  1377. * @li hidden_size: An optional attribute of type int32. pass the hidden_size. \n
  1378. *
  1379. * @par Outputs:
  1380. * seq_mask: A 3D Tensor. Must be one of the following types: fp16/fp32. with the shape of [num_step, batch_size, hidden_size]. And has the same type as "b" \n
  1381. *
  1382. * @par Restrictions:
  1383. * Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1384. */
  1385. REG_OP(RnnGenMaskV2)
  1386. .INPUT(seq_length, TensorType({DT_INT32}))
  1387. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1388. .REQUIRED_ATTR(hidden_size, Int)
  1389. .OUTPUT(seq_mask, TensorType({DT_FLOAT16, DT_FLOAT}))
  1390. .OP_END_FACTORY_REG(RnnGenMaskV2)
  1391. /**
  1392. * @brief Common GRU calculation.
  1393. * @par Inputs:
  1394. * Eight inputs, including:
  1395. * @li x: The input sequences packed (and pontentially padded) into on 3D Tesnor(float16).
  1396. * @li w: The weight tensor for the gates is 3D Tensor(float16).
  1397. * @li r: The recurrence weight tesnor is 3D Tensor(float16).
  1398. * @li b: The bias tensor for the gates. The format must be ND
  1399. * @li sequence_lens: Optional tensor specifying lengths of sequences(int32). The format must be ND
  1400. * @li init_h: Optional initial value of the hidden(float16,float32).
  1401. * @par Attributes:
  1402. * @li activation_alpha: Optional scaling values used by some activation functions. \n
  1403. * @li activation_beta: Optional scaling values used by some activation functions. \n
  1404. * @li activations: A list of 2 (or 4 if bidirectional) activation functions for update, reset, and hidden gates. \n
  1405. * @li clip: Cell clip threshold. \n
  1406. * @li direction: Specify if the RNN is forward, reverse, or bidirectional. \n
  1407. * @li hidden_size: Number of neurons in the hidden layer. \n
  1408. * @li linear_before_reset: When computing the output of the hidden gate, apply the linear transformation before multiplying by the output of the reset gate. \n
  1409. * @par Outputs:
  1410. * @li y: A Tensor that concats all the intermediate output values of the hidden(float16,float32).
  1411. * @li y_h: The last output value of the hidden(float16,float32).
  1412. */
  1413. REG_OP(CommonGRU)
  1414. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1415. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  1416. .INPUT(r, TensorType({DT_FLOAT16, DT_FLOAT}))
  1417. .OPTIONAL_INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  1418. .OPTIONAL_INPUT(sequence_lens, TensorType({DT_INT32}))
  1419. .OPTIONAL_INPUT(initial_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1420. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1421. .OUTPUT(y_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1422. .ATTR(activation_alpha, ListFloat, {})
  1423. .ATTR(activation_beta , ListFloat, {})
  1424. .ATTR(activations , ListString, {})
  1425. .ATTR(clip, Float, -1.0)
  1426. .ATTR(direction, String, "forward")
  1427. .REQUIRED_ATTR(hidden_size, Int)
  1428. .ATTR(linear_before_reset , Int, 0)
  1429. .OP_END_FACTORY_REG(CommonGRU)
  1430. /**
  1431. * @brief Calculates the reversed outputs of the function "embedding". \n
  1432. * @par Inputs:
  1433. * Four inputs, including:
  1434. * @li weight: A mutable Tensor of word grad. Must be one of the following types:
  1435. * float32.
  1436. * @li indices: A mutable word index Tensor of the int32 type.\n
  1437. * @li offsets: A mutable word index Tensor of the int32 type.\n
  1438. * @li per_sample_weights: to indicate all weights should be taken to be 1.
  1439. * If specified, per_sample_weights must have exactly the same shape as input
  1440. * and is treated as having the same offsets, if those are not None.
  1441. * Only supported for mode='sum'.\n
  1442. * @par Attributes:
  1443. * @li mode: An string attr which use "sum"``, ``"mean"`` or ``"max"``. Specifies the way to reduce the bag. \n
  1444. * @li scale_grad_by_freq: An optional bool. Defaults to "False".
  1445. * If "True", "grad_weight" will be scale by word_frequency.
  1446. * If "False", "grad_weight" will not be scale by word_frequency. \n
  1447. * @li sparse: if True, gradient w.r.t.attr weight matrix will be a sparse tensor. \n
  1448. * @li include_last_offset: if True, attr offsets has one additional element, where the last element
  1449. * is equivalent to the size of indices. This matches the CSR format. \n
  1450. * @par Outputs:
  1451. * y: A mutable output Tensor of new word grad has the same type as "grads". \n
  1452. * @par Third-party framework compatibility
  1453. * Compatible with the Pytorch operator EmbeddingBag.
  1454. */
  1455. REG_OP(EmbeddingBag)
  1456. .INPUT(weight, TensorType({ DT_FLOAT32 }))
  1457. .INPUT(indices, TensorType({ DT_INT32 }))
  1458. .OPTIONAL_INPUT(offsets, TensorType({DT_INT32}))
  1459. .OPTIONAL_INPUT(per_sample_weights, TensorType({DT_FLOAT32}))
  1460. .OUTPUT(y, TensorType({ DT_FLOAT32 }))
  1461. .ATTR(mode, String, "mean")
  1462. .ATTR(scale_grad_by_freq, Bool, false)
  1463. .ATTR(sparse, Bool, false)
  1464. .ATTR(include_last_offset, Bool, false)
  1465. .OP_END_FACTORY_REG(EmbeddingBag)
  1466. /**
  1467. * @brief:LSTMP calculation
  1468. * @par Inputs:
  1469. * eight inputs:
  1470. * @li x:A required Tensor(seq, batch, dim). Must be one of the following types: float16, float32.
  1471. * @li real_mask:A optional Tensor(seq, batch). Must be one of the following types: float16, float32.
  1472. * @li init_h:A optional Tensor(batch, state). Must be one of the following types: float16, float32.
  1473. * @li init_c:A optional Tensor(batch, hidden). Must be one of the following types: float16, float32.
  1474. * @li wx:A required Tensor(4*hidden, dim). Must be one of the following types: float16, float32.
  1475. * @li wr:A required Tensor(4*hidden, state). Must be one of the following types: float16, float32.
  1476. * @li bias:A optional Tensor(hidden). Must be one of the following types: float16, float32. The format must be ND.
  1477. * @li project: A optional Tensor. Must be one of the following types: float16, float32.
  1478. *
  1479. * @par Outputs:
  1480. *three outputs:
  1481. *@li y:A Tensor. Must be one of the following types: float16, float32.
  1482. *@li output_h:A Tensor. Must be one of the following types: float16, float32.
  1483. *@li output_c:A Tensor. Must be one of the following types: float16, float32.
  1484. *
  1485. *@par Attributes:
  1486. *time_major:An bool identifying the time major in the op. Default to false.
  1487. * @par Restrictions:
  1488. * Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1489. */
  1490. REG_OP(LSTMP)
  1491. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1492. .INPUT(wx, TensorType({DT_FLOAT16, DT_FLOAT}))
  1493. .INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT}))
  1494. .INPUT(wr, TensorType({DT_FLOAT16, DT_FLOAT}))
  1495. .INPUT(project, TensorType({DT_FLOAT16, DT_FLOAT}))
  1496. .OPTIONAL_INPUT(real_mask, TensorType({DT_FLOAT16, DT_FLOAT}))
  1497. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1498. .OPTIONAL_INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  1499. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1500. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1501. .OUTPUT(output_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  1502. .ATTR(time_major, Bool, false)
  1503. .OP_END_FACTORY_REG(LSTMP)
  1504. } // namespace ge
  1505. #endif // OPS_BUILT_IN_OP_PROTO_INC_RNN_H_

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