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.

image_ops.h 50 kB

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
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
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
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
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
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347
  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 image_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_IMAGE_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_IMAGE_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. *@brief Adjust the hue of one or more images . \n
  26. *@par Inputs:
  27. *Input images is a tensor of at least 3 dimensions. The last dimension is
  28. interpretted as channels, and must be three. Inputs include:
  29. *@li images:A Tensor of type float. Images to adjust. At least 3-D.
  30. *@li delta:A Tensor of type float. A float delta to add to the hue . \n
  31. *@par Outputs:
  32. *y:A Tensor of type float . \n
  33. *@attention Constraints:
  34. *Input images is a tensor of at least 3 dimensions. The last dimension is
  35. interpretted as channels, and must be three . \n
  36. *@par Third-party framework compatibility
  37. *Compatible with tensorflow AdjustHue operator.
  38. */
  39. REG_OP(AdjustHue)
  40. .INPUT(images, TensorType({DT_FLOAT16,DT_FLOAT}))
  41. .INPUT(delta, TensorType({DT_FLOAT}))
  42. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  43. .OP_END_FACTORY_REG(AdjustHue)
  44. /**
  45. *@brief Adjust the saturation of one or more images . \n
  46. *@par Inputs:
  47. *Input images is a tensor of at least 3 dimensions. The last dimension is
  48. interpretted as channels, and must be three. Inputs include:
  49. *@li images:A Tensor of type float. Images to adjust. At least 3-D.
  50. *@li scale:A Tensor of type float. A float scale to add to the saturation . \n
  51. *@par Outputs:
  52. *y:A Tensor of type float . \n
  53. *@attention Constraints:
  54. *Input images is a tensor of at least 3 dimensions. The last dimension is
  55. interpretted as channels, and must be three . \n
  56. *@par Third-party framework compatibility
  57. *Compatible with tensorflow AdjustSaturation operator.
  58. */
  59. REG_OP(AdjustSaturation)
  60. .INPUT(images, TensorType({DT_FLOAT16,DT_FLOAT}))
  61. .INPUT(scale, TensorType({DT_FLOAT}))
  62. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  63. .OP_END_FACTORY_REG(AdjustSaturation)
  64. /**
  65. *@brief Adjust the contrast of one or more images . \n
  66. *@par Inputs:
  67. *Input images is a tensor of at least 3 dimensions. The last 3 dimensions are
  68. interpreted as '[height, width, channels]'. Inputs include:
  69. *@li images:A Tensor of type float. Images to adjust. At least 3-D.
  70. *@li scale:A Tensor of type float. A float multiplier for adjusting contrast . \n
  71. *@par Outputs:
  72. *y:A Tensor of type float . \n
  73. *@attention Constraints:
  74. *Input images is a tensor of at least 3 dimensions. The last dimension is
  75. interpretted as channels, and must be three . \n
  76. *@par Third-party framework compatibility
  77. *Compatible with tensorflow AdjustContrast operator.
  78. */
  79. REG_OP(AdjustContrast)
  80. .INPUT(images, TensorType({DT_FLOAT16,DT_FLOAT}))
  81. .INPUT(contrast_factor, TensorType({DT_FLOAT}))
  82. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  83. .OP_END_FACTORY_REG(AdjustContrast)
  84. /**
  85. *@brief Extracts crops from the input image tensor and resizes them. Extracts
  86. crops from the input image tensor and resizes them using bilinear sampling or
  87. nearest neighbor sampling to a common output size specified by crop_size . \n
  88. *@par Inputs:
  89. *Input images must be a 4-D tensor. Inputs include:
  90. *@li images:A Tensor. Must be one of the following types:uint8, uint16, int8,
  91. int16, int32, int64, float16, float, double. A 4-D tensor of shape
  92. [batch, image_height, image_width, depth].
  93. *@li boxes: A Tensor of type float. A 2-D tensor of shape [num_boxes, 4].
  94. *@li box_index: A Tensor of type int32. A 1-D tensor of shape [num_boxes] with
  95. int32 values in [0, batch).
  96. *@li crop_size: A Tensor of type int32. A 1-D tensor of 2 elements, crop_size
  97. = [crop_height, crop_width]. All cropped image patches are resized to this size . \n
  98. *@par Attributes:
  99. *@li extrapolation_value: An optional float. Defaults to 0. Value used for
  100. extrapolation, when applicable.
  101. *@li method: An optional string from: '"bilinear", "nearest"'. Defaults to
  102. "bilinear". Currently two sampling methods are supported: Bilinear and
  103. NearestNeighbor . \n
  104. *@par Outputs:
  105. *y:A Tensor of type float . \n
  106. *@attention Constraints:
  107. *Input images must be a 4-D tensor . \n
  108. *@par Third-party framework compatibility
  109. *Compatible with tensorflow CropAndResize operator.
  110. */
  111. REG_OP(CropAndResize)
  112. .INPUT(x, TensorType({DT_UINT8, DT_UINT16, DT_INT8, \
  113. DT_INT16, DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  114. .INPUT(boxes, TensorType({DT_FLOAT}))
  115. .INPUT(box_index, TensorType({DT_INT32}))
  116. .INPUT(crop_size, TensorType({DT_INT32}))
  117. .OUTPUT(y, TensorType({DT_FLOAT}))
  118. .ATTR(extrapolation_value, Float, 0)
  119. .ATTR(method, String, "bilinear")
  120. .OP_END_FACTORY_REG(CropAndResize)
  121. /**
  122. *@brief Extracts crops from the input image tensor and resizes them.
  123. * Extracts crops from the input image tensor and resizes them using bilinear sampling or
  124. * nearest neighbor sampling to a common output size specified by crop_size . \n
  125. *@par Inputs:
  126. *Input images must be a 5HD tensor. Inputs include:
  127. *@li x:A Tensor. Must be one of the following types:float16, float. A 5HD tensor of shape
  128. * [batch, C1, image_height, image_width, C0].
  129. *@li boxes: A Tensor of type float. A 2-D tensor of shape [num_boxes, 4].
  130. *@li box_index: A Tensor of type int32. A 1-D tensor of shape [num_boxes] with int32 values in [0, batch) . \n
  131. *@par Attributes:
  132. *@li crop_size: list int. [crop_height, crop_width]. All cropped image patches are resized to this size.
  133. *@li extrapolation_value: An optional float. Defaults to 0. Value used for extrapolation, when applicable.
  134. *@li method: An optional string from: '"bilinear"'. Defaults to "bilinear" . \n
  135. *@par Outputs:
  136. *y:A Tensor of type float . \n
  137. *@attention Constraints:
  138. *Input images must be a 5HD tensor . \n
  139. *@par Third-party framework compatibility
  140. *Compatible with tensorflow CropAndResize operator.
  141. * @par Restrictions:
  142. * Warning: THIS FUNCTION IS DEPRECATED. Please use CropAndResize instead.
  143. */
  144. REG_OP(CropAndResizeD)
  145. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  146. .INPUT(boxes, TensorType({DT_FLOAT}))
  147. .INPUT(box_index, TensorType({DT_INT32}))
  148. .OUTPUT(y, TensorType({DT_FLOAT}))
  149. .REQUIRED_ATTR(crop_size, ListInt)
  150. .ATTR(extrapolation_value, Float, 0)
  151. .ATTR(method, String, "bilinear")
  152. .OP_END_FACTORY_REG(CropAndResizeD)
  153. /**
  154. *@brief Computes the gradient of the crop_and_resize op wrt the input
  155. boxes tensor . \n
  156. *@par Inputs:
  157. *Input images and grads must be a 4-D tensor. Inputs include:
  158. *@li grads: A 4-D tensor of shape [num_boxes, crop_height, crop_width, depth].
  159. *@li images: A 4-D tensor of shape [batch, image_height, image_width, depth].
  160. Both image_height and image_width need to be positive.
  161. *@li boxes: A 2-D tensor of shape [num_boxes, 4]. The i-th row of the tensor
  162. specifies the coordinates of a box in the box_ind[i] image and is specified in
  163. normalized coordinates [y1, x1, y2, x2].
  164. *@li box_index: A 1-D tensor of shape [num_boxes] with int32 values in
  165. [0, batch). The value of box_ind[i] specifies the image that the i-th box
  166. refers to . \n
  167. *@par Attributes:
  168. method: A string specifying the interpolation method. Only 'bilinear' is
  169. supported for now . \n
  170. *@par Outputs:
  171. *y:A 2-D tensor of shape [num_boxes, 4] . \n
  172. *@attention Constraints:
  173. *Input images and grads must be a 4-D tensor . \n
  174. *@par Third-party framework compatibility
  175. *Compatible with tensorflow CropAndResizeGradBoxes operator.
  176. */
  177. REG_OP(CropAndResizeGradBoxes)
  178. .INPUT(grads, TensorType({DT_FLOAT}))
  179. .INPUT(images, TensorType({DT_UINT8, DT_UINT16, DT_INT8, DT_INT16, \
  180. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  181. .INPUT(boxes, TensorType({DT_FLOAT}))
  182. .INPUT(box_index, TensorType({DT_INT32}))
  183. .OUTPUT(y, TensorType({DT_FLOAT}))
  184. .ATTR(method, String, "bilinear")
  185. .OP_END_FACTORY_REG(CropAndResizeGradBoxes)
  186. /**
  187. *@brief Computes the gradient of the crop_and_resize op wrt the input
  188. images tensor . \n
  189. *@par Inputs:
  190. *Input grads must be a 4-D tensor. Inputs include:
  191. *@li grads: A 4-D tensor of shape [num_boxes, crop_height, crop_width, depth].
  192. *@li boxes: A 2-D tensor of shape [num_boxes, 4]. The i-th row of the tensor
  193. specifies the coordinates of a box in the box_ind[i] image and is specified
  194. in normalized coordinates [y1, x1, y2, x2].
  195. *@li box_index: A 1-D tensor of shape [num_boxes] with int32 values in
  196. [0, batch). The value of box_ind[i] specifies the image that the i-th box
  197. refers to.
  198. *@li image_size: A 1-D tensor with value [batch, image_height, image_width,
  199. depth] containing the original image size. Both image_height and image_width
  200. need to be positive . \n
  201. *@par Attributes:
  202. method: A string specifying the interpolation method. Only 'bilinear' is
  203. supported for now . \n
  204. *@par Outputs:
  205. *y:A 4-D tensor of shape [batch, image_height, image_width, depth] . \n
  206. *@attention Constraints:
  207. *Input grads must be a 4-D tensor . \n
  208. *@par Third-party framework compatibility
  209. *Compatible with tensorflow CropAndResizeGradImage operator.
  210. */
  211. REG_OP(CropAndResizeGradImage)
  212. .INPUT(grads, TensorType({DT_FLOAT}))
  213. .INPUT(boxes, TensorType({DT_FLOAT}))
  214. .INPUT(box_index, TensorType({DT_INT32}))
  215. .INPUT(image_size, TensorType({DT_INT32}))
  216. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  217. .ATTR(method, String, "bilinear")
  218. .REQUIRED_ATTR(T, Type)
  219. .OP_END_FACTORY_REG(CropAndResizeGradImage)
  220. /**
  221. *@brief Extracts a glimpse from the input tensor . \n
  222. *@par Inputs:
  223. *Input x must be a 4-D tensor. Inputs include:
  224. *@li x: A 4-D float tensor of shape [batch_size, height, width, channels].
  225. *@li size: A 1-D tensor of 2 elements containing the size of the glimpses to
  226. extract. The glimpse height must be specified first, following by the glimpse
  227. width.
  228. *@li offsets: A 2-D integer tensor of shape [batch_size, 2] containing the y,
  229. x locations of the center of each window . \n
  230. *@par Attributes:
  231. *@li centered: indicates if the offset coordinates are centered relative to
  232. the image, in which case the (0, 0) offset is relative to the center of the
  233. input images. If false, the (0,0) offset corresponds to the upper left corner
  234. of the input images.
  235. *@li normalized: indicates if the offset coordinates are normalized.
  236. *@li uniform_noise: indicates if the noise should be generated using a
  237. uniform distribution or a Gaussian distribution.
  238. *@li noise: indicates if the noise should uniform, gaussian, or zero.
  239. The default is uniform which means the the noise type will be decided by
  240. uniform_noise . \n
  241. *@par Outputs:
  242. *y:A tensor representing the glimpses [batch_size, glimpse_height,
  243. glimpse_width, channels] . \n
  244. *@attention Constraints:
  245. *Input x must be a 4-D tensor . \n
  246. *@par Third-party framework compatibility
  247. *Compatible with tensorflow CropAndResizeGradImage operator.
  248. */
  249. REG_OP(ExtractGlimpse)
  250. .INPUT(x, TensorType({DT_FLOAT}))
  251. .INPUT(size, TensorType({DT_INT32}))
  252. .INPUT(offsets, TensorType({DT_FLOAT}))
  253. .OUTPUT(y, TensorType({DT_FLOAT}))
  254. .ATTR(centered, Bool, true)
  255. .ATTR(normalized, Bool, true)
  256. .ATTR(uniform_noise, Bool, true)
  257. .ATTR(noise, String, "uniform")
  258. .OP_END_FACTORY_REG(ExtractGlimpse)
  259. /**
  260. *@brief Convert one or more images from HSV to RGB . \n
  261. *@par Inputs:
  262. *Last dimension of input x must be size 3. Inputs include:
  263. *images: 1-D or higher rank. HSV data to convert. Last dimension must be size 3 . \n
  264. *@par Outputs:
  265. *y:images converted to RGB . \n
  266. *@attention Constraints:
  267. *Last dimension of input x must be size 3 . \n
  268. *@par Third-party framework compatibility
  269. *Compatible with tensorflow HSVToRGB operator.
  270. */
  271. REG_OP(HSVToRGB)
  272. .INPUT(images, TensorType({DT_FLOAT16,DT_FLOAT,DT_DOUBLE}))
  273. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT,DT_DOUBLE}))
  274. .OP_END_FACTORY_REG(HSVToRGB)
  275. /**
  276. *@brief Resize quantized images to size using quantized bilinear interpolation . \n
  277. *@par Inputs:
  278. *Input images must be a 4-D tensor. Inputs include:
  279. *@li images: 4-D with shape [batch, height, width, channels].
  280. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
  281. size for the images.
  282. *@li min: A Tensor of type float.
  283. *@li max: A Tensor of type float . \n
  284. *@par Attributes:
  285. *@li align_corners: An optional bool. Defaults to False. If true, the centers
  286. of the 4 corner pixels of the input and output tensors are aligned, preserving
  287. the values at the corner pixels. Defaults to false.
  288. *@li half_pixel_centers: indicates if the offset coordinates are normalized . \n
  289. *@par Outputs:
  290. *@li resized_images: 4-D with shape [batch, new_height, new_width, channels].
  291. *@li y_min: A Tensor of type float.
  292. *@li y_max: A Tensor of type float . \n
  293. *@attention Constraints:
  294. *Input images and output images must be quantized types . \n
  295. *@par Third-party framework compatibility
  296. *Compatible with tensorflow QuantizedResizeBilinear operator.
  297. */
  298. REG_OP(QuantizedResizeBilinear)
  299. .INPUT(images, TensorType({DT_QUINT8,DT_QINT32,DT_FLOAT}))
  300. .INPUT(size, TensorType({ DT_INT32 }))
  301. .INPUT(min, TensorType({ DT_FLOAT }))
  302. .INPUT(max, TensorType({ DT_FLOAT }))
  303. .OUTPUT(resized_images, TensorType({DT_QUINT8,DT_QINT32,DT_FLOAT }))
  304. .OUTPUT(y_min, TensorType({ DT_FLOAT }))
  305. .OUTPUT(y_max, TensorType({ DT_FLOAT }))
  306. .ATTR(align_corners, Bool, false)
  307. .ATTR(half_pixel_centers, Bool, false)
  308. .OP_END_FACTORY_REG(QuantizedResizeBilinear)
  309. /**
  310. *@brief Resize images to size using area interpolation . \n
  311. *@par Inputs:
  312. *Input images must be a 4-D tensor. Inputs include:
  313. *@li images: 4-D with shape [batch, height, width, channels].
  314. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width.
  315. The new size for the images . \n
  316. *@par Attributes:
  317. *align_corners: If true, the centers of the 4 corner pixels of the input and
  318. output tensors are aligned, preserving the values at the corner pixels.
  319. Defaults to false . \n
  320. *@par Outputs:
  321. *y: 4-D with shape [batch, new_height, new_width, channels] . \n
  322. *@attention Constraints:
  323. *Input images can be of different types but output images are always float . \n
  324. *@par Third-party framework compatibility
  325. *Compatible with tensorflow ResizeArea operator.
  326. */
  327. REG_OP(ResizeArea)
  328. .INPUT(images, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, \
  329. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  330. .INPUT(size, TensorType({DT_INT32}))
  331. .OUTPUT(y, TensorType({DT_FLOAT}))
  332. .ATTR(align_corners, Bool, false)
  333. .OP_END_FACTORY_REG(ResizeArea)
  334. /**
  335. *@brief Computes the gradient of bicubic interpolation . \n
  336. *@par Inputs:
  337. *Input grads must be a 4-D tensor. Inputs include:
  338. *@li grads: A Tensor of type float. 4-D with shape [batch, height, width,
  339. channels].
  340. *@li original_image: A Tensor. Must be one of the following types: float,
  341. double. 4-D with shape [batch, orig_height, orig_width, channels], The image
  342. tensor that was resized . \n
  343. *@par Attributes:
  344. *@li align_corners: An optional bool. Defaults to False. If true, the centers
  345. of the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  346. false.
  347. *@li half_pixel_centers: An optional bool. Defaults to False . \n
  348. *@par Outputs:
  349. *y: A Tensor. Has the same type as original_image . \n
  350. *@attention Constraints:
  351. *Input images can be of different types but output images are always float . \n
  352. *@par Third-party framework compatibility
  353. *Compatible with tensorflow ResizeBicubicGrad operator.
  354. */
  355. REG_OP(ResizeBicubicGrad)
  356. .INPUT(grads, TensorType({DT_FLOAT}))
  357. .INPUT(original_image, TensorType({DT_FLOAT, DT_DOUBLE}))
  358. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE}))
  359. .ATTR(align_corners, Bool, false)
  360. .ATTR(half_pixel_centers, Bool, false)
  361. .OP_END_FACTORY_REG(ResizeBicubicGrad)
  362. /**
  363. *@brief Resize images to size using bicubic interpolation . \n
  364. *@par Inputs:
  365. *Input images must be a 4-D tensor. Inputs include:
  366. *@li images: 4-D with shape [batch, height, width, channels].
  367. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
  368. size for the images . \n
  369. *@par Attributes:
  370. *@li align_corners: If true, the centers of the 4 corner pixels of the input
  371. and output tensors are aligned, preserving the values at the corner pixels.
  372. Defaults to false.
  373. *@li half_pixel_centers: An optional bool. Defaults to False . \n
  374. *@par Outputs:
  375. *y: 4-D with shape [batch, new_height, new_width, channels] . \n
  376. *@attention Constraints:
  377. *Input images can be of different types but output images are always float . \n
  378. *@par Third-party framework compatibility
  379. *Compatible with tensorflow ResizeBicubic operator.
  380. */
  381. REG_OP(ResizeBicubic)
  382. .INPUT(images, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, \
  383. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  384. .INPUT(size, TensorType({DT_INT32}))
  385. .OUTPUT(y, TensorType({DT_FLOAT}))
  386. .ATTR(align_corners, Bool, false)
  387. .ATTR(half_pixel_centers, Bool, false)
  388. .OP_END_FACTORY_REG(ResizeBicubic)
  389. /**
  390. *@brief Computes the gradient of nearest neighbor interpolation . \n
  391. *@par Inputs:
  392. *Input grads must be a 4-D tensor. Inputs include:
  393. *@li grads: A Tensor. Must be one of the following types: uint8, int8, int32,
  394. float16, float, double. 4-D with shape [batch, height, width, channels].
  395. *@li size: A 1-D int32 Tensor of 2 elements: orig_height, orig_width.
  396. The original input size . \n
  397. *@par Attributes:
  398. *@li align_corners: An optional bool. Defaults to False. If true, the centers
  399. of the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  400. false.
  401. *@li half_pixel_centers: An optional bool. Defaults to False . \n
  402. *@par Outputs:
  403. *y: A Tensor. Has the same type as grads . \n
  404. *@attention Constraints:
  405. *Input grads must be a 4-D tensor . \n
  406. *@par Third-party framework compatibility
  407. *Compatible with tensorflow ResizeNearestNeighborV2Grad operator.
  408. */
  409. REG_OP(ResizeNearestNeighborV2Grad)
  410. .INPUT(grads, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  411. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  412. .INPUT(size, TensorType({DT_INT32}))
  413. .OUTPUT(y, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  414. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  415. .ATTR(align_corners, Bool, false)
  416. .ATTR(half_pixel_centers, Bool, false)
  417. .OP_END_FACTORY_REG(ResizeNearestNeighborV2Grad)
  418. /**
  419. *@brief Computes the gradient of nearest neighbor interpolation . \n
  420. *@par Inputs:
  421. *Input grads must be a 4-D tensor. Inputs include:
  422. *grads: A Tensor. 4-D with shape [batch, height, width, channels].
  423. *@par Attributes:
  424. *@li align_corners: An optional bool. Defaults to False. If true, the centers
  425. of the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  426. false.
  427. *@li size: An list type. Specify the images size . \n
  428. *@par Outputs:
  429. *y: A Tensor. Has the same type as grads . \n
  430. *@par Third-party framework compatibility
  431. *Compatible with tensorflow ResizeNearestNeighborV2GradD operator.
  432. *
  433. * @par Restrictions:
  434. * Warning: THIS FUNCTION IS DEPRECATED. Please use ResizeNearestNeighborV2Grad instead.
  435. */
  436. REG_OP(ResizeNearestNeighborV2GradD)
  437. .INPUT(grads, TensorType({DT_FLOAT}))
  438. .OUTPUT(y, TensorType({DT_FLOAT}))
  439. .REQUIRED_ATTR(size, ListInt)
  440. .ATTR(align_corners, Bool, false)
  441. .ATTR(half_pixel_centers, Bool, false)
  442. .OP_END_FACTORY_REG(ResizeNearestNeighborV2GradD)
  443. /**
  444. *@brief Computes the gradient of bilinear interpolation . \n
  445. *@par Inputs:
  446. *Input grads must be a 4-D tensor. Inputs include:
  447. *@li grads: A Tensor of type float32. 4-D with shape [batch, height, width,
  448. channels].
  449. *@li original_image: A Tensor. 4-D with shape [batch, orig_height, orig_width,
  450. channels], The image tensor that was resized . \n
  451. *@par Attributes:
  452. *align_corners: An optional bool. Defaults to False. If true, the centers of
  453. the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  454. false . \n
  455. *@par Outputs:
  456. *y: A Tensor. Has the same type as original_image . \n
  457. *@attention Constraints:
  458. *Input grads must be a 4-D tensor . \n
  459. *@par Third-party framework compatibility
  460. *Compatible with tensorflow ResizeBilinearV2Grad operator.
  461. */
  462. REG_OP(ResizeBilinearV2Grad)
  463. .INPUT(grads, TensorType({DT_FLOAT}))
  464. .INPUT(original_image, TensorType::FloatingDataType())
  465. .OUTPUT(y, TensorType({DT_FLOAT}))
  466. .ATTR(align_corners, Bool, false)
  467. .ATTR(half_pixel_centers, Bool, false)
  468. .OP_END_FACTORY_REG(ResizeBilinearV2Grad)
  469. /**
  470. *@brief Resize images to size using bilinear interpolation . \n
  471. *@par Inputs:
  472. *Input images must be a 4-D tensor. Inputs include:
  473. *@li x: 4-D with shape [batch, height, width, channels].
  474. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
  475. size for the images . \n
  476. *@par Attributes:
  477. *align_corners: If true, the centers of the 4 corner pixels of the input and
  478. output tensors are aligned, preserving the values at the corner pixels.
  479. Defaults to false . \n
  480. *@par Outputs:
  481. *y: 4-D with shape [batch, new_height, new_width, channels] . \n
  482. *@attention Constraints:
  483. *Input images can be of different types but output images are always float . \n
  484. *@par Third-party framework compatibility
  485. *Compatible with tensorflow ResizeBilinearV2 operator.
  486. */
  487. REG_OP(ResizeBilinearV2)
  488. .INPUT(x, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16,
  489. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  490. .INPUT(size, TensorType({DT_INT32}))
  491. .OUTPUT(y, TensorType({DT_FLOAT}))
  492. .ATTR(align_corners, Bool, false)
  493. .ATTR(half_pixel_centers, Bool, false)
  494. .OP_END_FACTORY_REG(ResizeBilinearV2)
  495. /**
  496. *@brief Converts one or more images from RGB to HSV . \n
  497. *@par Inputs:
  498. *Last dimension of input images must be size 3. Inputs include:
  499. *images: A Tensor. Must be one of the following types: float, double. 1-D or
  500. higher rank. RGB data to convert. Last dimension must be size 3 . \n
  501. *@par Outputs:
  502. *y: A Tensor. Has the same type as images . \n
  503. *@attention Constraints:
  504. *Outputs a tensor of the same shape as the images tensor, containing the HSV
  505. value of the pixels. The output is only well defined if the value in images
  506. are in [0,1] . \n
  507. *@par Third-party framework compatibility
  508. *Compatible with tensorflow RGBToHSV operator.
  509. */
  510. REG_OP(RGBToHSV)
  511. .INPUT(images, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE }))
  512. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE }))
  513. .OP_END_FACTORY_REG(RGBToHSV)
  514. /**
  515. *@brief Generate a single randomly distorted bounding box for an image . \n
  516. *@par Inputs:
  517. *Input images must be a 4-D tensor. Inputs include:
  518. *@li image_size: 1-D, containing [height, width, channels].
  519. *@li bounding_boxes: 3-D with shape [batch, N, 4] describing the N bounding
  520. boxes associated with the image.
  521. *@li min_object_covered: The cropped area of the image must contain at least
  522. this fraction of any bounding box supplied. The value of this parameter should
  523. be non-negative. In the case of 0, the cropped area does not need to overlap
  524. any of the bounding boxes supplied . \n
  525. *@par Attributes:
  526. *@li seed: If either seed or seed2 are set to non-zero, the random number
  527. generator is seeded by the given seed. Otherwise, it is seeded by a random seed.
  528. *@li seed2: A second seed to avoid seed collision.
  529. *@li aspect_ratio_range: The cropped area of the image must have an aspect
  530. ratio = width / height within this range.
  531. *@li max_attempts: Number of attempts at generating a cropped region of the
  532. image of the specified constraints. After max_attempts failures, return the
  533. entire image.
  534. *@li use_image_if_no_bounding_boxes: Controls behavior if no bounding boxes
  535. supplied. If true, assume an implicit bounding box covering the whole input.
  536. If false, raise an error . \n
  537. *@par Outputs:
  538. *@li begin: 1-D, containing [offset_height, offset_width, 0].
  539. *@li size: 1-D, containing [target_height, target_width, -1].
  540. *@li bboxes: 3-D with shape [1, 1, 4] containing the distorted bounding box . \n
  541. *@attention Constraints:
  542. *Input images can be of different types but output images are always float . \n
  543. *@par Third-party framework compatibility
  544. *Compatible with tensorflow SampleDistortedBoundingBoxExt2 operator.
  545. */
  546. REG_OP(SampleDistortedBoundingBoxExt2)
  547. .INPUT(image_size, TensorType({ DT_UINT8, DT_INT8, DT_INT16, \
  548. DT_INT32, DT_INT64 }))
  549. .INPUT(bounding_boxes, TensorType({ DT_FLOAT }))
  550. .INPUT(min_object_covered, TensorType({ DT_FLOAT }))
  551. .OUTPUT(begin, TensorType({ DT_UINT8, DT_INT8, DT_INT16, \
  552. DT_INT32, DT_INT64 }))
  553. .OUTPUT(size, TensorType({ DT_UINT8, DT_INT8, DT_INT16, \
  554. DT_INT32, DT_INT64 }))
  555. .OUTPUT(bboxes, TensorType({ DT_FLOAT }))
  556. .ATTR(seed, Int, 0)
  557. .ATTR(seed2, Int, 0)
  558. .ATTR(aspect_ratio_range, ListFloat, { 0.75f, 1.33f })
  559. .ATTR(area_range, ListFloat, { 0.05f, 1.0f })
  560. .ATTR(max_attempts, Int, 100)
  561. .ATTR(use_image_if_no_bounding_boxes, Bool, false)
  562. .OP_END_FACTORY_REG(SampleDistortedBoundingBoxExt2)
  563. /**
  564. *@brief Resize images to size using nearest neighbor interpolation . \n
  565. *@par Inputs:
  566. *Input x must be a 4-D tensor. Inputs include:
  567. *@li x: 4-D with shape [batch, height, width, channels].
  568. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width.
  569. The new size for the images . \n
  570. *@par Attributes:
  571. *align_corners: If true, the centers of the 4 corner pixels of the input and
  572. output tensors are aligned, preserving the values at the corner pixels.
  573. Defaults to false . \n
  574. *@par Outputs:
  575. *y: 4-D with shape [batch, new_height, new_width, channels] . \n
  576. *@par Third-party framework compatibility
  577. *Compatible with tensorflow ResizeNearestNeighborV2 operator.
  578. */
  579. REG_OP(ResizeNearestNeighborV2)
  580. .INPUT(x, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  581. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  582. .INPUT(size, TensorType({DT_INT32}))
  583. .OUTPUT(y, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  584. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  585. .ATTR(align_corners, Bool, false)
  586. .ATTR(half_pixel_centers, Bool, false)
  587. .OP_END_FACTORY_REG(ResizeNearestNeighborV2)
  588. /**
  589. *@brief Draw bounding boxes on a batch of images . \n
  590. *@par Inputs:
  591. *Input images must be a 4-D tensor. Inputs include:
  592. *@li images: A Tensor. Must be one of the following types: float. 4-D with
  593. shape [batch, height, width, depth]. A batch of images.
  594. *@li boxes: A Tensor of type float32. 3-D with shape [batch,
  595. num_bounding_boxes, 4] containing bounding boxes . \n
  596. *@par Outputs:
  597. *A Tensor. Has the same type as images . \n
  598. *@attention Constraints:
  599. *Input images must be a 4-D tensor . \n
  600. *@par Third-party framework compatibility
  601. *Compatible with tensorflow DrawBoundingBoxes operator.
  602. */
  603. REG_OP(DrawBoundingBoxes)
  604. .INPUT(images, TensorType({DT_FLOAT}))
  605. .INPUT(boxes, TensorType({DT_FLOAT}))
  606. .OUTPUT(y, TensorType({DT_FLOAT}))
  607. .OP_END_FACTORY_REG(DrawBoundingBoxes)
  608. /**
  609. *@brief Greedily selects a subset of bounding boxes in descending order of
  610. score . \n
  611. *@par Inputs:
  612. *Input boxes and scores must be float type. Inputs include:
  613. *@li boxes: A 2-D float tensor of shape [num_boxes, 4].
  614. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  615. score corresponding to each box (each row of boxes).
  616. *@li max_output_size: A scalar integer tensor representing the maximum number
  617. of boxes to be selected by non max suppression . \n
  618. *@par Attributes:
  619. *iou_threshold: A float representing the threshold for deciding whether boxes
  620. overlap too much with respect to IOU . \n
  621. *@par Outputs:
  622. *selected_indices: A 1-D integer tensor of shape [M] representing the selected
  623. indices from the boxes tensor, where M <= max_output_size . \n
  624. *@attention Constraints:
  625. *Input boxes and scores must be float type . \n
  626. *@par Third-party framework compatibility
  627. *Compatible with tensorflow NonMaxSuppression operator.
  628. */
  629. REG_OP(NonMaxSuppression)
  630. .INPUT(boxes, TensorType({DT_FLOAT}))
  631. .INPUT(scores, TensorType({DT_FLOAT}))
  632. .INPUT(max_output_size, TensorType({DT_INT32}))
  633. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  634. .ATTR(iou_threshold, Float, 0.5f)
  635. .OP_END_FACTORY_REG(NonMaxSuppression)
  636. /**
  637. *@brief Greedily selects a subset of bounding boxes in descending order of
  638. score . \n
  639. *@par Inputs:
  640. *Input boxes and scores must be float type. Inputs include:
  641. *@li boxes: A 2-D float tensor of shape [num_boxes, 4].
  642. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  643. score corresponding to each box (each row of boxes).
  644. *@li max_output_size: A scalar integer tensor representing the maximum number
  645. of boxes to be selected by non max suppression.
  646. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding
  647. whether boxes overlap too much with respect to IOU . \n
  648. *@par Outputs:
  649. *selected_indices: A 1-D integer tensor of shape [M] representing the selected
  650. indices from the boxes tensor, where M <= max_output_size . \n
  651. *@attention Constraints:
  652. *Input boxes and scores must be float type . \n
  653. *@par Third-party framework compatibility
  654. *Compatible with tensorflow NonMaxSuppressionV2 operator.
  655. */
  656. REG_OP(NonMaxSuppressionV2)
  657. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  658. .INPUT(scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  659. .INPUT(max_output_size, TensorType({DT_INT32}))
  660. .INPUT(iou_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  661. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  662. .OP_END_FACTORY_REG(NonMaxSuppressionV2)
  663. /**
  664. *@brief Greedily selects a subset of bounding boxes in descending order of
  665. score . \n
  666. *@par Inputs:
  667. *Input boxes and scores must be float type. Inputs include:
  668. *@li boxes: A 2-D float tensor of shape [num_boxes, 4].
  669. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  670. score corresponding to each box (each row of boxes).
  671. *@li max_output_size: A scalar integer tensor representing the maximum number
  672. of boxes to be selected by non max suppression.
  673. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding
  674. whether boxes overlap too much with respect to IOU.
  675. *@li score_threshold: A 0-D float tensor representing the threshold for
  676. deciding when to remove boxes based on score . \n
  677. *@par Outputs:
  678. *selected_indices: A 1-D integer tensor of shape [M] representing the selected
  679. indices from the boxes tensor, where M <= max_output_size . \n
  680. *@attention Constraints:
  681. *Input boxes and scores must be float type . \n
  682. *@par Third-party framework compatibility
  683. *Compatible with tensorflow NonMaxSuppressionV3 operator.
  684. */
  685. REG_OP(NonMaxSuppressionV3)
  686. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  687. .INPUT(scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  688. .INPUT(max_output_size, TensorType({DT_INT32}))
  689. .INPUT(iou_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  690. .INPUT(score_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  691. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  692. .OP_END_FACTORY_REG(NonMaxSuppressionV3)
  693. /**
  694. *@brief Greedily selects a subset of bounding boxes in descending order of
  695. score . \n
  696. *@par Inputs:
  697. *Input boxes and scores must be float type. Inputs include:
  698. *@li boxes: A 2-D float tensor of shape [num_boxes, 4].
  699. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  700. score corresponding to each box (each row of boxes).
  701. *@li max_output_size: A scalar integer tensor representing the maximum number
  702. of boxes to be selected by non max suppression.
  703. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding
  704. whether boxes overlap too much with respect to IOU.
  705. *@li score_threshold: A 0-D float tensor representing the threshold for
  706. deciding when to remove boxes based on score . \n
  707. *@par Attributes:
  708. *pad_to_max_output_size: If true, the output selected_indices is padded
  709. to be of length max_output_size. Defaults to false . \n
  710. *@par Outputs:
  711. *@li selected_indices: A 1-D integer tensor of shape [M] representing the
  712. selected indices from the boxes tensor, where M <= max_output_size.
  713. *@li valid_outputs: A 0-D integer tensor representing the number of valid
  714. elements in selected_indices, with the valid elements appearing first . \n
  715. *@attention Constraints:
  716. *Input boxes and scores must be float type . \n
  717. *@par Third-party framework compatibility
  718. *Compatible with tensorflow NonMaxSuppressionV4 operator.
  719. */
  720. REG_OP(NonMaxSuppressionV4)
  721. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  722. .INPUT(scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  723. .INPUT(max_output_size, TensorType({DT_INT32}))
  724. .INPUT(iou_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  725. .INPUT(score_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  726. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  727. .OUTPUT(valid_outputs, TensorType({DT_INT32}))
  728. .ATTR(pad_to_max_output_size, Bool, false)
  729. .OP_END_FACTORY_REG(NonMaxSuppressionV4)
  730. /**
  731. *@brief Greedily selects a subset of bounding boxes in descending order of
  732. score . \n
  733. *@par Inputs:
  734. *Input overlaps and scores must be float type. Inputs include:
  735. *@li overlaps: A 2-D float tensor of shape [num_boxes, num_boxes]
  736. representing the n-by-n box overlap values.
  737. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  738. score corresponding to each box (each row of boxes).
  739. *@li max_output_size: A scalar integer tensor representing the maximum number
  740. of boxes to be selected by non max suppression.
  741. *@li overlap_threshold: A 0-D float tensor representing the threshold for
  742. deciding whether boxes overlap too.
  743. *@li score_threshold: A 0-D float tensor representing the threshold for
  744. deciding when to remove boxes based on score . \n
  745. *@par Attributes:
  746. *pad_to_max_output_size: If true, the output selected_indices is padded
  747. to be of length max_output_size. Defaults to false . \n
  748. *@par Outputs:
  749. *selected_indices: A 1-D integer tensor of shape [M] representing the
  750. selected indices from the boxes tensor, where M <= max_output_size . \n
  751. *@par Third-party framework compatibility
  752. *Compatible with tensorflow NonMaxSuppressionWithOverlaps operator.
  753. */
  754. REG_OP(NonMaxSuppressionWithOverlaps)
  755. .INPUT(overlaps, TensorType({DT_FLOAT}))
  756. .INPUT(scores, TensorType({DT_FLOAT}))
  757. .INPUT(max_output_size, TensorType({DT_INT32}))
  758. .INPUT(overlap_threshold, TensorType({DT_FLOAT}))
  759. .INPUT(score_threshold, TensorType({DT_FLOAT}))
  760. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  761. .OP_END_FACTORY_REG(NonMaxSuppressionWithOverlaps)
  762. /**
  763. *@brief JPEG-encode an image . \n
  764. *@par Inputs:
  765. *Input image must be unit8 type. Inputs include:
  766. *image: A 3-D uint8 Tensor of shape [height, width, channels] . \n
  767. *@par Attributes:
  768. *@li format: Per pixel image format.
  769. *@li quality: Quality of the compression from 0 to 100 (higher is better
  770. and slower).
  771. *@li progressive: If True, create a JPEG that loads progressively (coarse
  772. to fine).
  773. *@li optimize_size: If True, spend CPU/RAM to reduce size with no quality
  774. change.
  775. *@li chroma_downsampling: A boolean, default is true.
  776. *@li density_unit: Unit used to specify x_density and y_density: pixels per
  777. inch ('in') or centimeter ('cm').
  778. *@li x_density: Horizontal pixels per density unit.
  779. *@li y_density: Vertical pixels per density unit.
  780. *@li xmp_metadata: If not empty, embed this XMP metadata in the image header . \n
  781. *@par Outputs:
  782. *contents: 0-D. JPEG-encoded image . \n
  783. *@par Third-party framework compatibility
  784. *Compatible with tensorflow EncodeJpeg operator.
  785. */
  786. REG_OP(EncodeJpeg)
  787. .INPUT(image, TensorType({DT_UINT8}))
  788. .OUTPUT(contents, TensorType({DT_STRING}))
  789. .ATTR(format, String, "")
  790. .ATTR(quality, Int, 95)
  791. .ATTR(progressive, Bool, false)
  792. .ATTR(optimize_size, Bool, false)
  793. .ATTR(chroma_downsampling, Bool, true)
  794. .ATTR(density_unit, String, "in")
  795. .ATTR(x_density, Int, 300)
  796. .ATTR(y_density, Int, 300)
  797. .ATTR(xmp_metadata, String, "")
  798. .OP_END_FACTORY_REG(EncodeJpeg)
  799. /**
  800. *@brief PNG-encode an image.
  801. *@par Inputs:
  802. *Input image must be unit8 or uint16 type. Inputs include:
  803. *image: is a 3-D uint8 or uint16 Tensor of shape [height, width, channels]
  804. where channels is: 1: for grayscale; 2: for grayscale + alpha; 3: for RGB;
  805. 4: for RGBA . \n
  806. *@par Attributes:
  807. *compression: Compression level . \n
  808. *@par Outputs:
  809. *contents: 0-D. PNG-encoded image . \n
  810. *@par Third-party framework compatibility
  811. *Compatible with tensorflow EncodePng operator.
  812. */
  813. REG_OP(EncodePng)
  814. .INPUT(image, TensorType({DT_UINT8, DT_UINT16}))
  815. .OUTPUT(contents, TensorType({DT_STRING}))
  816. .ATTR(compression, Int, -1)
  817. .OP_END_FACTORY_REG(EncodePng)
  818. /**
  819. *@brief Resizes "images" to "size" using bilinear interpolation . \n
  820. *@par Inputs:
  821. * One input:
  822. *x: An NC1HWC0 Tensor.
  823. * Must be one of the following types: float16, float32 . \n
  824. *@par Attributes:
  825. *@li size: A required int32 Tensor specifying the new size for the images.
  826. No default value.
  827. *@li align_corners: An optional bool. If "true", the centers of the corner
  828. pixels of the input and output tensors are aligned. Defaults to "false" . \n
  829. *@par Outputs:
  830. *y: A Tensor with type float32 and the same format as input "images" . \n
  831. *@attention Constraints:
  832. *@li The input "size" must be a tensor of 2 elements: size[0] <= 2048,
  833. size[1] <= 2048.
  834. *@li The input "images" must be a tensor of 5 elements: images[2] <= 2048,
  835. images[3] <= 2048 . \n
  836. *@par Third-party framework compatibility
  837. * Compatible with TensorFlow operator ResizeBilinearV2D.
  838. *
  839. * @par Restrictions:
  840. * Warning: THIS FUNCTION IS DEPRECATED. Please use ResizeBilinearV2 instead.
  841. */
  842. REG_OP(ResizeBilinearV2D)
  843. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  844. .OUTPUT(y, TensorType({DT_FLOAT}))
  845. .ATTR(align_corners, Bool, false)
  846. .ATTR(half_pixel_centers, Bool, false)
  847. .REQUIRED_ATTR(size, ListInt)
  848. .OP_END_FACTORY_REG(ResizeBilinearV2D)
  849. /**
  850. *@brief Resizes "images" to "size" using bilinear interpolation and keep ratio at the time. \n
  851. *@par Inputs:
  852. * One input:
  853. *images: An NC1HWC0 Tensor.
  854. * Must be one of the following types: float16, float32 . \n
  855. *@par Attributes:
  856. *@li min_dimension: A required int32 attribute for the min dimension for the images.
  857. * No default value.
  858. *@li max_dimension: A required int32 attribute for the max dimension for the images.
  859. * No default value.
  860. *@li align_corners: An optional bool. If "true", the centers of the corner
  861. * pixels of the input and output tensors are aligned. Defaults to "false".
  862. *@li half_pixel_centers: indicates if the offset coordinates are normalized
  863. * Defaults to "false" . \n
  864. *@par Outputs:
  865. *y: A Tensor with type float32 and the same format as input "images" . \n
  866. *@attention Constraints:
  867. * The input "images" must be a tensor of 5 elements: images[2] <= 2048,
  868. images[3] <= 2048.
  869. */
  870. REG_OP(KeepRatioResizeBilinear)
  871. .INPUT(images, TensorType({DT_FLOAT16, DT_FLOAT}))
  872. .OUTPUT(y, TensorType({DT_FLOAT}))
  873. .REQUIRED_ATTR(min_dimension, Int)
  874. .REQUIRED_ATTR(max_dimension, Int)
  875. .ATTR(align_corners, Bool, false)
  876. .ATTR(half_pixel_centers, Bool, false)
  877. .OP_END_FACTORY_REG(KeepRatioResizeBilinear)
  878. /**
  879. *@brief Resizes "images" to "size" using nearest neighbor interpolation . \n
  880. *@par Inputs:
  881. * One input:
  882. *x: An NC1HWC0 Tensor.
  883. * Must be one of the following types: float16, float32, int32, int8, uint8
  884. *@par Attributes:
  885. *@li size: A required int32 Tensor specifying the new size for the images.
  886. No default value.
  887. *@li align_corners: An optional bool. If "true", the centers of the corner
  888. pixels of the input and output tensors are aligned. Defaults to "false" . \n
  889. *@par Outputs:
  890. *y: A Tensor with the same type and format as input "images" . \n
  891. *@attention Constraints:
  892. * The input "size" must be a tensor of 2 elements: size[0] <= 7680,
  893. size[1] <= 4320
  894. *@par Third-party framework compatibility
  895. * Compatible with TensorFlow operator ResizeNearestNeighborV2.
  896. *
  897. * @par Restrictions:
  898. * Warning: THIS FUNCTION IS DEPRECATED. Please use ResizeNearestNeighborV2 instead.
  899. */
  900. REG_OP(ResizeNearestNeighborV2D)
  901. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  902. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  903. .REQUIRED_ATTR(size, ListInt)
  904. .ATTR(align_corners, Bool, false)
  905. .ATTR(half_pixel_centers, Bool, false)
  906. .OP_END_FACTORY_REG(ResizeNearestNeighborV2D)
  907. /**
  908. *@brief Extract the shape information of a JPEG-encoded image . \n
  909. *@par Inputs:
  910. *Input contents must be 0-D. Inputs include:
  911. *contents: 0-D. The JPEG-encoded image . \n
  912. *@par Attributes:
  913. *output_type: The output type of the operation (int32 or int64). Defaults
  914. to int32 . \n
  915. *@par Outputs:
  916. *image_shape: 1-D. The image shape with format [height, width, channels] . \n
  917. *@par Third-party framework compatibility
  918. *Compatible with tensorflow ExtractJpegShape operator.
  919. */
  920. REG_OP(ExtractJpegShape)
  921. .INPUT(contents, TensorType({DT_STRING}))
  922. .OUTPUT(image_shape, TensorType({DT_INT32, DT_INT64}))
  923. .REQUIRED_ATTR(output_type, Type)
  924. .OP_END_FACTORY_REG(ExtractJpegShape)
  925. /**
  926. *@brief Draw bounding boxes on a batch of images . \n
  927. *@par Inputs:
  928. *@li images: 4-D with shape `[batch, height, width, depth]`.
  929. A batch of images.
  930. *@li boxes: 3-D with shape `[batch, num_bounding_boxes, 4]`
  931. containing bounding boxes.
  932. *@li colors: 2-D. A list of RGBA colors to cycle through for the boxes . \n
  933. *@par Outputs:
  934. *y: Returns 4-D with the same shape as `images`.
  935. The batch of input images with bounding boxes drawn on the images . \n
  936. *@par Third-party framework compatibility
  937. * Compatible with tensorflow DrawBoundingBoxesV2 operator.
  938. */
  939. REG_OP(DrawBoundingBoxesV2)
  940. .INPUT(images, TensorType({DT_FLOAT}))
  941. .INPUT(boxes, TensorType({DT_FLOAT}))
  942. .INPUT(colors, TensorType({DT_FLOAT}))
  943. .OUTPUT(y, TensorType({DT_FLOAT}))
  944. .OP_END_FACTORY_REG(DrawBoundingBoxesV2)
  945. /**
  946. *@brief Greedily selects a subset of bounding boxes in descending order of score,
  947. pruning away boxes that have high intersection-over-union (IOU) overlap
  948. with previously selected boxes . \n
  949. *@par Inputs:
  950. *@li boxes: A 2-D float tensor of shape `[num_boxes, 4]`.
  951. *@li scores: A 1-D float tensor of shape `[num_boxes]` representing a single
  952. score corresponding to each box (each row of boxes).
  953. *@li max_output_size: A scalar integer tensor representing the maximum number of
  954. boxes to be selected by non max suppression.
  955. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding whether
  956. boxes overlap too much with respect to IOU.
  957. *@li score_threshold: A 0-D float tensor representing the threshold for deciding when to
  958. remove boxes based on score.
  959. *@li soft_nms_sigma: A 0-D float tensor representing the sigma parameter for Soft NMS . \n
  960. *@par Attributes:
  961. pad_to_max_output_size: If true, the output `selected_indices` is padded to be of length
  962. `max_output_size`. Defaults to false. If not specified, defaults to false . \n
  963. *@par Outputs:
  964. *@li selected_indices: A 1-D integer tensor of shape [M] representing the
  965. selected indices from the boxes tensor, where M <= max_output_size.
  966. *@li selected_scores: A 1-D float tensor of shape `[M]` representing the corresponding
  967. scores for each selected box, where `M <= max_output_size`.
  968. *@li valid_outputs: A 0-D integer tensor representing the number of valid
  969. elements in selected_indices, with the valid elements appearing first . \n
  970. *@par Third-party framework compatibility
  971. * Compatible with tensorflow NonMaxSuppressionV5 operator.
  972. */
  973. REG_OP(NonMaxSuppressionV5)
  974. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  975. .INPUT(scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  976. .INPUT(max_output_size, TensorType({DT_INT32}))
  977. .INPUT(iou_threshold, TensorType({DT_FLOAT16, DT_FLOAT}))
  978. .INPUT(score_threshold, TensorType({DT_FLOAT16, DT_FLOAT}))
  979. .INPUT(soft_nms_sigma, TensorType({DT_FLOAT16, DT_FLOAT}))
  980. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  981. .OUTPUT(selected_scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  982. .OUTPUT(valid_outputs, TensorType({DT_INT32}))
  983. .ATTR(pad_to_max_output_size, Bool, false)
  984. .REQUIRED_ATTR(T, Type)
  985. .OP_END_FACTORY_REG(NonMaxSuppressionV5)
  986. /**
  987. *@brief Resizes "images" to "size" by scale and translate . \n
  988. *@par Inputs:
  989. *@li images: A `Tensor`. Must be one of the following types: `int8`, `uint8`,
  990. `int16`, `uint16`, `int32`, `int64`, `bfloat16`, `float32`, `float64`.
  991. *@li size: A `Tensor` of type `int32`.
  992. *@li scale: A `Tensor` of type `float32`.
  993. *@li translation: A `Tensor` of type `float32` . \n
  994. *@li kernel_type: type is string, default lanczos3
  995. *@li antialias: type is bool, default true \n
  996. *@par Outputs:
  997. *y: A Tensor with type float32 . \n
  998. *@par Third-party framework compatibility
  999. * Compatible with TensorFlow ScaleAndTranslate operator.
  1000. */
  1001. REG_OP(ScaleAndTranslate)
  1002. .INPUT(images, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16,
  1003. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1004. .INPUT(size, TensorType({DT_INT32}))
  1005. .INPUT(scale, TensorType({DT_FLOAT}))
  1006. .INPUT(translation, TensorType({DT_FLOAT}))
  1007. .OUTPUT(y, TensorType({DT_FLOAT}))
  1008. .ATTR(kernel_type, String, "lanczos3")
  1009. .ATTR(antialias, Bool, true)
  1010. .OP_END_FACTORY_REG(ScaleAndTranslate)
  1011. /**
  1012. *@brief Computes the gradient by scale and translate . \n
  1013. *@par Inputs:
  1014. *@li grads: A `Tensor`. Must be one of the following types: `float32`.
  1015. *@li original_image: A `Tensor`. Must have the same type as `grads`.
  1016. *@li scale: A `Tensor` of type `float32`.
  1017. *@li translation: A `Tensor` of type `float32` . \n
  1018. *@li kernel_type: type is string, default lanczos3
  1019. *@li antialias: type is bool, default true
  1020. *@par Outputs:
  1021. *y: A `Tensor`. Has the same type as `grads` . \n
  1022. *@par Third-party framework compatibility
  1023. * Compatible with TensorFlow ScaleAndTranslateGrad operator.
  1024. */
  1025. REG_OP(ScaleAndTranslateGrad)
  1026. .INPUT(grads, TensorType({DT_FLOAT}))
  1027. .INPUT(original_image, TensorType({DT_FLOAT}))
  1028. .INPUT(scale, TensorType({DT_FLOAT}))
  1029. .INPUT(translation, TensorType({DT_FLOAT}))
  1030. .OUTPUT(y, TensorType({DT_FLOAT}))
  1031. .ATTR(kernel_type, String, "lanczos3")
  1032. .ATTR(antialias, Bool, true)
  1033. .OP_END_FACTORY_REG(ScaleAndTranslateGrad)
  1034. /**
  1035. *@brief Greedily selects a subset of bounding boxes in descending order of score,
  1036. This operation performs non_max_suppression on the inputs per batch, across all classes . \n
  1037. *@par Inputs:
  1038. *@li boxes: A 4-D float tensor of shape `[batch_size, num_boxes, q, 4]`. If `q` is 1 then
  1039. same boxes are used for all classes otherwise, if `q` is equal to number of
  1040. classes, class-specific boxes are used.
  1041. *@li scores: A 3-D float tensor of shape `[batch_size, num_boxes, num_classes]`
  1042. representing a single score corresponding to each box (each row of boxes).
  1043. *@li max_output_size_per_class: A scalar integer tensor representing the maximum number of
  1044. boxes to be selected by non max suppression per class.
  1045. *@li max_total_size: A scalar representing maximum number of boxes retained over all classes.
  1046. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding whether
  1047. boxes overlap too much with respect to IOU.
  1048. *@li score_threshold: A 0-D float tensor representing the threshold for deciding when to remove
  1049. boxes based on score . \n
  1050. *@par Attributes:
  1051. *@li pad_per_class: If false, the output nmsed boxes, scores and classes
  1052. are padded/clipped to `max_total_size`. If true, the
  1053. output nmsed boxes, scores and classes are padded to be of length
  1054. `max_size_per_class`*`num_classes`, unless it exceeds `max_total_size` in
  1055. which case it is clipped to `max_total_size`. Defaults to false.
  1056. *@li clip_boxes: If true, assume the box coordinates are between [0, 1] and clip the output boxes
  1057. if they fall beyond [0, 1]. If false, do not do clipping and output the box
  1058. coordinates as it is. If not specified, defaults to true . \n
  1059. *@par Outputs:
  1060. *nmsed_boxes:type is float
  1061. *nmsed_scores:type is float
  1062. *nmsed_classes:type is float \n
  1063. *@par Third-party framework compatibility
  1064. * Compatible with tensorflow CombinedNonMaxSuppression operator.
  1065. */
  1066. REG_OP(CombinedNonMaxSuppression)
  1067. .INPUT(boxes, TensorType({DT_FLOAT}))
  1068. .INPUT(scores, TensorType({DT_FLOAT}))
  1069. .INPUT(max_output_size_per_class, TensorType({DT_INT32}))
  1070. .INPUT(max_total_size, TensorType({DT_INT32}))
  1071. .INPUT(iou_threshold, TensorType({DT_FLOAT}))
  1072. .INPUT(score_threshold, TensorType({DT_FLOAT}))
  1073. .OUTPUT(nmsed_boxes, TensorType({DT_FLOAT}))
  1074. .OUTPUT(nmsed_scores, TensorType({DT_FLOAT}))
  1075. .OUTPUT(nmsed_classes, TensorType({DT_FLOAT}))
  1076. .OUTPUT(valid_detections, TensorType({DT_INT32}))
  1077. .ATTR(pad_per_class, Bool, false)
  1078. .ATTR(clip_boxes, Bool, true)
  1079. .OP_END_FACTORY_REG(CombinedNonMaxSuppression)
  1080. /**
  1081. *@brief Function spatial transformer . \n
  1082. *@par Inputs:
  1083. *@li x: A Tensor dtype of float16, float32.
  1084. *@li theta: A Tensor dtype of float16, float32, auxiliary coefficients . \n
  1085. *@par Attributes:
  1086. *@li output_size: A tuple output size.
  1087. *@li default_theta: A tuple default theta
  1088. *@li use_default_theta: List use default theta
  1089. *@li align_corners: Align corners
  1090. *@par Outputs:
  1091. *y: A Tensor dtype of float16, float32, should be same shape and type as x.
  1092. */
  1093. REG_OP(SpatialTransformerD)
  1094. .INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16}))
  1095. .OPTIONAL_INPUT(theta, TensorType({DT_FLOAT,DT_FLOAT16}))
  1096. .OUTPUT(y, TensorType({DT_FLOAT,DT_FLOAT16}))
  1097. .ATTR(output_size, ListInt, {-1, -1})
  1098. .ATTR(default_theta, ListFloat, {})
  1099. .ATTR(align_corners, Bool, false)
  1100. .ATTR(use_default_theta, ListBool, {})
  1101. .OP_END_FACTORY_REG(SpatialTransformerD)
  1102. } // namespace ge
  1103. #endif // OPS_BUILT_IN_OP_PROTO_INC_IMAGE_OPS_H_

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