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 74 kB

5 years ago
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
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
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
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323
  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. The format must be FRACTAL_NZ.
  29. *@li h:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_NZ.
  30. *@li c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  31. *@li w:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_Z.
  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. The format must be FRACTAL_NZ.
  72. *@li w:A 4D Tensor. Must be the type float32. The format must be FRACTAL_Z.
  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. The format must be FRACTAL_Z.
  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. The format must be FRACTAL_NZ.
  90. *@li w:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  91. *@li b:A 1D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  92. *@li y:A 1D Tensor. Must be one of the following types: int32. The format must be FRACTAL_NZ.
  93. *@li init_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  94. *@li init_c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  95. *@li h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  96. *@li c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  97. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  98. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  99. *@li dc:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  100. *@li i:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  101. *@li j:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  102. *@li f:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  103. *@li o:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  104. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  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. The format must be FRACTAL_NZ.
  108. *@li wcf:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  109. *@li wco:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  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. The format must be FRACTAL_NZ.
  123. *@li db:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  124. *@li dx:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  125. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  126. *@li dc_prev:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  127. *@li dwci:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  128. *@li dwcf:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  129. *@li dwco:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  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. The format must be FRACTAL_NZ.
  176. *@li w:A required 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  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 float16 in FRACTAL_NZ and int32 in ND.
  179. *@li init_h:A optional 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  180. *@li init_c:A optional 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  181. *@li wci:A 4D optional Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  182. *@li wcf:A 4D optional Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  183. *@li wco:A 4D optional Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  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. The format must be FRACTAL_NZ.
  201. *@li output_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  202. *@li output_c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  203. *@li i:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  204. *@li j:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  205. *@li f:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  206. *@li o:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  207. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  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. The format must be FRACTAL_NZ.
  248. *@li weight_input:A required 4D Tensor. Must be one of the following types: float16, float32.
  249. *The format must be FRACTAL_Z.
  250. *@li weight_hidden:A required 4D Tensor. Must be one of the following types: float16, float32.
  251. *The format must be FRACTAL_Z.
  252. *@li b:A required 1D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  253. *@li seq_length:A optional 1D Tensor. Must be one of the following types: int32. The format must be ND.
  254. *@li init_h:A optional 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  255. *@li init_c:A optional 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  256. *@li wci:A 4D optional Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  257. *@li wcf:A 4D optional Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  258. *@li wco:A 4D optional Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  259. *@li mask:A 1D optional Tensor. Must be one of the following types: uint8. The format must be ND . \n
  260. *@par Attributes:
  261. *@li cell_type:An string identifying the cell type in the op. Default to "LSTM". Only LSTM is currently supported.
  262. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL".
  263. *Only UNIDIRECTIONAL is currently supported.
  264. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  265. *@li use_peephole:An bool identifying if use peephole in the op. Default to false.
  266. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  267. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  268. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  269. *@li time_major:An bool identifying the time major in the op. Default to true.
  270. *@li activation:An string identifying the type of activation function in the op. Default to "tanh".
  271. *Support "tanh" and "clip".
  272. *@li recurrent_activation:An string identifying the type of activation function in the op. Default to "sigmoid".
  273. *Support "sigmoid" and "hard_sigmoid". In general, set "hard_sigmoid" for TF Keras LSTM.
  274. *@li forget_bias:An float identifying the forget bias in the op. Default to 0.
  275. *@li gate_order:An string identifying the type of gate order in the op. Support "ijfo" and "ifco". Default to "ijfo".
  276. *Set "ijfo" for TF operator LSTM, Set "ifco" for TF Keras LSTM.
  277. *@li stateful: An bool identifying the type of stateful in the op. Default to fasle.Only false is currently supported.
  278. *@li merge_mode: An string identifying the type of merge_modein the op. Default to "concat".
  279. *Only "concat" is currently supported
  280. *@li is_training:An bool identifying is training in the op. Default to true . \n
  281. *@par Outputs:
  282. *eight outputs:
  283. *@li y:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  284. *@li output_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  285. *Return the last output_h.
  286. *@li output_c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  287. *Return the last output_c.
  288. *@li i:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  289. *@li j:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  290. *@li f:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  291. *@li o:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  292. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  293. *@par Third-party framework compatibility:
  294. * Compatible with the TF operator LSTM or TF keras operator LSTM.
  295. */
  296. REG_OP(DynamicRNNV2)
  297. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  298. .INPUT(weight_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  299. .INPUT(weight_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  300. .OPTIONAL_INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  301. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32}))
  302. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  303. .OPTIONAL_INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  304. .OPTIONAL_INPUT(wci, TensorType({DT_FLOAT16, DT_FLOAT}))
  305. .OPTIONAL_INPUT(wcf, TensorType({DT_FLOAT16, DT_FLOAT}))
  306. .OPTIONAL_INPUT(wco, TensorType({DT_FLOAT16, DT_FLOAT}))
  307. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  308. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  309. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  310. .OUTPUT(output_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  311. .OUTPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  312. .OUTPUT(j, TensorType({DT_FLOAT16, DT_FLOAT}))
  313. .OUTPUT(f, TensorType({DT_FLOAT16, DT_FLOAT}))
  314. .OUTPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  315. .OUTPUT(tanhc, TensorType({DT_FLOAT16, DT_FLOAT}))
  316. .ATTR(cell_type, String, "LSTM")
  317. .ATTR(direction, String, "UNIDIRECTIONAL")
  318. .ATTR(cell_depth, Int, 1)
  319. .ATTR(use_peephole, Bool, false)
  320. .ATTR(keep_prob, Float, 1.0)
  321. .ATTR(cell_clip, Float, -1.0)
  322. .ATTR(num_proj, Int, 0)
  323. .ATTR(time_major, Bool, true)
  324. .ATTR(activation, String, "tanh")
  325. .ATTR(recurrent_activation, String, "sigmoid")
  326. .ATTR(forget_bias, Float, 0.0)
  327. .ATTR(gate_order, String, "ijfo")
  328. .ATTR(stateful, Bool, false)
  329. .ATTR(merge_mode, String, "concat")
  330. .ATTR(is_training, Bool, true)
  331. .OP_END_FACTORY_REG(DynamicRNNV2)
  332. /**
  333. *@brief: DynamicRNNV3 calculation.
  334. *@par Inputs:
  335. *ten inputs:
  336. *@li x:A required 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  337. *@li w:A required 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  338. *@li b:A required 1D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  339. *@li seq_length:A optional 1D Tensor. Must be one of the following types: int32. The format must be ND.
  340. *@li init_h:A optional 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  341. *@li init_c:A optional 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  342. *@li wci:A 4D optional Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  343. *@li wcf:A 4D optional Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  344. *@li wco:A 4D optional Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  345. *@li mask:A 1D optional Tensor. Must be one of the following types: uint8. The format must be ND . \n
  346. *@li real_mask:A 4D optional Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  347. *@li project:A 4D optional Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  348. *@par Attributes:
  349. *@li cell_type:An string identifying the cell type in the op. Default to "LSTM". Only LSTM is currently supported.
  350. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported.
  351. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  352. *@li use_peephole:An bool identifying if use peephole in the op. Default to false.
  353. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  354. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  355. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  356. *@li time_major:An bool identifying the time major in the op. Default to true.
  357. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported.
  358. *@li forget_bias:An float identifying the forget bias in the op. Default to 0.
  359. *@li is_training:An bool identifying is training in the op. Default to true . \n
  360. *@par Outputs:
  361. *eight outputs:
  362. *@li y:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  363. *@li output_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  364. *@li output_c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  365. *@li i:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  366. *@li j:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  367. *@li f:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  368. *@li o:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  369. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  370. *@par Third-party framework compatibility:
  371. * Compatible with the TF operator LSTM.
  372. */
  373. REG_OP(DynamicRNNV3)
  374. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  375. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  376. .INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  377. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32}))
  378. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  379. .OPTIONAL_INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  380. .OPTIONAL_INPUT(wci, TensorType({DT_FLOAT16, DT_FLOAT}))
  381. .OPTIONAL_INPUT(wcf, TensorType({DT_FLOAT16, DT_FLOAT}))
  382. .OPTIONAL_INPUT(wco, TensorType({DT_FLOAT16, DT_FLOAT}))
  383. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  384. .OPTIONAL_INPUT(real_mask, TensorType({DT_FLOAT16, DT_FLOAT}))
  385. .OPTIONAL_INPUT(project, TensorType({DT_FLOAT16, DT_FLOAT}))
  386. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  387. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  388. .OUTPUT(output_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  389. .OUTPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  390. .OUTPUT(j, TensorType({DT_FLOAT16, DT_FLOAT}))
  391. .OUTPUT(f, TensorType({DT_FLOAT16, DT_FLOAT}))
  392. .OUTPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  393. .OUTPUT(tanhc, TensorType({DT_FLOAT16, DT_FLOAT}))
  394. .ATTR(cell_type, String, "LSTM")
  395. .ATTR(direction, String, "UNIDIRECTIONAL")
  396. .ATTR(cell_depth, Int, 1)
  397. .ATTR(use_peephole, Bool, false)
  398. .ATTR(keep_prob, Float, 1.0)
  399. .ATTR(cell_clip, Float, -1.0)
  400. .ATTR(num_proj, Int, 0)
  401. .ATTR(time_major, Bool, true)
  402. .ATTR(activation, String, "tanh")
  403. .ATTR(forget_bias, Float, 0.0)
  404. .ATTR(is_training, Bool, true)
  405. .OP_END_FACTORY_REG(DynamicRNNV3)
  406. /**
  407. *@brief: DynamicLSTMV2 calculation.
  408. *@par Inputs:
  409. *ten inputs:
  410. *@li x:A required 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  411. *@li w:A required 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  412. *@li b:A required 1D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  413. *@li cont:A required 2D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  414. *@li w_xc_x_static:A optional 2D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  415. *@li h0:A optional 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  416. *@li c0:A optional 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  417. *@li wci:A optional 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  418. *@li wcf:A optional 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  419. *@li wco:A optional 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  420. *@li mask:A optional 1D Tensor. Must be one of the following types: uint8. The format must be ND .
  421. *@par Attributes:
  422. *@li num_output:An integer identifying the num projection in the op. Default to 0.
  423. *@li expose_hidden:An bool identifying the expose_hidden in the op. Default to flase.
  424. *@li need_output_last:An bool identifying the time major in the op. Default to true.
  425. *@li forget_bias:An float identifying the forget bias in the op. Default to 0.
  426. *@par Outputs:
  427. *eight outputs:
  428. *@li y:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  429. *@li output_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  430. *@li output_c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  431. *@li last_output_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  432. *@li last_output_c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  433. *@par Third-party framework compatibility:
  434. * Compatible with the Caffe operator LSTM.
  435. *@par Restrictions:
  436. * Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  437. */
  438. REG_OP(DynamicLSTMV2)
  439. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  440. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  441. .INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  442. .INPUT(cont, TensorType({DT_FLOAT16, DT_FLOAT}))
  443. .OPTIONAL_INPUT(w_xc_x_static, TensorType({DT_FLOAT16, DT_FLOAT}))
  444. .OPTIONAL_INPUT(h0, TensorType({DT_FLOAT16, DT_FLOAT}))
  445. .OPTIONAL_INPUT(c0, TensorType({DT_FLOAT16, DT_FLOAT}))
  446. .OPTIONAL_INPUT(wci, TensorType({DT_FLOAT16, DT_FLOAT}))
  447. .OPTIONAL_INPUT(wcf, TensorType({DT_FLOAT16, DT_FLOAT}))
  448. .OPTIONAL_INPUT(wco, TensorType({DT_FLOAT16, DT_FLOAT}))
  449. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  450. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  451. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  452. .OUTPUT(output_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  453. .OUTPUT(last_output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  454. .OUTPUT(last_output_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  455. .ATTR(num_output, Int, 0)
  456. .ATTR(expose_hidden, Bool, false)
  457. .ATTR(need_output_last, Bool, false)
  458. .ATTR(forget_bias, Float, 0.0)
  459. .OP_END_FACTORY_REG(DynamicLSTMV2)
  460. /**
  461. *@brief: LSTMInputGrad calculation.
  462. *@par Inputs:
  463. *ten inputs: \n
  464. *@li w:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  465. *@li init_c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  466. *@li c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  467. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  468. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  469. *@li dc:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  470. *@li i:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  471. *@li j:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  472. *@li f:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  473. *@li o:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  474. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  475. *@par Outputs:
  476. *four outputs: \n
  477. *@li dx:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  478. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  479. *@li dc_prev:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  480. *@li dgate:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_NZ.
  481. */
  482. REG_OP(LSTMInputGrad)
  483. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  484. .INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  485. .INPUT(c, TensorType({DT_FLOAT16, DT_FLOAT}))
  486. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  487. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  488. .INPUT(dc, TensorType({DT_FLOAT16, DT_FLOAT}))
  489. .INPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  490. .INPUT(j, TensorType({DT_FLOAT16, DT_FLOAT}))
  491. .INPUT(f, TensorType({DT_FLOAT16, DT_FLOAT}))
  492. .INPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  493. .OPTIONAL_INPUT(tanhct, TensorType({DT_FLOAT16, DT_FLOAT}))
  494. .OUTPUT(dx, TensorType({DT_FLOAT16, DT_FLOAT}))
  495. .OUTPUT(dh_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  496. .OUTPUT(dc_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  497. .OUTPUT(dgate, TensorType({DT_FLOAT16}))
  498. .OP_END_FACTORY_REG(LSTMInputGrad)
  499. /**
  500. *@brief: Dynamic LSTM Cell grad calculation.Calculate the gradient of gates and cell state.
  501. *@par Inputs:
  502. *twelve inputs:
  503. *@li init_c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  504. *@li c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  505. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  506. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  507. *@li dc:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  508. *@li i:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  509. *@li j:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  510. *@li f:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  511. *@li o:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  512. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  513. *@li mask:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  514. *@li t_state:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ . \n
  515. *@par Attributes:
  516. *@li forget_bias:An integer identifying the forget bias in the op. Default to 1.
  517. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported . \n
  518. *@li direction:An string that marks the calculation sequence of the operator. Default to "Forward".
  519. *@li gate_order:An string mark the order of output 4 gate. Default to "ijfo".
  520. *@par Outputs:
  521. *two outputs:
  522. *@li dgate:A 4D Tensor. Must be one of the following types: float16.
  523. *@li dct_1:A 4D Tensor. Must be one of the following types: float16, float32.
  524. *@par Restrictions:
  525. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  526. */
  527. REG_OP(DynamicLSTMGradCell)
  528. .INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  529. .INPUT(c, TensorType({DT_FLOAT16, DT_FLOAT}))
  530. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  531. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  532. .INPUT(dc, TensorType({DT_FLOAT16, DT_FLOAT}))
  533. .INPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  534. .INPUT(j, TensorType({DT_FLOAT16, DT_FLOAT}))
  535. .INPUT(f, TensorType({DT_FLOAT16, DT_FLOAT}))
  536. .INPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  537. .INPUT(tanhct, TensorType({DT_FLOAT16, DT_FLOAT}))
  538. .INPUT(t_state, TensorType({DT_INT32, DT_INT32}))
  539. .INPUT(mask, TensorType({DT_FLOAT16, DT_FLOAT}))
  540. .OUTPUT(dgate, TensorType({DT_FLOAT16, DT_FLOAT}))
  541. .OUTPUT(dct_1, TensorType({DT_FLOAT16, DT_FLOAT}))
  542. .ATTR(forget_bias, Float, 1.0)
  543. .ATTR(activation, String, "tanh")
  544. .ATTR(direction, String, "UNIDIRECTIONAL")
  545. .ATTR(gate_order, String, "ijfo")
  546. .OP_END_FACTORY_REG(DynamicLSTMGradCell)
  547. /**
  548. *@brief: Basic LSTM Cell backward calculation.Calculate the gradient of input and hidden state.
  549. *@par Inputs:
  550. *three inputs:
  551. *@li dgate:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_NZ.
  552. *@li w:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_Z.
  553. *@li dropout_mask:A 1D Tensor. Must be one of the following types: uint8. The format must be ND . \n
  554. *@par Attributes:
  555. *keep_prob:An integer identifying the keep prob in the op. Default to 1 . \n
  556. *@par Outputs:
  557. *two outputs:
  558. *@li dxt:A 4D Tensor. Must be one of the following types: float16, float32.
  559. *@li dht:A 4D Tensor. Must be one of the following types: float16, float32.
  560. *@par Restrictions:
  561. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  562. */
  563. REG_OP(BasicLSTMCellInputGrad)
  564. .INPUT(dgate, TensorType({DT_FLOAT16}))
  565. .INPUT(w, TensorType({DT_FLOAT16}))
  566. .OPTIONAL_INPUT(dropout_mask, TensorType({DT_UINT8}))
  567. .OUTPUT(dxt, TensorType({DT_FLOAT16, DT_FLOAT32}))
  568. .OUTPUT(dht, TensorType({DT_FLOAT16, DT_FLOAT32}))
  569. .ATTR(keep_prob, Float, 1.0)
  570. .OP_END_FACTORY_REG(BasicLSTMCellInputGrad)
  571. /**
  572. *@brief: Basic LSTM Cell backward calculation.Calculate the gradient of weight and bias.
  573. *@par Inputs:
  574. *three inputs:
  575. *@li x:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_NZ.
  576. *@li h:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_NZ.
  577. *@li dgate:A 4D Tensor. Must be one of the following types: uint8. The format must be FRACTAL_NZ . \n
  578. *@par Outputs:
  579. *two outputs:
  580. *@li dw:A 4D Tensor. Must be one of the following types: float16.
  581. *@li db:A 4D Tensor. Must be one of the following types: float16, float32.
  582. *@par Restrictions:
  583. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  584. */
  585. REG_OP(BasicLSTMCellWeightGrad)
  586. .INPUT(x, TensorType({DT_FLOAT16}))
  587. .INPUT(h, TensorType({DT_FLOAT16}))
  588. .INPUT(dgate, TensorType({DT_FLOAT16}))
  589. .OUTPUT(dw, TensorType({DT_FLOAT16}))
  590. .OUTPUT(db, TensorType({DT_FLOAT16, DT_FLOAT32}))
  591. .OP_END_FACTORY_REG(BasicLSTMCellWeightGrad)
  592. /**
  593. *@brief: Basic LSTM Cell backward calculation.Calculate the gradient of gates and cell state.
  594. *@par Inputs:
  595. *eight inputs:
  596. *@li c:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  597. *@li dht:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  598. *@li dct:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  599. *@li it:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  600. *@li jt:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  601. *@li ft:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  602. *@li ot:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  603. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ . \n
  604. *@par Attributes:
  605. *@li forget_bias:An integer identifying the forget bias in the op. Default to 1.
  606. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported . \n
  607. *@par Outputs:
  608. *two outputs:
  609. *@li dgate:A 4D Tensor. Must be one of the following types: float16.
  610. *@li dct_1:A 4D Tensor. Must be one of the following types: float16, float32.
  611. *@par Restrictions:
  612. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  613. */
  614. REG_OP(BasicLSTMCellCStateGrad)
  615. .INPUT(c, TensorType({DT_FLOAT16, DT_FLOAT}))
  616. .INPUT(dht, TensorType({DT_FLOAT16, DT_FLOAT}))
  617. .INPUT(dct, TensorType({DT_FLOAT16, DT_FLOAT}))
  618. .INPUT(it, TensorType({DT_FLOAT16, DT_FLOAT}))
  619. .INPUT(jt, TensorType({DT_FLOAT16, DT_FLOAT}))
  620. .INPUT(ft, TensorType({DT_FLOAT16, DT_FLOAT}))
  621. .INPUT(ot, TensorType({DT_FLOAT16, DT_FLOAT}))
  622. .INPUT(tanhct, TensorType({DT_FLOAT16, DT_FLOAT}))
  623. .OUTPUT(dgate, TensorType({DT_FLOAT16}))
  624. .OUTPUT(dct_1, TensorType({DT_FLOAT16, DT_FLOAT}))
  625. .ATTR(forget_bias, Float, 1.0)
  626. .ATTR(activation, String, "tanh")
  627. .OP_END_FACTORY_REG(BasicLSTMCellCStateGrad)
  628. /**
  629. *@brief: RNN operator.
  630. *@par Inputs:
  631. *eight inputs:
  632. *@li x:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_NZ.
  633. *@li cont:A 1D Tensor. Must be one of the following types: float16. The format must be ND.
  634. *@li x_static:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_NZ.
  635. *@li h_0:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  636. *@li w_xh:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_Z.
  637. *@li w_sh:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_Z.
  638. *@li w_hh:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_Z.
  639. *@li w_ho:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_Z.
  640. *@li bias_h:A 1D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  641. *@li bias_o:A 1D Tensor. Must be one of the following types: float16, float32. The format must be ND . \n
  642. *@par Attributes:
  643. *@li expose_hidden:An bool identifying if expose the hidden state of last time step. Default to false.
  644. *@li num_output:An integer identifying the number of output features. Default to 0 . \n
  645. *@par Outputs:
  646. *two outputs:
  647. *@li o:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  648. *@li h_t:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  649. *@par Restrictions:
  650. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  651. */
  652. REG_OP(RNN)
  653. .INPUT(x, TensorType({DT_FLOAT16}))
  654. .INPUT(cont, TensorType({DT_FLOAT16}))
  655. .OPTIONAL_INPUT(x_static, TensorType({DT_FLOAT16}))
  656. .OPTIONAL_INPUT(h_0, TensorType({DT_FLOAT16, DT_FLOAT}))
  657. .INPUT(w_xh, TensorType({DT_FLOAT16}))
  658. .INPUT(bias_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  659. .OPTIONAL_INPUT(w_sh, TensorType({DT_FLOAT16}))
  660. .INPUT(w_hh, TensorType({DT_FLOAT16}))
  661. .INPUT(w_ho, TensorType({DT_FLOAT16}))
  662. .INPUT(bias_o, TensorType({DT_FLOAT16, DT_FLOAT}))
  663. .OUTPUT(o, TensorType({DT_FLOAT16, DT_FLOAT}))
  664. .OUTPUT(h_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  665. .ATTR(num_output, Int, 0)
  666. .ATTR(expose_hidden, Bool, false)
  667. .OP_END_FACTORY_REG(RNN)
  668. /**
  669. *@brief: BasicRNNCell operator.
  670. *@par Inputs:
  671. *eight inputs:
  672. *@li x:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_NZ.
  673. *@li cont:A 1D Tensor. Must be one of the following types: float16. The format must be ND.
  674. *@li w_xh_x_static:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_NZ.
  675. *@li h_0:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  676. *@li w_xh:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_Z.
  677. *@li w_hh:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_Z.
  678. *@li w_ho:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_Z.
  679. *@li bias_h:A 1D Tensor. Must be one of the following types: float16, float32. The format must be ND.
  680. *@li bias_o:A 1D Tensor. Must be one of the following types: float16, float32. The format must be ND . \n
  681. *@par Attributes:
  682. *@li expose_hidden:An bool identifying if expose the hidden state of last time step. Default to false.
  683. *@li num_output:An integer identifying the number of output features. Default to 0 . \n
  684. *@par Outputs:
  685. *two outputs:
  686. *@li o_t:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  687. *@li h_t:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  688. *@par Restrictions:
  689. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  690. */
  691. REG_OP(BasicRNNCell)
  692. .INPUT(x, TensorType({DT_FLOAT16}))
  693. .OPTIONAL_INPUT(cont, TensorType({DT_FLOAT16}))
  694. .OPTIONAL_INPUT(w_xh_x_static, TensorType({DT_FLOAT16, DT_FLOAT}))
  695. .OPTIONAL_INPUT(h_0, TensorType({DT_FLOAT16, DT_FLOAT}))
  696. .INPUT(w_xh, TensorType({DT_FLOAT16}))
  697. .INPUT(bias_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  698. .OPTIONAL_INPUT(w_hh, TensorType({DT_FLOAT16}))
  699. .INPUT(w_ho, TensorType({DT_FLOAT16}))
  700. .INPUT(bias_o, TensorType({DT_FLOAT16, DT_FLOAT}))
  701. .OUTPUT(o_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  702. .OUTPUT(h_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  703. .ATTR(expose_hidden, Bool, false)
  704. .ATTR(num_output, Int, 0)
  705. .OP_END_FACTORY_REG(BasicRNNCell)
  706. /**
  707. *@brief DynamicGRU calculation.
  708. *@par Inputs:
  709. *seven inputs:
  710. *@li x:Must be one of the following types: float16. The format must be FRACTAL_NZ.
  711. *@li w:Must be one of the following types: float16. The format must be FRACTAL_Z.
  712. *@li b:Must be one of the following types: float16, float32. The format must be ND.
  713. *@li cw:Must be one of the following types: float16. The format must be FRACTAL_Z.
  714. *@li cb:Must be one of the following types: float16, float32. The format must be ND.
  715. *@li seq_length:Must be one of the following types: int32. The format must be ND.
  716. *@li init_h:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  717. *@par Attributes:
  718. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported.
  719. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  720. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  721. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  722. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  723. *@li time_major:An bool identifying the time major in the op. Default to true.
  724. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported.
  725. *@li is_training:An bool identifying is training in the op. Default to true.
  726. *@par Outputs:
  727. *five outputs:
  728. *@li y:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  729. *@li output_h:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  730. *@li r:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  731. *@li i:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  732. *@li n:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  733. *@par Restrictions:
  734. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  735. */
  736. REG_OP(DynamicGRU)
  737. .INPUT(x, TensorType({DT_FLOAT16}))
  738. .INPUT(w, TensorType({DT_FLOAT16}))
  739. .INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  740. .INPUT(cw, TensorType({DT_FLOAT16}))
  741. .INPUT(cb, TensorType({DT_FLOAT16, DT_FLOAT}))
  742. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32}))
  743. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  744. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  745. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  746. .OUTPUT(r, TensorType({DT_FLOAT16, DT_FLOAT}))
  747. .OUTPUT(i, TensorType({DT_FLOAT16, DT_FLOAT}))
  748. .OUTPUT(n, TensorType({DT_FLOAT16, DT_FLOAT}))
  749. .ATTR(direction, String, "UNIDIRECTIONAL")
  750. .ATTR(cell_depth, Int, 1)
  751. .ATTR(keep_prob, Float, 1.0)
  752. .ATTR(cell_clip, Float, -1.0)
  753. .ATTR(num_proj, Int, 0)
  754. .ATTR(time_major, Bool, true)
  755. .ATTR(activation, String, "tanh")
  756. .ATTR(is_training, Bool, true)
  757. .OP_END_FACTORY_REG(DynamicGRU)
  758. /**
  759. *@brief DynamicGRUV2 calculation.
  760. *@par Inputs:
  761. *seven inputs:
  762. *@li x:Must be one of the following types: float16. The format must be FRACTAL_NZ.
  763. *@li weight_input:Must be one of the following types: float16. The format must be FRACTAL_Z.
  764. *@li weight_hidden:Must be one of the following types: float16. The format must be FRACTAL_Z.
  765. *@li bias_input:Must be one of the following types: float16, float32. The format must be ND.
  766. *@li bias_hidden:Must be one of the following types: float16, float32. The format must be ND.
  767. *@li seq_length:Must be one of the following types: float16 in FRACTAL_NZ and int32 in ND.
  768. *@li init_h:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  769. *@par Attributes:
  770. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported.
  771. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  772. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  773. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  774. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  775. *@li time_major:An bool identifying the time major in the op. Default to true.
  776. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported.
  777. *@li gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  778. *@li reset_after:An bool identifying whether to apply reset gate after matrix multiplication. Default to true.
  779. *@li is_training:An bool identifying is training in the op. Default to true.
  780. *@par Outputs:
  781. *six outputs:
  782. *@li y:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  783. *@li output_h:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  784. *@li update:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  785. *@li reset:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  786. *@li new:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  787. *@li hidden_new:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  788. */
  789. REG_OP(DynamicGRUV2)
  790. .INPUT(x, TensorType({DT_FLOAT16}))
  791. .INPUT(weight_input, TensorType({DT_FLOAT16}))
  792. .INPUT(weight_hidden, TensorType({DT_FLOAT16}))
  793. .OPTIONAL_INPUT(bias_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  794. .OPTIONAL_INPUT(bias_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  795. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32, DT_FLOAT16}))
  796. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  797. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  798. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  799. .OUTPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  800. .OUTPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  801. .OUTPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  802. .OUTPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  803. .ATTR(direction, String, "UNIDIRECTIONAL")
  804. .ATTR(cell_depth, Int, 1)
  805. .ATTR(keep_prob, Float, 1.0)
  806. .ATTR(cell_clip, Float, -1.0)
  807. .ATTR(num_proj, Int, 0)
  808. .ATTR(time_major, Bool, true)
  809. .ATTR(activation, String, "tanh")
  810. .ATTR(gate_order, String, "zrh")
  811. .ATTR(reset_after, Bool, true)
  812. .ATTR(is_training, Bool, true)
  813. .OP_END_FACTORY_REG(DynamicGRUV2)
  814. /**
  815. *@brief DynamicGRUV2Hidden calculation.
  816. *@par Inputs:
  817. *five inputs:
  818. *@li x_weight_input:Must be one of the following types: float32. The format must be FRACTAL_NZ.
  819. *@li weight_hidden:Must be one of the following types: float16. The format must be FRACTAL_Z.
  820. *@li bias_hidden:Must be one of the following types: float16, float32. The format must be ND.
  821. *@li seq_length:Must be one of the following types: float16 in FRACTAL_NZ and int32 in ND.
  822. *@li init_h:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  823. *@par Attributes:
  824. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL".
  825. Only UNIDIRECTIONAL is currently supported.
  826. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  827. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  828. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  829. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  830. *@li time_major:An bool identifying the time major in the op. Default to true.
  831. *@li activation:An string identifying the type of activation function in the op. Default to "tanh".
  832. Only tanh is currently supported.
  833. *@li gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  834. *@li reset_after:An bool identifying whether to apply reset gate after matrix multiplication. Default to true.
  835. *@li is_training:An bool identifying is training in the op. Default to true.
  836. *@par Outputs:
  837. *six outputs:
  838. *@li y:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  839. *@li output_h:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  840. *@li update:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  841. *@li reset:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  842. *@li new:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  843. *@li hidden_new:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  844. *@par Restrictions:
  845. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  846. */
  847. REG_OP(DynamicGRUV2Hidden)
  848. .INPUT(x_weight_input, TensorType({DT_FLOAT32}))
  849. .INPUT(weight_hidden, TensorType({DT_FLOAT16}))
  850. .OPTIONAL_INPUT(bias_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  851. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32, DT_FLOAT16}))
  852. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  853. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  854. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  855. .OUTPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  856. .OUTPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  857. .OUTPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  858. .OUTPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  859. .ATTR(direction, String, "UNIDIRECTIONAL")
  860. .ATTR(cell_depth, Int, 1)
  861. .ATTR(keep_prob, Float, 1.0)
  862. .ATTR(cell_clip, Float, -1.0)
  863. .ATTR(num_proj, Int, 0)
  864. .ATTR(time_major, Bool, true)
  865. .ATTR(activation, String, "tanh")
  866. .ATTR(gate_order, String, "zrh")
  867. .ATTR(reset_after, Bool, true)
  868. .ATTR(is_training, Bool, true)
  869. .OP_END_FACTORY_REG(DynamicGRUV2Hidden)
  870. /**
  871. *@brief: DynamicGRUV2Grad calculation.
  872. *@par Inputs:
  873. *fourteen inputs: \n
  874. *@li x:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  875. *@li weight_input:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  876. *@li weight_hidden:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  877. *@li y:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  878. *@li init_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  879. *@li h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  880. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  881. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  882. *@li update:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  883. *@li reset:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  884. *@li new:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  885. *@li hidden_new:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  886. *@li seq_length:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  887. *@li mask:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  888. *@par Attributes:
  889. *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported.
  890. *@li cell_depth:An integer identifying the cell depth in the op. Default to 1.
  891. *@li keep_prob:An float identifying the keep prob in the op. Default to 1.
  892. *@li cell_clip:An float identifying the cell clip in the op. Default to -1.
  893. *@li num_proj:An integer identifying the num projection in the op. Default to 0.
  894. *@li time_major:An bool identifying the time major in the op. Default to true.
  895. *@li gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  896. *@li reset_after:An bool identifying whether to apply reset gate after matrix multiplication. Default to true.
  897. *@par Outputs:
  898. *six outputs: \n
  899. *@li dw_input:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  900. *@li dw_hidden:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  901. *@li db_input:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  902. *@li db_hidden:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  903. *@li dx:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  904. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  905. *@par Restrictions:
  906. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  907. */
  908. REG_OP(DynamicGRUV2Grad)
  909. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  910. .INPUT(weight_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  911. .INPUT(weight_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  912. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  913. .INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  914. .INPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  915. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  916. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  917. .INPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  918. .INPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  919. .INPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  920. .INPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  921. .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32}))
  922. .OPTIONAL_INPUT(mask, TensorType({DT_UINT8}))
  923. .OUTPUT(dw_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  924. .OUTPUT(dw_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  925. .OUTPUT(db_input, TensorType({DT_FLOAT16, DT_FLOAT}))
  926. .OUTPUT(db_hidden, TensorType({DT_FLOAT16, DT_FLOAT}))
  927. .OUTPUT(dx, TensorType({DT_FLOAT16, DT_FLOAT}))
  928. .OUTPUT(dh_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  929. .ATTR(direction, String, "UNIDIRECTIONAL")
  930. .ATTR(cell_depth, Int, 0)
  931. .ATTR(keep_prob, Float, -1.0)
  932. .ATTR(cell_clip, Float, -1.0)
  933. .ATTR(num_proj, Int, 0)
  934. .ATTR(time_major, Bool, true)
  935. .ATTR(gate_order, String, "zrh")
  936. .ATTR(reset_after, Bool, true)
  937. .OP_END_FACTORY_REG(DynamicGRUV2Grad)
  938. /**
  939. *@brief: GRUV2HiddenGrad calculation.
  940. *@par Inputs:
  941. *nine inputs: \n
  942. *@li dh_pre_t:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  943. *@li init_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  944. *@li h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  945. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  946. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  947. *@li update:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  948. *@li reset:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  949. *@li new:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  950. *@li hidden_new:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  951. *@par Attributes:
  952. *@li t_state:An Int identifying the current t state. Default to [0, 4].
  953. *@li gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  954. *@par Outputs:
  955. *three outputs: \n
  956. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  957. *@li dgate_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  958. *@li dnt_x:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  959. *@par Restrictions:
  960. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  961. */
  962. REG_OP(GRUV2HiddenGradCell)
  963. .INPUT(dh_pre_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  964. .INPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  965. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  966. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  967. .INPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  968. .INPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  969. .INPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  970. .INPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  971. .OUTPUT(dh_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  972. .OUTPUT(dgate_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  973. .OUTPUT(dnt_x, TensorType({DT_FLOAT16, DT_FLOAT}))
  974. .ATTR(t_state, Int, 0)
  975. .ATTR(gate_order, String, "zrh")
  976. .OP_END_FACTORY_REG(GRUV2HiddenGradCell)
  977. /**
  978. *@brief: DynamicGRUCellGrad calculation.
  979. *@par Inputs:
  980. *ten inputs: \n
  981. *@li dh_pre_t:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  982. *@li h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  983. *@li dy:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  984. *@li dh:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  985. *@li update:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  986. *@li reset:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  987. *@li new:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  988. *@li hidden_new:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.+
  989. *@li init_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  990. *@li t_state:A 1D Tensor. Must be one of the following types: int32. The format must be ND.
  991. *@par Attributes:
  992. *gate_order:An string identifying the gate order in weight and bias. Default to "zrh". "rzh" is another option.
  993. *@par Outputs:
  994. *three outputs: \n
  995. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  996. *@li dgate_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  997. *@li dnt_x:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  998. *@par Restrictions:
  999. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1000. */
  1001. REG_OP(DynamicGRUCellGrad)
  1002. .INPUT(dh_pre_t, TensorType({DT_FLOAT16, DT_FLOAT}))
  1003. .INPUT(h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1004. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  1005. .INPUT(dh, TensorType({DT_FLOAT16, DT_FLOAT}))
  1006. .INPUT(update, TensorType({DT_FLOAT16, DT_FLOAT}))
  1007. .INPUT(reset, TensorType({DT_FLOAT16, DT_FLOAT}))
  1008. .INPUT(new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1009. .INPUT(hidden_new, TensorType({DT_FLOAT16, DT_FLOAT}))
  1010. .INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1011. .INPUT(t_state, TensorType({DT_INT32, DT_INT32}))
  1012. .OUTPUT(dh_prev, TensorType({DT_FLOAT16, DT_FLOAT}))
  1013. .OUTPUT(dgate_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1014. .OUTPUT(dnt_x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1015. .ATTR(gate_order, String, "zrh")
  1016. .OP_END_FACTORY_REG(DynamicGRUCellGrad)
  1017. /**
  1018. * @brief Calculates the reversed outputs of the function "embedding". \n
  1019. * @par Inputs:
  1020. * Two inputs, including:
  1021. * @li grad: A mutable Tensor of word grad. Must be one of the following types:
  1022. * float32.
  1023. * @li indices: A mutable word index Tensor of the int32 type.\n
  1024. * @par Attributes:
  1025. * @li num_weights: An int attr which use to judge how many words in dict. \n
  1026. * @li padding_idx: An int attr judge which word to fill zeros. Defaults to "-1". \n
  1027. * @li scale_grad_by_freq: An optional bool. Defaults to "False".
  1028. * If "True", "grad_weight" will be scale by word_frequency.
  1029. * If "False", "grad_weight" will not be scale by word_frequency. \n
  1030. * @par Outputs:
  1031. * y: A mutable output Tensor of new word grad has the same type as "grads". \n
  1032. * @par Third-party framework compatibility
  1033. * Compatible with the Pytorch operator EmbeddingDenseGrad.
  1034. */
  1035. REG_OP(EmbeddingDenseGrad)
  1036. .INPUT(grad, TensorType({ DT_FLOAT32 })) /* "First operand." */
  1037. .INPUT(indices, TensorType({ DT_INT32 })) /* "Second operand." */
  1038. .OUTPUT(y, TensorType({ DT_FLOAT32 })) /* "Result, has same element type as two inputs" */
  1039. .REQUIRED_ATTR(num_weights, Int)
  1040. .ATTR(padding_idx, Int, -1)
  1041. .ATTR(scale_grad_by_freq, Bool, false)
  1042. .OP_END_FACTORY_REG(EmbeddingDenseGrad)
  1043. /**
  1044. *@brief CommonLSTM calculation.
  1045. *@par Inputs:
  1046. *eight inputs: \n
  1047. *@li x:Each time step is a 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  1048. *@li w:Each direction is a 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  1049. *@li r:Each direction is a 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_ZN_LSTM.
  1050. *@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.
  1051. *@li sequence_lens:An optional input. A 1D Tensor.Must be one of the following types: int32. The format must be ND.
  1052. *@li initial_h:An optional input. Each direction is a 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  1053. *@li initial_c:An optional input. Each direction is a 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  1054. *@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.
  1055. *@par Attributes:
  1056. *@li activation_alpha:Optional scaling values used by some activation functions. Empty is currently supported.
  1057. *@li activation_beta:Optional scaling values used by some activation functions. Empty is currently supported.
  1058. *@li activations:The list of activation functions. Empty is currently supported.
  1059. *@li clip:An float identifying the cell clip in the op. Default to -1.
  1060. *@li direction:Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward(default), reverse, or bidirectional.
  1061. *@li hidden_size:Number of neurons in the hidden layer. Reserved.
  1062. *@li input_forget:Couple the input and forget gates if 1. Reserved.
  1063. *@par Outputs:
  1064. *three outputs: \n
  1065. *@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. The format must be FRACTAL_NZ.
  1066. *@li y_h:Each direction is a 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  1067. *@li y_c:Each direction is a 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ.
  1068. */
  1069. REG_OP(CommonLSTM)
  1070. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1071. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  1072. .INPUT(r, TensorType({DT_FLOAT16, DT_FLOAT}))
  1073. .OPTIONAL_INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  1074. .OPTIONAL_INPUT(sequence_lens, TensorType({DT_INT32}))
  1075. .OPTIONAL_INPUT(initial_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1076. .OPTIONAL_INPUT(initial_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  1077. .OPTIONAL_INPUT(p, TensorType({DT_FLOAT16, DT_FLOAT}))
  1078. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1079. .OUTPUT(y_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1080. .OUTPUT(y_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  1081. .ATTR(activation_alpha, ListFloat, {})
  1082. .ATTR(activation_beta, ListFloat, {})
  1083. .ATTR(activations, ListString, {})
  1084. .ATTR(clip, Float, -1.0)
  1085. .ATTR(direction, String, "forward")
  1086. .REQUIRED_ATTR(hidden_size, Int)
  1087. .ATTR(input_forget, Int, 0)
  1088. .OP_END_FACTORY_REG(CommonLSTM)
  1089. /**
  1090. * @brief Calculate the mask. According to hidden_size and num_step, convert seq_length to mask.
  1091. *
  1092. * @par Inputs:
  1093. * @li seq_length: A 1D Tensor. Must be one of the following types: int32. Record the current length of each batch. [batch_size].
  1094. * @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].
  1095. * @li hidden_size: An optional attribute of type int32. pass the hidden_size. \n
  1096. *
  1097. * @par Outputs:
  1098. * 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
  1099. *
  1100. * @par Restrictions:
  1101. * Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1102. */
  1103. REG_OP(RnnGenMaskV2)
  1104. .INPUT(seq_length, TensorType({DT_INT32}))
  1105. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1106. .REQUIRED_ATTR(hidden_size, Int)
  1107. .OUTPUT(seq_mask, TensorType({DT_FLOAT16, DT_FLOAT}))
  1108. .OP_END_FACTORY_REG(RnnGenMaskV2)
  1109. /**
  1110. * @brief Common GRU calculation.
  1111. * @par Inputs:
  1112. * Eight inputs, including:
  1113. * @li x: The input sequences packed (and pontentially padded) into on 3D Tesnor(float16). The format must be FRACTAL_NZ
  1114. * @li w: The weight tensor for the gates is 3D Tensor(float16). The format must be FRACTAL_Z
  1115. * @li r: The recurrence weight tesnor is 3D Tensor(float16). The format must be FRACTAL_Z
  1116. * @li b: The bias tensor for the gates. The format must be ND
  1117. * @li sequence_lens: Optional tensor specifying lengths of sequences(int32). The format must be ND
  1118. * @li init_h: Optional initial value of the hidden(float16,float32). The format must be FRACTAL_NZ
  1119. * @par Attributes:
  1120. * @li activation_alpha: Optional scaling values used by some activation functions. \n
  1121. * @li activation_beta: Optional scaling values used by some activation functions. \n
  1122. * @li activations: A list of 2 (or 4 if bidirectional) activation functions for update, reset, and hidden gates. \n
  1123. * @li clip: Cell clip threshold. \n
  1124. * @li direction: Specify if the RNN is forward, reverse, or bidirectional. \n
  1125. * @li hidden_size: Number of neurons in the hidden layer. \n
  1126. * @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
  1127. * @par Outputs:
  1128. * @li y: A Tensor that concats all the intermediate output values of the hidden(float16,float32). The format must be FRACTAL_NZ
  1129. * @li y_h: The last output value of the hidden(float16,float32). The format must be FRACTAL_NZ
  1130. */
  1131. REG_OP(CommonGRU)
  1132. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1133. .INPUT(w, TensorType({DT_FLOAT16, DT_FLOAT}))
  1134. .INPUT(r, TensorType({DT_FLOAT16, DT_FLOAT}))
  1135. .OPTIONAL_INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT}))
  1136. .OPTIONAL_INPUT(sequence_lens, TensorType({DT_INT32}))
  1137. .OPTIONAL_INPUT(initial_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1138. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1139. .OUTPUT(y_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1140. .ATTR(activation_alpha, ListFloat, {})
  1141. .ATTR(activation_beta , ListFloat, {})
  1142. .ATTR(activations , ListString, {})
  1143. .ATTR(clip, Float, -1.0)
  1144. .ATTR(direction, String, "forward")
  1145. .REQUIRED_ATTR(hidden_size, Int)
  1146. .ATTR(linear_before_reset , Int, 0)
  1147. .OP_END_FACTORY_REG(CommonGRU)
  1148. /**
  1149. * @brief Calculates the reversed outputs of the function "embedding". \n
  1150. * @par Inputs:
  1151. * Four inputs, including:
  1152. * @li weight: A mutable Tensor of word grad. Must be one of the following types:
  1153. * float32.
  1154. * @li indices: A mutable word index Tensor of the int32 type.\n
  1155. * @li offsets: A mutable word index Tensor of the int32 type.\n
  1156. * @li per_sample_weights: to indicate all weights should be taken to be 1.
  1157. * If specified, per_sample_weights must have exactly the same shape as input
  1158. * and is treated as having the same offsets, if those are not None.
  1159. * Only supported for mode='sum'..\n
  1160. * @par Attributes:
  1161. * @li mode: An string attr which use "sum"``, ``"mean"`` or ``"max"``. Specifies the way to reduce the bag.. \n
  1162. * @li scale_grad_by_freq: An optional bool. Defaults to "False".
  1163. * If "True", "grad_weight" will be scale by word_frequency.
  1164. * If "False", "grad_weight" will not be scale by word_frequency. \n
  1165. * @li sparse: if True, gradient w.r.t.attr weight matrix will be a sparse tensor. \n
  1166. * @li include_last_offset: if True, attr offsets has one additional element, where the last element
  1167. * is equivalent to the size of indices. This matches the CSR format.. \n
  1168. * @par Outputs:
  1169. * y: A mutable output Tensor of new word grad has the same type as "grads". \n
  1170. * @par Third-party framework compatibility
  1171. * Compatible with the Pytorch operator EmbeddingBag.
  1172. */
  1173. REG_OP(EmbeddingBag)
  1174. .INPUT(weight, TensorType({ DT_FLOAT32 }))
  1175. .INPUT(indices, TensorType({ DT_INT32 }))
  1176. .OPTIONAL_INPUT(offsets, TensorType({DT_INT32}))
  1177. .OPTIONAL_INPUT(per_sample_weights, TensorType({DT_FLOAT32}))
  1178. .OUTPUT(y, TensorType({ DT_FLOAT32 }))
  1179. .ATTR(mode, String, "mean")
  1180. .ATTR(scale_grad_by_freq, Bool, false)
  1181. .ATTR(sparse, Bool, false)
  1182. .ATTR(include_last_offset, Bool, false)
  1183. .OP_END_FACTORY_REG(EmbeddingBag)
  1184. /**
  1185. * @brief:LSTMP calculation
  1186. * @par Inputs:
  1187. * eight inputs:
  1188. * @li x:A required Tensor(seq, batch, dim). Must be one of the following types: float16, float32.
  1189. * @li real_mask:A optional Tensor(seq, batch). Must be one of the following types: float16, float32.
  1190. * @li init_h:A optional Tensor(batch, state). Must be one of the following types: float16, float32.
  1191. * @li init_c:A optional Tensor(batch, hidden). Must be one of the following types: float16, float32.
  1192. * @li wx:A required Tensor(4*hidden, dim). Must be one of the following types: float16, float32.
  1193. * @li wr:A required Tensor(4*hidden, state). Must be one of the following types: float16, float32.
  1194. * @li bias:A optional Tensor(hidden). Must be one of the following types: float16, float32. The format must be ND.
  1195. * @li project: A optional Tensor. Must be one of the following types: float16, float32.
  1196. *
  1197. * @par Outputs:
  1198. *three outputs:
  1199. *@li y:A Tensor. Must be one of the following types: float16, float32.
  1200. *@li output_h:A Tensor. Must be one of the following types: float16, float32.
  1201. *@li output_c:A Tensor. Must be one of the following types: float16, float32.
  1202. *
  1203. *@par Attributes:
  1204. *time_major:An bool identifying the time major in the op. Default to false.
  1205. * @par Restrictions:
  1206. * Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1207. */
  1208. REG_OP(LSTMP)
  1209. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1210. .INPUT(wx, TensorType({DT_FLOAT16, DT_FLOAT}))
  1211. .INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT}))
  1212. .INPUT(wr, TensorType({DT_FLOAT16, DT_FLOAT}))
  1213. .INPUT(project, TensorType({DT_FLOAT16, DT_FLOAT}))
  1214. .OPTIONAL_INPUT(real_mask, TensorType({DT_FLOAT16, DT_FLOAT}))
  1215. .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1216. .OPTIONAL_INPUT(init_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  1217. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1218. .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT}))
  1219. .OUTPUT(output_c, TensorType({DT_FLOAT16, DT_FLOAT}))
  1220. .ATTR(time_major, Bool, false)
  1221. .OP_END_FACTORY_REG(LSTMP)
  1222. } // namespace ge
  1223. #endif // OPS_BUILT_IN_OP_PROTO_INC_RNN_H_

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