mindspore 2.1.0__cp38-cp38-win_amd64.whl → 2.2.11__cp38-cp38-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mindspore might be problematic. Click here for more details.

Files changed (511) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
  3. mindspore/Newtonsoft.Json.dll +0 -0
  4. mindspore/__init__.py +4 -1
  5. mindspore/_c_dataengine.cp38-win_amd64.pyd +0 -0
  6. mindspore/_c_expression.cp38-win_amd64.pyd +0 -0
  7. mindspore/_c_mindrecord.cp38-win_amd64.pyd +0 -0
  8. mindspore/_check_jit_forbidden_api.py +3 -1
  9. mindspore/_checkparam.py +23 -29
  10. mindspore/_extends/graph_kernel/__init__.py +0 -1
  11. mindspore/_extends/graph_kernel/model/graph_split.py +84 -76
  12. mindspore/_extends/graph_kernel/model/model_builder.py +9 -50
  13. mindspore/_extends/graph_kernel/splitter.py +4 -11
  14. mindspore/_extends/parallel_compile/akg_compiler/akg_process.py +122 -15
  15. mindspore/_extends/parallel_compile/akg_compiler/build_tbe_kernel.py +84 -67
  16. mindspore/_extends/parallel_compile/akg_compiler/tbe_topi.py +4 -2
  17. mindspore/_extends/parallel_compile/akg_compiler/util.py +10 -7
  18. mindspore/_extends/parallel_compile/tbe_compiler/tbe_adapter.py +2 -2
  19. mindspore/_extends/parallel_compile/tbe_compiler/tbe_helper.py +6 -5
  20. mindspore/_extends/parallel_compile/tbe_compiler/tbe_job.py +1 -1
  21. mindspore/_extends/parallel_compile/tbe_compiler/tbe_job_manager.py +1 -1
  22. mindspore/_extends/parse/__init__.py +13 -15
  23. mindspore/_extends/parse/namespace.py +7 -33
  24. mindspore/_extends/parse/parser.py +67 -72
  25. mindspore/_extends/parse/resources.py +1 -1
  26. mindspore/_extends/parse/standard_method.py +86 -106
  27. mindspore/_extends/parse/trope.py +1 -1
  28. mindspore/_extends/remote/kernel_build_server.py +25 -7
  29. mindspore/_extends/remote/kernel_build_server_akg_v2.py +55 -0
  30. mindspore/_install_custom.py +43 -0
  31. mindspore/amp.py +47 -11
  32. mindspore/atlprov.dll +0 -0
  33. mindspore/boost/boost.py +1 -8
  34. mindspore/boost/boost_cell_wrapper.py +3 -2
  35. mindspore/boost/grad_accumulation.py +1 -1
  36. mindspore/boost/group_loss_scale_manager.py +8 -7
  37. mindspore/c1.dll +0 -0
  38. mindspore/c1xx.dll +0 -0
  39. mindspore/c2.dll +0 -0
  40. mindspore/common/__init__.py +5 -3
  41. mindspore/common/_jit_fallback_utils.py +6 -0
  42. mindspore/common/_register_for_adapter.py +2 -0
  43. mindspore/common/_register_for_tensor.py +2 -2
  44. mindspore/common/_stub_tensor.py +13 -0
  45. mindspore/common/_utils.py +29 -0
  46. mindspore/common/api.py +174 -259
  47. mindspore/common/auto_dynamic_shape.py +494 -0
  48. mindspore/common/dtype.py +18 -11
  49. mindspore/common/dump.py +6 -4
  50. mindspore/common/initializer.py +14 -14
  51. mindspore/common/jit_config.py +33 -15
  52. mindspore/common/lazy_inline.py +126 -7
  53. mindspore/common/mindir_util.py +101 -0
  54. mindspore/common/parameter.py +51 -41
  55. mindspore/common/seed.py +4 -4
  56. mindspore/common/sparse_tensor.py +13 -14
  57. mindspore/common/tensor.py +243 -165
  58. mindspore/communication/__init__.py +7 -4
  59. mindspore/communication/_comm_helper.py +83 -4
  60. mindspore/communication/management.py +152 -84
  61. mindspore/config/op_info.config +14 -3
  62. mindspore/context.py +152 -61
  63. mindspore/dataset/__init__.py +5 -5
  64. mindspore/dataset/audio/__init__.py +2 -2
  65. mindspore/dataset/audio/transforms.py +52 -52
  66. mindspore/dataset/callback/ds_callback.py +16 -2
  67. mindspore/dataset/core/config.py +68 -51
  68. mindspore/dataset/engine/cache_client.py +33 -7
  69. mindspore/dataset/engine/datasets.py +250 -112
  70. mindspore/dataset/engine/datasets_audio.py +43 -211
  71. mindspore/dataset/engine/datasets_standard_format.py +16 -35
  72. mindspore/dataset/engine/datasets_text.py +43 -67
  73. mindspore/dataset/engine/datasets_user_defined.py +86 -100
  74. mindspore/dataset/engine/datasets_vision.py +219 -1029
  75. mindspore/dataset/engine/iterators.py +11 -4
  76. mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +4 -0
  77. mindspore/dataset/engine/obs/util.py +3 -0
  78. mindspore/dataset/engine/samplers.py +1 -1
  79. mindspore/dataset/engine/validators.py +19 -5
  80. mindspore/dataset/text/__init__.py +3 -3
  81. mindspore/dataset/text/transforms.py +101 -127
  82. mindspore/dataset/text/utils.py +205 -138
  83. mindspore/dataset/transforms/__init__.py +1 -1
  84. mindspore/dataset/transforms/py_transforms_util.py +40 -12
  85. mindspore/dataset/transforms/transforms.py +95 -40
  86. mindspore/dataset/utils/browse_dataset.py +8 -2
  87. mindspore/dataset/utils/line_reader.py +17 -19
  88. mindspore/dataset/vision/__init__.py +3 -3
  89. mindspore/dataset/vision/c_transforms.py +6 -3
  90. mindspore/dataset/vision/transforms.py +409 -287
  91. mindspore/dataset/vision/utils.py +13 -14
  92. mindspore/dataset/vision/validators.py +11 -1
  93. mindspore/dnnl.dll +0 -0
  94. mindspore/dpcmi.dll +0 -0
  95. mindspore/experimental/map_parameter.py +14 -0
  96. mindspore/{nn/optim_ex → experimental/optim}/__init__.py +30 -29
  97. mindspore/{nn/optim_ex → experimental/optim}/adam.py +60 -67
  98. mindspore/{nn/optim_ex → experimental/optim}/adamw.py +181 -203
  99. mindspore/experimental/optim/lr_scheduler.py +1427 -0
  100. mindspore/{nn/optim_ex → experimental/optim}/optimizer.py +252 -259
  101. mindspore/{nn/optim_ex → experimental/optim}/sgd.py +147 -152
  102. mindspore/gen_ops.py +273 -0
  103. mindspore/include/OWNERS +0 -1
  104. mindspore/include/api/data_type.h +2 -1
  105. mindspore/include/api/graph.h +0 -15
  106. mindspore/include/api/kernel.h +2 -0
  107. mindspore/include/api/kernel_api.h +37 -12
  108. mindspore/include/api/model.h +17 -14
  109. mindspore/include/api/status.h +8 -3
  110. mindspore/include/api/types.h +37 -4
  111. mindspore/include/c_api/ms/abstract.h +67 -0
  112. mindspore/include/c_api/ms/attribute.h +197 -0
  113. mindspore/include/c_api/ms/base/handle_types.h +43 -0
  114. mindspore/include/c_api/ms/base/macros.h +32 -0
  115. mindspore/include/c_api/ms/base/status.h +33 -0
  116. mindspore/include/c_api/ms/base/types.h +282 -0
  117. mindspore/include/c_api/ms/context.h +102 -0
  118. mindspore/include/c_api/ms/graph.h +160 -0
  119. mindspore/include/c_api/ms/node.h +606 -0
  120. mindspore/include/c_api/ms/tensor.h +161 -0
  121. mindspore/include/c_api/ms/value.h +84 -0
  122. mindspore/include/dataset/constants.h +6 -5
  123. mindspore/include/dataset/execute.h +23 -13
  124. mindspore/include/dataset/text.h +26 -26
  125. mindspore/include/dataset/transforms.h +13 -13
  126. mindspore/include/dataset/vision.h +60 -60
  127. mindspore/include/dataset/vision_ascend.h +5 -6
  128. mindspore/include/dataset/vision_lite.h +17 -17
  129. mindspore/jpeg62.dll +0 -0
  130. mindspore/mindrecord/tools/imagenet_to_mr.py +1 -1
  131. mindspore/mindrecord/tools/mnist_to_mr.py +2 -2
  132. mindspore/mindspore_backend.dll +0 -0
  133. mindspore/mindspore_common.dll +0 -0
  134. mindspore/mindspore_core.dll +0 -0
  135. mindspore/mindspore_glog.dll +0 -0
  136. mindspore/mindspore_shared_lib.dll +0 -0
  137. mindspore/msobj140.dll +0 -0
  138. mindspore/mspdb140.dll +0 -0
  139. mindspore/mspdbcore.dll +0 -0
  140. mindspore/mspdbst.dll +0 -0
  141. mindspore/mspft140.dll +0 -0
  142. mindspore/msvcdis140.dll +0 -0
  143. mindspore/msvcp140_1.dll +0 -0
  144. mindspore/msvcp140_2.dll +0 -0
  145. mindspore/msvcp140_atomic_wait.dll +0 -0
  146. mindspore/msvcp140_codecvt_ids.dll +0 -0
  147. mindspore/nn/__init__.py +0 -2
  148. mindspore/nn/cell.py +313 -74
  149. mindspore/nn/dynamic_lr.py +21 -21
  150. mindspore/nn/layer/activation.py +22 -30
  151. mindspore/nn/layer/basic.py +15 -13
  152. mindspore/nn/layer/channel_shuffle.py +1 -1
  153. mindspore/nn/layer/container.py +271 -9
  154. mindspore/nn/layer/conv.py +323 -204
  155. mindspore/nn/layer/dense.py +8 -5
  156. mindspore/nn/layer/embedding.py +33 -27
  157. mindspore/nn/layer/flash_attention.py +61 -95
  158. mindspore/nn/layer/image.py +8 -6
  159. mindspore/nn/layer/math.py +16 -25
  160. mindspore/nn/layer/normalization.py +107 -66
  161. mindspore/nn/layer/padding.py +1 -1
  162. mindspore/nn/layer/pooling.py +131 -109
  163. mindspore/nn/layer/rnn_cells.py +27 -22
  164. mindspore/nn/layer/rnns.py +13 -16
  165. mindspore/nn/layer/thor_layer.py +1 -1
  166. mindspore/nn/layer/transformer.py +221 -154
  167. mindspore/nn/learning_rate_schedule.py +9 -1
  168. mindspore/nn/loss/loss.py +235 -174
  169. mindspore/nn/optim/ada_grad.py +2 -1
  170. mindspore/nn/optim/adadelta.py +1 -0
  171. mindspore/nn/optim/adafactor.py +2 -1
  172. mindspore/nn/optim/adam.py +7 -4
  173. mindspore/nn/optim/adamax.py +3 -2
  174. mindspore/nn/optim/adasum.py +2 -2
  175. mindspore/nn/optim/asgd.py +2 -3
  176. mindspore/nn/optim/ftrl.py +6 -5
  177. mindspore/nn/optim/lamb.py +7 -4
  178. mindspore/nn/optim/lars.py +1 -1
  179. mindspore/nn/optim/lazyadam.py +5 -3
  180. mindspore/nn/optim/momentum.py +2 -1
  181. mindspore/nn/optim/optimizer.py +53 -4
  182. mindspore/nn/optim/proximal_ada_grad.py +3 -4
  183. mindspore/nn/optim/rmsprop.py +4 -3
  184. mindspore/nn/optim/rprop.py +23 -12
  185. mindspore/nn/optim/sgd.py +26 -11
  186. mindspore/nn/optim/thor.py +9 -7
  187. mindspore/nn/probability/bijector/bijector.py +5 -5
  188. mindspore/nn/probability/bijector/power_transform.py +27 -27
  189. mindspore/nn/probability/bijector/softplus.py +3 -3
  190. mindspore/nn/probability/distribution/_utils/custom_ops.py +3 -3
  191. mindspore/nn/probability/distribution/bernoulli.py +5 -5
  192. mindspore/nn/probability/distribution/beta.py +3 -3
  193. mindspore/nn/probability/distribution/categorical.py +7 -7
  194. mindspore/nn/probability/distribution/cauchy.py +0 -1
  195. mindspore/nn/probability/distribution/distribution.py +3 -3
  196. mindspore/nn/probability/distribution/gamma.py +3 -3
  197. mindspore/nn/probability/distribution/geometric.py +4 -4
  198. mindspore/nn/probability/distribution/gumbel.py +4 -4
  199. mindspore/nn/probability/distribution/log_normal.py +2 -2
  200. mindspore/nn/probability/distribution/logistic.py +2 -2
  201. mindspore/nn/probability/distribution/poisson.py +4 -4
  202. mindspore/nn/probability/distribution/transformed_distribution.py +3 -3
  203. mindspore/nn/probability/distribution/uniform.py +6 -6
  204. mindspore/nn/wrap/__init__.py +4 -2
  205. mindspore/nn/wrap/cell_wrapper.py +87 -34
  206. mindspore/nn/wrap/grad_reducer.py +8 -5
  207. mindspore/nn/wrap/loss_scale.py +105 -42
  208. mindspore/numpy/array_creations.py +1 -2
  209. mindspore/numpy/array_ops.py +3 -2
  210. mindspore/numpy/utils_const.py +5 -5
  211. mindspore/opencv_core452.dll +0 -0
  212. mindspore/opencv_imgcodecs452.dll +0 -0
  213. mindspore/opencv_imgproc452.dll +0 -0
  214. mindspore/ops/_grad_experimental/__init__.py +0 -5
  215. mindspore/ops/_grad_experimental/grad_array_ops.py +2 -3
  216. mindspore/ops/_grad_experimental/grad_comm_ops.py +15 -2
  217. mindspore/ops/_grad_experimental/grad_debug_ops.py +0 -37
  218. mindspore/ops/_grad_experimental/grad_implementations.py +11 -1
  219. mindspore/ops/_grad_experimental/grad_inner_ops.py +2 -216
  220. mindspore/ops/_grad_experimental/grad_math_ops.py +19 -199
  221. mindspore/ops/_grad_experimental/grad_sparse.py +15 -0
  222. mindspore/ops/_grad_experimental/grad_sparse_ops.py +3 -3
  223. mindspore/ops/_op_impl/_custom_op/dsd_back_impl.py +1 -1
  224. mindspore/ops/_op_impl/aicpu/__init__.py +14 -2
  225. mindspore/ops/_op_impl/aicpu/add.py +3 -3
  226. mindspore/ops/_op_impl/aicpu/bias_add_grad.py +0 -1
  227. mindspore/ops/_op_impl/aicpu/count_nonzero.py +43 -0
  228. mindspore/ops/_op_impl/{_custom_op/flash_attention/constants.py → aicpu/eps.py} +18 -27
  229. mindspore/ops/_op_impl/aicpu/gamma.py +2 -2
  230. mindspore/ops/_op_impl/aicpu/linear_sum_assignment.py +21 -2
  231. mindspore/ops/_op_impl/aicpu/log_uniform_candidate_sampler.py +6 -3
  232. mindspore/ops/_op_impl/aicpu/lu_unpack_grad.py +0 -1
  233. mindspore/ops/_op_impl/aicpu/multinomial.py +3 -3
  234. mindspore/ops/_op_impl/aicpu/parameterized_truncated_normal.py +15 -7
  235. mindspore/ops/_op_impl/aicpu/random_categorical.py +39 -19
  236. mindspore/ops/_op_impl/aicpu/random_choice_with_mask.py +5 -2
  237. mindspore/ops/_op_impl/aicpu/random_poisson.py +103 -52
  238. mindspore/ops/_op_impl/aicpu/random_shuffle.py +17 -15
  239. mindspore/ops/_op_impl/aicpu/{sparseaddmm.py → sparse_addmm.py} +2 -2
  240. mindspore/ops/_op_impl/aicpu/{sparsesparsemaximum.py → sparse_sparse_maximum.py} +4 -4
  241. mindspore/ops/_op_impl/aicpu/standard_laplace.py +5 -5
  242. mindspore/ops/_op_impl/aicpu/standard_normal.py +5 -5
  243. mindspore/ops/_op_impl/aicpu/truncated_normal.py +9 -7
  244. mindspore/ops/_op_impl/aicpu/uniform.py +5 -3
  245. mindspore/ops/_op_impl/aicpu/uniform_candidate_sampler.py +8 -4
  246. mindspore/ops/_op_impl/aicpu/uniform_int.py +5 -5
  247. mindspore/ops/_op_impl/aicpu/uniform_real.py +4 -4
  248. mindspore/ops/_op_impl/tbe/__init__.py +4 -4
  249. mindspore/ops/_op_impl/tbe/inplace_index_add.py +7 -3
  250. mindspore/ops/_op_impl/tbe/trans_data_ds.py +2 -0
  251. mindspore/ops/_primitive_cache.py +1 -1
  252. mindspore/ops/_tracefunc.py +45 -13
  253. mindspore/ops/_utils/utils.py +6 -1
  254. mindspore/ops/_vmap/vmap_array_ops.py +3 -3
  255. mindspore/ops/_vmap/vmap_base.py +3 -3
  256. mindspore/ops/_vmap/vmap_convolution_ops.py +1 -1
  257. mindspore/ops/_vmap/vmap_grad_math_ops.py +6 -4
  258. mindspore/ops/_vmap/vmap_math_ops.py +5 -2
  259. mindspore/ops/_vmap/vmap_nn_ops.py +61 -7
  260. mindspore/ops/arg_dtype_cast.py +54 -0
  261. mindspore/ops/composite/base.py +37 -10
  262. mindspore/ops/composite/math_ops.py +5 -4
  263. mindspore/ops/composite/multitype_ops/_compile_utils.py +275 -73
  264. mindspore/ops/composite/multitype_ops/_constexpr_utils.py +16 -9
  265. mindspore/ops/composite/multitype_ops/add_impl.py +43 -4
  266. mindspore/ops/composite/multitype_ops/getitem_impl.py +42 -4
  267. mindspore/ops/composite/multitype_ops/ones_like_impl.py +6 -0
  268. mindspore/ops/composite/multitype_ops/setitem_impl.py +2 -1
  269. mindspore/ops/composite/multitype_ops/zeros_like_impl.py +9 -0
  270. mindspore/ops/deprecated.py +304 -0
  271. mindspore/ops/function/__init__.py +4 -1
  272. mindspore/ops/function/array_func.py +174 -193
  273. mindspore/ops/function/clip_func.py +81 -13
  274. mindspore/ops/function/debug_func.py +1 -1
  275. mindspore/ops/function/grad/grad_func.py +18 -9
  276. mindspore/ops/function/image_func.py +10 -4
  277. mindspore/ops/function/linalg_func.py +5 -5
  278. mindspore/ops/function/math_func.py +575 -386
  279. mindspore/ops/function/nn_func.py +568 -260
  280. mindspore/ops/function/random_func.py +88 -57
  281. mindspore/ops/function/sparse_func.py +1 -1
  282. mindspore/ops/function/sparse_unary_func.py +14 -12
  283. mindspore/ops/function/vmap_func.py +6 -5
  284. mindspore/ops/functional.py +15 -10
  285. mindspore/ops/op_info_register.py +244 -25
  286. mindspore/ops/operations/__init__.py +31 -19
  287. mindspore/ops/operations/_grad_ops.py +71 -7
  288. mindspore/ops/operations/_inner_ops.py +350 -17
  289. mindspore/ops/operations/_quant_ops.py +4 -8
  290. mindspore/ops/operations/_sequence_ops.py +42 -0
  291. mindspore/ops/operations/array_ops.py +68 -282
  292. mindspore/ops/operations/comm_ops.py +107 -59
  293. mindspore/ops/operations/custom_ops.py +94 -70
  294. mindspore/ops/operations/debug_ops.py +8 -4
  295. mindspore/ops/operations/image_ops.py +18 -12
  296. mindspore/ops/operations/inner_ops.py +26 -3
  297. mindspore/ops/operations/math_ops.py +192 -144
  298. mindspore/ops/operations/nn_ops.py +857 -489
  299. mindspore/ops/operations/other_ops.py +0 -22
  300. mindspore/ops/operations/random_ops.py +53 -111
  301. mindspore/ops/operations/sparse_ops.py +3 -1
  302. mindspore/ops/primitive.py +24 -18
  303. mindspore/parallel/_auto_parallel_context.py +68 -8
  304. mindspore/parallel/_cost_model_context.py +2 -2
  305. mindspore/parallel/_offload_context.py +17 -3
  306. mindspore/parallel/_parallel_serialization.py +12 -5
  307. mindspore/parallel/_ps_context.py +12 -0
  308. mindspore/parallel/_tensor.py +18 -13
  309. mindspore/parallel/_transformer/layers.py +5 -3
  310. mindspore/parallel/_transformer/loss.py +1 -0
  311. mindspore/parallel/_transformer/moe.py +2 -2
  312. mindspore/parallel/_transformer/op_parallel_config.py +12 -1
  313. mindspore/parallel/_transformer/transformer.py +23 -3
  314. mindspore/parallel/_utils.py +11 -7
  315. mindspore/parallel/algo_parameter_config.py +85 -5
  316. mindspore/parallel/checkpoint_transform.py +19 -12
  317. mindspore/parallel/shard.py +21 -14
  318. mindspore/pgodb140.dll +0 -0
  319. mindspore/pgort140.dll +0 -0
  320. mindspore/profiler/common/struct_type.py +3 -3
  321. mindspore/profiler/common/util.py +4 -2
  322. mindspore/profiler/envprofiling.py +1 -1
  323. mindspore/profiler/parser/aicpu_data_parser.py +5 -3
  324. mindspore/profiler/parser/ascend_flops_generator.py +2 -2
  325. mindspore/profiler/parser/ascend_fpbp_generator.py +1 -1
  326. mindspore/profiler/parser/ascend_hccl_generator.py +249 -12
  327. mindspore/profiler/parser/ascend_msprof_exporter.py +150 -255
  328. mindspore/profiler/parser/ascend_msprof_generator.py +204 -17
  329. mindspore/profiler/parser/ascend_op_generator.py +6 -6
  330. mindspore/profiler/parser/ascend_steptrace_generator.py +6 -4
  331. mindspore/profiler/parser/ascend_timeline_generator.py +14 -187
  332. mindspore/profiler/parser/base_timeline_generator.py +10 -8
  333. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +16 -12
  334. mindspore/profiler/parser/flops_parser.py +15 -11
  335. mindspore/profiler/parser/framework_parser.py +38 -22
  336. mindspore/profiler/parser/hccl_parser.py +16 -12
  337. mindspore/profiler/parser/integrator.py +22 -11
  338. mindspore/profiler/parser/memory_usage_parser.py +2 -2
  339. mindspore/profiler/parser/minddata_analyzer.py +12 -14
  340. mindspore/profiler/parser/minddata_pipeline_parser.py +1 -1
  341. mindspore/profiler/parser/msadvisor_parser.py +8 -4
  342. mindspore/profiler/parser/op_intermediate_parser.py +5 -2
  343. mindspore/profiler/parser/optime_parser.py +1 -1
  344. mindspore/profiler/parser/profiler_info.py +21 -2
  345. mindspore/profiler/parser/step_trace_parser.py +11 -14
  346. mindspore/profiler/profiling.py +179 -89
  347. mindspore/rewrite/api/node.py +102 -19
  348. mindspore/rewrite/api/node_type.py +5 -1
  349. mindspore/rewrite/api/pattern_engine.py +1 -1
  350. mindspore/rewrite/api/scoped_value.py +9 -17
  351. mindspore/rewrite/api/symbol_tree.py +131 -47
  352. mindspore/rewrite/ast_helpers/__init__.py +2 -1
  353. mindspore/rewrite/ast_helpers/ast_finder.py +129 -0
  354. mindspore/rewrite/ast_helpers/ast_modifier.py +116 -104
  355. mindspore/rewrite/ast_transformers/flatten_recursive_stmt.py +93 -46
  356. mindspore/rewrite/common/rewrite_elog.py +5 -1
  357. mindspore/rewrite/namer.py +33 -24
  358. mindspore/rewrite/namespace.py +14 -5
  359. mindspore/{_extends/graph_kernel/expanders/complex → rewrite/node}/__init__.py +9 -9
  360. mindspore/rewrite/node/call_function.py +79 -0
  361. mindspore/rewrite/node/cell_container.py +135 -0
  362. mindspore/rewrite/node/control_flow.py +88 -0
  363. mindspore/rewrite/{node.py → node/node.py} +273 -234
  364. mindspore/rewrite/node/node_manager.py +254 -0
  365. mindspore/rewrite/{topological_manager.py → node/node_topological_manager.py} +13 -46
  366. mindspore/rewrite/parsers/arguments_parser.py +22 -21
  367. mindspore/rewrite/parsers/assign_parser.py +216 -221
  368. mindspore/rewrite/parsers/attribute_parser.py +9 -7
  369. mindspore/rewrite/parsers/class_def_parser.py +174 -113
  370. mindspore/rewrite/parsers/constant_parser.py +9 -6
  371. mindspore/rewrite/parsers/container_parser.py +9 -7
  372. mindspore/rewrite/parsers/for_parser.py +42 -21
  373. mindspore/rewrite/parsers/function_def_parser.py +24 -16
  374. mindspore/rewrite/parsers/if_parser.py +28 -24
  375. mindspore/rewrite/parsers/module_parser.py +196 -25
  376. mindspore/rewrite/{parser.py → parsers/parser.py} +4 -2
  377. mindspore/rewrite/{parser_register.py → parsers/parser_register.py} +1 -1
  378. mindspore/rewrite/parsers/return_parser.py +6 -6
  379. mindspore/rewrite/sparsify/sparse_transformer.py +12 -3
  380. mindspore/rewrite/sparsify/utils.py +1 -1
  381. mindspore/rewrite/symbol_tree.py +523 -578
  382. mindspore/rewrite/symbol_tree_builder.py +9 -193
  383. mindspore/rewrite/symbol_tree_dumper.py +2 -2
  384. mindspore/run_check/_check_version.py +6 -4
  385. mindspore/{ops/bprop_mindir → safeguard}/__init__.py +4 -3
  386. mindspore/safeguard/rewrite_obfuscation.py +541 -0
  387. mindspore/tbbmalloc.dll +0 -0
  388. mindspore/tinyxml2.dll +0 -0
  389. mindspore/train/_utils.py +7 -3
  390. mindspore/train/amp.py +323 -123
  391. mindspore/train/anf_ir_pb2.py +14 -2
  392. mindspore/train/callback/_backup_and_restore.py +2 -12
  393. mindspore/train/callback/_callback.py +29 -4
  394. mindspore/train/callback/_checkpoint.py +23 -8
  395. mindspore/train/callback/_early_stop.py +2 -2
  396. mindspore/train/callback/_landscape.py +4 -4
  397. mindspore/train/callback/_loss_monitor.py +2 -2
  398. mindspore/train/callback/_on_request_exit.py +2 -2
  399. mindspore/train/callback/_reduce_lr_on_plateau.py +3 -4
  400. mindspore/train/callback/_summary_collector.py +15 -8
  401. mindspore/train/callback/_time_monitor.py +58 -5
  402. mindspore/train/data_sink.py +5 -11
  403. mindspore/train/dataset_helper.py +84 -57
  404. mindspore/train/loss_scale_manager.py +2 -2
  405. mindspore/train/metrics/__init__.py +3 -3
  406. mindspore/train/metrics/cosine_similarity.py +1 -1
  407. mindspore/train/metrics/hausdorff_distance.py +3 -2
  408. mindspore/train/metrics/mean_surface_distance.py +3 -2
  409. mindspore/train/metrics/metric.py +39 -19
  410. mindspore/train/metrics/roc.py +2 -2
  411. mindspore/train/metrics/root_mean_square_surface_distance.py +4 -3
  412. mindspore/train/mind_ir_pb2.py +85 -36
  413. mindspore/train/model.py +187 -47
  414. mindspore/train/serialization.py +487 -161
  415. mindspore/train/summary/_summary_adapter.py +1 -1
  416. mindspore/train/summary/_writer_pool.py +3 -2
  417. mindspore/train/summary/summary_record.py +37 -17
  418. mindspore/train/train_thor/convert_utils.py +3 -3
  419. mindspore/train/train_thor/dataset_helper.py +1 -1
  420. mindspore/turbojpeg.dll +0 -0
  421. mindspore/vcmeta.dll +0 -0
  422. mindspore/vcruntime140.dll +0 -0
  423. mindspore/vcruntime140_1.dll +0 -0
  424. mindspore/version.py +1 -1
  425. {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/METADATA +7 -4
  426. {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/RECORD +429 -486
  427. mindspore/_extends/graph_kernel/expander.py +0 -80
  428. mindspore/_extends/graph_kernel/expanders/__init__.py +0 -54
  429. mindspore/_extends/graph_kernel/expanders/_utils.py +0 -269
  430. mindspore/_extends/graph_kernel/expanders/addn.py +0 -33
  431. mindspore/_extends/graph_kernel/expanders/batchnorm.py +0 -152
  432. mindspore/_extends/graph_kernel/expanders/batchnorm_grad.py +0 -105
  433. mindspore/_extends/graph_kernel/expanders/clip_by_norm_no_div_sum.py +0 -33
  434. mindspore/_extends/graph_kernel/expanders/complex/abs.py +0 -30
  435. mindspore/_extends/graph_kernel/expanders/complex/add.py +0 -44
  436. mindspore/_extends/graph_kernel/expanders/complex/div.py +0 -62
  437. mindspore/_extends/graph_kernel/expanders/complex/mul.py +0 -52
  438. mindspore/_extends/graph_kernel/expanders/complex/real_div.py +0 -62
  439. mindspore/_extends/graph_kernel/expanders/complex/sub.py +0 -45
  440. mindspore/_extends/graph_kernel/expanders/conv2d.py +0 -200
  441. mindspore/_extends/graph_kernel/expanders/dropout_grad.py +0 -30
  442. mindspore/_extends/graph_kernel/expanders/equal_count.py +0 -50
  443. mindspore/_extends/graph_kernel/expanders/erfc.py +0 -35
  444. mindspore/_extends/graph_kernel/expanders/expand_dims.py +0 -50
  445. mindspore/_extends/graph_kernel/expanders/fused_adam.py +0 -44
  446. mindspore/_extends/graph_kernel/expanders/fused_adam_weight_decay.py +0 -47
  447. mindspore/_extends/graph_kernel/expanders/fused_mul_add.py +0 -28
  448. mindspore/_extends/graph_kernel/expanders/gelu_grad.py +0 -70
  449. mindspore/_extends/graph_kernel/expanders/gkdropout.py +0 -40
  450. mindspore/_extends/graph_kernel/expanders/identity.py +0 -25
  451. mindspore/_extends/graph_kernel/expanders/layernorm.py +0 -93
  452. mindspore/_extends/graph_kernel/expanders/layernorm_grad.py +0 -113
  453. mindspore/_extends/graph_kernel/expanders/logsoftmax.py +0 -46
  454. mindspore/_extends/graph_kernel/expanders/logsoftmax_grad.py +0 -36
  455. mindspore/_extends/graph_kernel/expanders/matmul.py +0 -80
  456. mindspore/_extends/graph_kernel/expanders/maximum_grad.py +0 -59
  457. mindspore/_extends/graph_kernel/expanders/minimum_grad.py +0 -80
  458. mindspore/_extends/graph_kernel/expanders/oneslike.py +0 -26
  459. mindspore/_extends/graph_kernel/expanders/reduce_mean.py +0 -43
  460. mindspore/_extends/graph_kernel/expanders/relu_grad.py +0 -32
  461. mindspore/_extends/graph_kernel/expanders/sigmoid_cross_entropy_with_logits.py +0 -41
  462. mindspore/_extends/graph_kernel/expanders/sigmoid_cross_entropy_with_logits_grad.py +0 -35
  463. mindspore/_extends/graph_kernel/expanders/sigmoid_grad.py +0 -31
  464. mindspore/_extends/graph_kernel/expanders/slice.py +0 -35
  465. mindspore/_extends/graph_kernel/expanders/softmax_cross_entropy_with_logits.py +0 -42
  466. mindspore/_extends/graph_kernel/expanders/softmax_grad_ext.py +0 -41
  467. mindspore/_extends/graph_kernel/expanders/softsign.py +0 -28
  468. mindspore/_extends/graph_kernel/expanders/sqrt_grad.py +0 -29
  469. mindspore/_extends/graph_kernel/expanders/square_sum_all.py +0 -44
  470. mindspore/_extends/graph_kernel/expanders/square_sum_v1.py +0 -37
  471. mindspore/_extends/graph_kernel/expanders/squared_difference.py +0 -43
  472. mindspore/_extends/graph_kernel/expanders/tanh_grad.py +0 -31
  473. mindspore/_extends/graph_kernel/model/op_infer.py +0 -506
  474. mindspore/dataset/datapreprocess/__init__.py +0 -20
  475. mindspore/dataset/datapreprocess/preprocess_imagenet_validate_dataset.py +0 -54
  476. mindspore/include/api/net.h +0 -142
  477. mindspore/nn/lr_scheduler.py +0 -262
  478. mindspore/ops/_grad_experimental/grad_image_ops.py +0 -248
  479. mindspore/ops/_grad_experimental/grad_linalg_ops.py +0 -181
  480. mindspore/ops/_grad_experimental/grad_other_ops.py +0 -72
  481. mindspore/ops/_grad_experimental/grad_scalar_ops.py +0 -112
  482. mindspore/ops/_grad_experimental/grad_sequence_ops.py +0 -351
  483. mindspore/ops/_op_impl/_custom_op/flash_attention/__init__.py +0 -0
  484. mindspore/ops/_op_impl/_custom_op/flash_attention/attention.py +0 -350
  485. mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_bwd.py +0 -409
  486. mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_fwd.py +0 -578
  487. mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_impl.py +0 -199
  488. mindspore/ops/_op_impl/_custom_op/flash_attention/tik_ops_utils.py +0 -446
  489. mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/__init__.py +0 -0
  490. mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/sparse_tiling.py +0 -45
  491. mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/strategy.py +0 -67
  492. mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/wukong_tiling.py +0 -62
  493. mindspore/ops/bprop_mindir/BNTrainingReduce_bprop.mindir +0 -0
  494. mindspore/ops/bprop_mindir/Broadcast_bprop.mindir +0 -0
  495. mindspore/ops/bprop_mindir/Depend_bprop.mindir +0 -0
  496. mindspore/ops/bprop_mindir/DepthwiseConv2dNative_bprop.mindir +0 -138
  497. mindspore/ops/bprop_mindir/EmbeddingLookup_bprop.mindir +0 -0
  498. mindspore/ops/bprop_mindir/Load_bprop.mindir +0 -0
  499. mindspore/ops/bprop_mindir/ScatterNonAliasingAdd_bprop.mindir +0 -0
  500. mindspore/ops/bprop_mindir/SparseGatherV2_bprop.mindir +0 -0
  501. mindspore/ops/bprop_mindir/SparseSoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
  502. mindspore/ops/bprop_mindir/Switch_bprop.mindir +0 -0
  503. mindspore/ops/bprop_mindir/TransShape_bprop.mindir +0 -0
  504. mindspore/ops/bprop_mindir/TupleGetItem_bprop.mindir +0 -0
  505. mindspore/ops/bprop_mindir/Unique_bprop.mindir +0 -0
  506. mindspore/ops/bprop_mindir/Unstack_bprop.mindir +0 -0
  507. mindspore/ops/bprop_mindir/generate_mindir.py +0 -114
  508. mindspore/rewrite/node_visitor.py +0 -44
  509. {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/WHEEL +0 -0
  510. {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/entry_points.txt +0 -0
  511. {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/top_level.txt +0 -0
@@ -34,6 +34,8 @@ Examples:
34
34
  >>> import mindspore.dataset as ds
35
35
  >>> import mindspore.dataset.vision as vision
36
36
  >>> from mindspore.dataset.vision import Border, Inter
37
+ >>> import mindspore.dataset.transforms as transforms
38
+ >>>
37
39
  >>> image_folder_dataset_dir = "/path/to/image_folder_dataset_directory"
38
40
  >>> # create a dataset that reads all files in dataset_dir with 8 threads
39
41
  >>> image_folder_dataset = ds.ImageFolderDataset(image_folder_dataset_dir,
@@ -76,7 +78,7 @@ from .validators import check_adjust_brightness, check_adjust_contrast, check_ad
76
78
  check_random_select_subpolicy_op, check_random_solarize, check_range, check_rescale, check_resize, \
77
79
  check_resize_interpolation, check_resized_crop, check_rgb_to_hsv, check_rotate, check_slice_patches, \
78
80
  check_solarize, check_ten_crop, check_trivial_augment_wide, check_uniform_augment, check_to_tensor, \
79
- FLOAT_MAX_INTEGER
81
+ check_device_target, FLOAT_MAX_INTEGER
80
82
  from ..core.datatypes import mstype_to_detype, nptype_to_detype
81
83
  from ..transforms.py_transforms_util import Implementation
82
84
  from ..transforms.transforms import CompoundOperation, PyTensorOperation, TensorOperation, TypeCast
@@ -114,7 +116,7 @@ class AdjustBrightness(ImageTensorOperation, PyTensorOperation):
114
116
  RuntimeError: If shape of the input image is not <H, W, C>.
115
117
 
116
118
  Supported Platforms:
117
- ``CPU``
119
+ ``CPU`` ``Ascend``
118
120
 
119
121
  Examples:
120
122
  >>> import mindspore.dataset as ds
@@ -127,7 +129,7 @@ class AdjustBrightness(ImageTensorOperation, PyTensorOperation):
127
129
 
128
130
  Tutorial Examples:
129
131
  - `Illustration of vision transforms
130
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
132
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
131
133
  """
132
134
 
133
135
  @check_adjust_brightness
@@ -135,8 +137,39 @@ class AdjustBrightness(ImageTensorOperation, PyTensorOperation):
135
137
  super().__init__()
136
138
  self.brightness_factor = brightness_factor
137
139
 
140
+ @check_device_target
141
+ def device(self, device_target="CPU"):
142
+ """
143
+ Set the device for the current operator execution.
144
+
145
+ Args:
146
+ device_target (str, optional): The operator will be executed on this device. Currently supports
147
+ ``CPU`` . Default: ``CPU`` .
148
+
149
+ Raises:
150
+ TypeError: If `device_target` is not of type str.
151
+ ValueError: If `device_target` is not ``CPU`` .
152
+
153
+ Supported Platforms:
154
+ ``CPU``
155
+
156
+ Examples:
157
+ >>> import mindspore.dataset as ds
158
+ >>> import mindspore.dataset.vision as vision
159
+ >>>
160
+ >>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
161
+ >>> transforms_list = [vision.Decode().device("CPU"), vision.AdjustBrightness(2.0).device("Ascend")]
162
+ >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, input_columns=["image"])
163
+
164
+ Tutorial Examples:
165
+ - `Illustration of vision transforms
166
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
167
+ """
168
+ self.device_target = device_target
169
+ return self
170
+
138
171
  def parse(self):
139
- return cde.AdjustBrightnessOperation(self.brightness_factor)
172
+ return cde.AdjustBrightnessOperation(self.brightness_factor, self.device_target)
140
173
 
141
174
  def _execute_py(self, img):
142
175
  """
@@ -166,7 +199,7 @@ class AdjustContrast(ImageTensorOperation, PyTensorOperation):
166
199
  RuntimeError: If shape of the input image is not <H, W, C>.
167
200
 
168
201
  Supported Platforms:
169
- ``CPU``
202
+ ``CPU`` ``Ascend``
170
203
 
171
204
  Examples:
172
205
  >>> import mindspore.dataset as ds
@@ -179,7 +212,7 @@ class AdjustContrast(ImageTensorOperation, PyTensorOperation):
179
212
 
180
213
  Tutorial Examples:
181
214
  - `Illustration of vision transforms
182
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
215
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
183
216
  """
184
217
 
185
218
  @check_adjust_contrast
@@ -187,8 +220,39 @@ class AdjustContrast(ImageTensorOperation, PyTensorOperation):
187
220
  super().__init__()
188
221
  self.contrast_factor = contrast_factor
189
222
 
223
+ @check_device_target
224
+ def device(self, device_target="CPU"):
225
+ """
226
+ Set the device for the current operator execution.
227
+
228
+ Args:
229
+ device_target (str, optional): The operator will be executed on this device. Currently supports
230
+ ``CPU`` . Default: ``CPU`` .
231
+
232
+ Raises:
233
+ TypeError: If `device_target` is not of type str.
234
+ ValueError: If `device_target` is not ``CPU`` .
235
+
236
+ Supported Platforms:
237
+ ``CPU``
238
+
239
+ Examples:
240
+ >>> import mindspore.dataset as ds
241
+ >>> import mindspore.dataset.vision as vision
242
+ >>>
243
+ >>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
244
+ >>> transforms_list = [vision.Decode().device("CPU"), vision.AdjustContrast(0).device("Ascend")]
245
+ >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, input_columns=["image"])
246
+
247
+ Tutorial Examples:
248
+ - `Illustration of vision transforms
249
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
250
+ """
251
+ self.device_target = device_target
252
+ return self
253
+
190
254
  def parse(self):
191
- return cde.AdjustContrastOperation(self.contrast_factor)
255
+ return cde.AdjustContrastOperation(self.contrast_factor, self.device_target)
192
256
 
193
257
  def _execute_py(self, img):
194
258
  """
@@ -241,7 +305,7 @@ class AdjustGamma(ImageTensorOperation, PyTensorOperation):
241
305
 
242
306
  Tutorial Examples:
243
307
  - `Illustration of vision transforms
244
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
308
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
245
309
  """
246
310
 
247
311
  @check_adjust_gamma
@@ -281,7 +345,7 @@ class AdjustHue(ImageTensorOperation, PyTensorOperation):
281
345
  RuntimeError: If shape of the input image is not <H, W, C>.
282
346
 
283
347
  Supported Platforms:
284
- ``CPU``
348
+ ``CPU`` ``Ascend``
285
349
 
286
350
  Examples:
287
351
  >>> import mindspore.dataset as ds
@@ -294,7 +358,7 @@ class AdjustHue(ImageTensorOperation, PyTensorOperation):
294
358
 
295
359
  Tutorial Examples:
296
360
  - `Illustration of vision transforms
297
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
361
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
298
362
  """
299
363
 
300
364
  @check_adjust_hue
@@ -302,8 +366,39 @@ class AdjustHue(ImageTensorOperation, PyTensorOperation):
302
366
  super().__init__()
303
367
  self.hue_factor = hue_factor
304
368
 
369
+ @check_device_target
370
+ def device(self, device_target="CPU"):
371
+ """
372
+ Set the device for the current operator execution.
373
+
374
+ Args:
375
+ device_target (str, optional): The operator will be executed on this device. Currently supports
376
+ ``CPU`` . Default: ``CPU`` .
377
+
378
+ Raises:
379
+ TypeError: If `device_target` is not of type str.
380
+ ValueError: If `device_target` is not ``CPU`` .
381
+
382
+ Supported Platforms:
383
+ ``CPU``
384
+
385
+ Examples:
386
+ >>> import mindspore.dataset as ds
387
+ >>> import mindspore.dataset.vision as vision
388
+ >>>
389
+ >>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
390
+ >>> transforms_list = [vision.Decode().device("CPU"), vision.AdjustHue(0.5).device("Ascend")]
391
+ >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, input_columns=["image"])
392
+
393
+ Tutorial Examples:
394
+ - `Illustration of vision transforms
395
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
396
+ """
397
+ self.device_target = device_target
398
+ return self
399
+
305
400
  def parse(self):
306
- return cde.AdjustHueOperation(self.hue_factor)
401
+ return cde.AdjustHueOperation(self.hue_factor, self.device_target)
307
402
 
308
403
  def _execute_py(self, img):
309
404
  """
@@ -334,7 +429,7 @@ class AdjustSaturation(ImageTensorOperation, PyTensorOperation):
334
429
  RuntimeError: If channel of the input image is not 3.
335
430
 
336
431
  Supported Platforms:
337
- ``CPU``
432
+ ``CPU`` ``Ascend``
338
433
 
339
434
  Examples:
340
435
  >>> import mindspore.dataset as ds
@@ -347,7 +442,7 @@ class AdjustSaturation(ImageTensorOperation, PyTensorOperation):
347
442
 
348
443
  Tutorial Examples:
349
444
  - `Illustration of vision transforms
350
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
445
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
351
446
  """
352
447
 
353
448
  @check_adjust_saturation
@@ -355,8 +450,39 @@ class AdjustSaturation(ImageTensorOperation, PyTensorOperation):
355
450
  super().__init__()
356
451
  self.saturation_factor = saturation_factor
357
452
 
453
+ @check_device_target
454
+ def device(self, device_target="CPU"):
455
+ """
456
+ Set the device for the current operator execution.
457
+
458
+ Args:
459
+ device_target (str, optional): The operator will be executed on this device. Currently supports
460
+ ``CPU`` . Default: ``CPU`` .
461
+
462
+ Raises:
463
+ TypeError: If `device_target` is not of type str.
464
+ ValueError: If `device_target` is not ``CPU`` .
465
+
466
+ Supported Platforms:
467
+ ``CPU``
468
+
469
+ Examples:
470
+ >>> import mindspore.dataset as ds
471
+ >>> import mindspore.dataset.vision as vision
472
+ >>>
473
+ >>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
474
+ >>> transforms_list = [vision.Decode().device("CPU"), vision.AdjustSaturation(2.0).device("Ascend")]
475
+ >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, input_columns=["image"])
476
+
477
+ Tutorial Examples:
478
+ - `Illustration of vision transforms
479
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
480
+ """
481
+ self.device_target = device_target
482
+ return self
483
+
358
484
  def parse(self):
359
- return cde.AdjustSaturationOperation(self.saturation_factor)
485
+ return cde.AdjustSaturationOperation(self.saturation_factor, self.device_target)
360
486
 
361
487
  def _execute_py(self, img):
362
488
  """
@@ -399,7 +525,7 @@ class AdjustSharpness(ImageTensorOperation):
399
525
 
400
526
  Tutorial Examples:
401
527
  - `Illustration of vision transforms
402
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
528
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
403
529
  """
404
530
 
405
531
  @check_adjust_sharpness
@@ -423,17 +549,8 @@ class Affine(ImageTensorOperation):
423
549
  shear (Union[float, Sequence[float, float]]): Shear angle value in degrees between -180 to 180.
424
550
  If float is provided, shear along the x axis with this value, without shearing along the y axis;
425
551
  If Sequence[float, float] is provided, shear along the x axis and y axis with these two values separately.
426
- resample (Inter, optional): An optional resampling filter. Default: ``Inter.NEAREST``.
427
- It can be ``Inter.BILINEAR``, ``Inter.NEAREST``, ``Inter.BICUBIC``, ``Inter.AREA``.
428
-
429
- - ``Inter.BILINEA`` , means resample method is bilinear interpolation.
430
-
431
- - ``Inter.NEAREST`` , means resample method is nearest-neighbor interpolation.
432
-
433
- - ``Inter.BICUBIC`` , means resample method is bicubic interpolation.
434
-
435
- - ``Inter.AREA`` :, means resample method is pixel area interpolation.
436
-
552
+ resample (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
553
+ Default: ``Inter.NEAREST``.
437
554
  fill_value (Union[int, tuple[int, int, int]], optional): Optional `fill_value` to fill the area
438
555
  outside the transform in the output image. There must be three elements in tuple and the value
439
556
  of single element is [0, 255]. Default: ``0``.
@@ -444,7 +561,7 @@ class Affine(ImageTensorOperation):
444
561
  TypeError: If `scale` is not of type float.
445
562
  ValueError: If `scale` is non positive.
446
563
  TypeError: If `shear` is not of float or Sequence[float, float].
447
- TypeError: If `resample` is not of type :class:`mindspore.dataset.vision.Inter` .
564
+ TypeError: If `resample` is not of type :class:`~.vision.Inter` .
448
565
  TypeError: If `fill_value` is not of type int or tuple[int, int, int].
449
566
  RuntimeError: If shape of the input image is not <H, W> or <H, W, C>.
450
567
 
@@ -466,7 +583,7 @@ class Affine(ImageTensorOperation):
466
583
 
467
584
  Tutorial Examples:
468
585
  - `Illustration of vision transforms
469
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
586
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
470
587
  """
471
588
 
472
589
  @check_affine
@@ -510,17 +627,8 @@ class AutoAugment(ImageTensorOperation):
510
627
 
511
628
  - ``AutoAugmentPolicy.SVHN``, means to apply AutoAugment learned on SVHN dataset.
512
629
 
513
- interpolation (Inter, optional): Image interpolation mode for Resize operation. Default: ``Inter.NEAREST``.
514
- It can be ``Inter.NEAREST``, ``Inter.BILINEAR``, ``Inter.BICUBIC``, ``Inter.AREA``.
515
-
516
- - ``Inter.NEAREST`` : means interpolation method is nearest-neighbor interpolation.
517
-
518
- - ``Inter.BILINEA`` : means interpolation method is bilinear interpolation.
519
-
520
- - ``Inter.BICUBIC`` : means the interpolation method is bicubic interpolation.
521
-
522
- - ``Inter.AREA`` : means the interpolation method is pixel area interpolation.
523
-
630
+ interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
631
+ Default: ``Inter.NEAREST``.
524
632
  fill_value (Union[int, tuple[int]], optional): Pixel fill value for the area outside the transformed image.
525
633
  It can be an int or a 3-tuple. If it is a 3-tuple, it is used to fill R, G, B channels respectively.
526
634
  If it is an integer, it is used for all RGB channels. The fill_value values must be in range [0, 255].
@@ -528,7 +636,7 @@ class AutoAugment(ImageTensorOperation):
528
636
 
529
637
  Raises:
530
638
  TypeError: If `policy` is not of type :class:`mindspore.dataset.vision.AutoAugmentPolicy` .
531
- TypeError: If `interpolation` is not of type :class:`mindspore.dataset.vision.Inter` .
639
+ TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
532
640
  TypeError: If `fill_value` is not an integer or a tuple of length 3.
533
641
  RuntimeError: If given tensor shape is not <H, W, C>.
534
642
 
@@ -550,7 +658,7 @@ class AutoAugment(ImageTensorOperation):
550
658
 
551
659
  Tutorial Examples:
552
660
  - `Illustration of vision transforms
553
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
661
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
554
662
  """
555
663
 
556
664
  @check_auto_augment
@@ -600,7 +708,7 @@ class AutoContrast(ImageTensorOperation, PyTensorOperation):
600
708
 
601
709
  Tutorial Examples:
602
710
  - `Illustration of vision transforms
603
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
711
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
604
712
  """
605
713
 
606
714
  @check_auto_contrast
@@ -663,7 +771,7 @@ class BoundingBoxAugment(ImageTensorOperation):
663
771
 
664
772
  Tutorial Examples:
665
773
  - `Illustration of vision transforms
666
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
774
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
667
775
  """
668
776
 
669
777
  @check_bounding_box_augment_cpp
@@ -717,7 +825,7 @@ class CenterCrop(ImageTensorOperation, PyTensorOperation):
717
825
 
718
826
  Tutorial Examples:
719
827
  - `Illustration of vision transforms
720
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
828
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
721
829
  """
722
830
 
723
831
  @check_center_crop
@@ -815,7 +923,7 @@ class ConvertColor(ImageTensorOperation):
815
923
 
816
924
  Tutorial Examples:
817
925
  - `Illustration of vision transforms
818
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
926
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
819
927
  """
820
928
 
821
929
  @check_convert_color
@@ -863,7 +971,7 @@ class Crop(ImageTensorOperation):
863
971
 
864
972
  Tutorial Examples:
865
973
  - `Illustration of vision transforms
866
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
974
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
867
975
  """
868
976
 
869
977
  @check_crop
@@ -919,7 +1027,7 @@ class CutMixBatch(ImageTensorOperation):
919
1027
 
920
1028
  Tutorial Examples:
921
1029
  - `Illustration of vision transforms
922
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1030
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
923
1031
  """
924
1032
 
925
1033
  @check_cut_mix_batch_c
@@ -966,7 +1074,7 @@ class CutOut(ImageTensorOperation):
966
1074
 
967
1075
  Tutorial Examples:
968
1076
  - `Illustration of vision transforms
969
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1077
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
970
1078
  """
971
1079
 
972
1080
  @check_cutout_new
@@ -998,7 +1106,7 @@ class Decode(ImageTensorOperation, PyTensorOperation):
998
1106
  RuntimeError: If the input image is already decoded.
999
1107
 
1000
1108
  Supported Platforms:
1001
- ``CPU``
1109
+ ``CPU`` ``Ascend``
1002
1110
 
1003
1111
  Examples:
1004
1112
  >>> import mindspore.dataset as ds
@@ -1017,7 +1125,7 @@ class Decode(ImageTensorOperation, PyTensorOperation):
1017
1125
 
1018
1126
  Tutorial Examples:
1019
1127
  - `Illustration of vision transforms
1020
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1128
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1021
1129
  """
1022
1130
 
1023
1131
  @check_decode
@@ -1044,8 +1152,43 @@ class Decode(ImageTensorOperation, PyTensorOperation):
1044
1152
  "but got {0}.".format(img.ndim))
1045
1153
  return super().__call__(img)
1046
1154
 
1155
+ @check_device_target
1156
+ def device(self, device_target="CPU"):
1157
+ """
1158
+ Set the device for the current operator execution.
1159
+
1160
+ Args:
1161
+ device_target (str, optional): The operator will be executed on this device. Currently supports
1162
+ ``CPU`` . Default: ``CPU`` .
1163
+
1164
+ Raises:
1165
+ TypeError: If `device_target` is not of type str.
1166
+ ValueError: If `device_target` is not ``CPU`` .
1167
+
1168
+ Supported Platforms:
1169
+ ``CPU``
1170
+
1171
+ Examples:
1172
+ >>> import mindspore.dataset as ds
1173
+ >>> import mindspore.dataset.vision as vision
1174
+ >>> from mindspore.dataset.vision import Inter
1175
+ >>>
1176
+ >>> decode_op = vision.Decode().device("Ascend")
1177
+ >>> resize_op = vision.Resize([100, 75], Inter.BICUBIC)
1178
+ >>> transforms_list = [decode_op, resize_op]
1179
+ >>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
1180
+ >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
1181
+ ... input_columns=["image"])
1182
+
1183
+ Tutorial Examples:
1184
+ - `Illustration of vision transforms
1185
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1186
+ """
1187
+ self.device_target = device_target
1188
+ return self
1189
+
1047
1190
  def parse(self):
1048
- return cde.DecodeOperation(True)
1191
+ return cde.DecodeOperation(True, self.device_target)
1049
1192
 
1050
1193
  def _execute_py(self, img):
1051
1194
  """
@@ -1081,7 +1224,7 @@ class Equalize(ImageTensorOperation, PyTensorOperation):
1081
1224
 
1082
1225
  Tutorial Examples:
1083
1226
  - `Illustration of vision transforms
1084
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1227
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1085
1228
  """
1086
1229
 
1087
1230
  def __init__(self):
@@ -1147,7 +1290,7 @@ class Erase(ImageTensorOperation):
1147
1290
 
1148
1291
  Tutorial Examples:
1149
1292
  - `Illustration of vision transforms
1150
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1293
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1151
1294
  """
1152
1295
 
1153
1296
  @check_erase
@@ -1199,7 +1342,7 @@ class FiveCrop(PyTensorOperation):
1199
1342
 
1200
1343
  Tutorial Examples:
1201
1344
  - `Illustration of vision transforms
1202
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1345
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1203
1346
  """
1204
1347
 
1205
1348
  @check_five_crop
@@ -1223,18 +1366,22 @@ class FiveCrop(PyTensorOperation):
1223
1366
 
1224
1367
 
1225
1368
  class GaussianBlur(ImageTensorOperation):
1226
- """
1369
+ r"""
1227
1370
  Blur input image with the specified Gaussian kernel.
1228
1371
 
1229
1372
  Args:
1230
- kernel_size (Union[int, Sequence[int]]): Size of the Gaussian kernel to use. The value must be positive and odd.
1231
- If only an integer is provided, the kernel size will be (kernel_size, kernel_size). If a sequence of integer
1232
- is provided, it must be a sequence of 2 values which represents (width, height).
1233
- sigma (Union[float, Sequence[float]], optional): Standard deviation of the Gaussian kernel to use.
1234
- Default: ``None``. The value must be positive. If only a float is provided, the sigma will be
1235
- (sigma, sigma).
1236
- If a sequence of float is provided, it must be a sequence of 2 values which represents (width, height).
1237
- If ``None`` is provided, the sigma will be calculated as ((kernel_size - 1) * 0.5 - 1) * 0.3 + 0.8.
1373
+ kernel_size (Union[int, Sequence[int, int]]): The size of the Gaussian kernel. Must be positive and odd.
1374
+ If the input type is int, the value will be used as both the width and height of the Gaussian kernel.
1375
+ If the input type is Sequence[int, int], the two elements will be used as the width and height of the
1376
+ Gaussian kernel respectively.
1377
+ sigma (Union[float, Sequence[float, float]], optional): The standard deviation of the Gaussian kernel.
1378
+ Must be positive.
1379
+ If the input type is float, the value will be used as the standard deviation of both the width and
1380
+ height of the Gaussian kernel.
1381
+ If the input type is Sequence[float, float], the two elements will be used as the standard deviation
1382
+ of the width and height of the Gaussian kernel respectively.
1383
+ Default: ``None`` , the standard deviation of the Gaussian kernel will be obtained by the
1384
+ formula :math:`((kernel\_size - 1) * 0.5 - 1) * 0.3 + 0.8` .
1238
1385
 
1239
1386
  Raises:
1240
1387
  TypeError: If `kernel_size` is not of type int or Sequence[int].
@@ -1257,7 +1404,7 @@ class GaussianBlur(ImageTensorOperation):
1257
1404
 
1258
1405
  Tutorial Examples:
1259
1406
  - `Illustration of vision transforms
1260
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1407
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1261
1408
  """
1262
1409
 
1263
1410
  @check_gaussian_blur
@@ -1307,7 +1454,7 @@ class Grayscale(PyTensorOperation):
1307
1454
 
1308
1455
  Tutorial Examples:
1309
1456
  - `Illustration of vision transforms
1310
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1457
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1311
1458
  """
1312
1459
 
1313
1460
  @check_num_channels
@@ -1351,7 +1498,7 @@ class HorizontalFlip(ImageTensorOperation):
1351
1498
 
1352
1499
  Tutorial Examples:
1353
1500
  - `Illustration of vision transforms
1354
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1501
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1355
1502
  """
1356
1503
 
1357
1504
  def __init__(self):
@@ -1392,7 +1539,7 @@ class HsvToRgb(PyTensorOperation):
1392
1539
 
1393
1540
  Tutorial Examples:
1394
1541
  - `Illustration of vision transforms
1395
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1542
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1396
1543
  """
1397
1544
 
1398
1545
  @check_hsv_to_rgb
@@ -1421,13 +1568,14 @@ class HWC2CHW(ImageTensorOperation):
1421
1568
  If the input image is of shape <H, W>, it will remain unchanged.
1422
1569
 
1423
1570
  Note:
1424
- This operation supports running on Ascend or GPU platforms by Offload.
1571
+ This operation is executed on the CPU by default, but it is also supported
1572
+ to be executed on the GPU or Ascend via heterogeneous acceleration.
1425
1573
 
1426
1574
  Raises:
1427
1575
  RuntimeError: If shape of the input image is not <H, W> or <H, W, C>.
1428
1576
 
1429
1577
  Supported Platforms:
1430
- ``CPU``
1578
+ ``CPU`` ``GPU`` ``Ascend``
1431
1579
 
1432
1580
  Examples:
1433
1581
  >>> import mindspore.dataset as ds
@@ -1443,7 +1591,7 @@ class HWC2CHW(ImageTensorOperation):
1443
1591
 
1444
1592
  Tutorial Examples:
1445
1593
  - `Illustration of vision transforms
1446
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1594
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1447
1595
  """
1448
1596
 
1449
1597
  def __init__(self):
@@ -1457,10 +1605,13 @@ class HWC2CHW(ImageTensorOperation):
1457
1605
 
1458
1606
  class Invert(ImageTensorOperation, PyTensorOperation):
1459
1607
  """
1460
- Apply invert on input image in RGB mode. This operation will reassign every pixel to (255 - pixel).
1608
+ Invert the colors of the input RGB image.
1609
+
1610
+ For each pixel in the image, if the original pixel value is `pixel`,
1611
+ the inverted pixel value will be `255 - pixel`.
1461
1612
 
1462
1613
  Raises:
1463
- RuntimeError: If given tensor shape is not <H, W, C>.
1614
+ RuntimeError: If the input image is not in shape of <H, W, C>.
1464
1615
 
1465
1616
  Supported Platforms:
1466
1617
  ``CPU``
@@ -1476,7 +1627,7 @@ class Invert(ImageTensorOperation, PyTensorOperation):
1476
1627
 
1477
1628
  Tutorial Examples:
1478
1629
  - `Illustration of vision transforms
1479
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1630
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1480
1631
  """
1481
1632
 
1482
1633
  def __init__(self):
@@ -1540,7 +1691,7 @@ class LinearTransformation(PyTensorOperation):
1540
1691
 
1541
1692
  Tutorial Examples:
1542
1693
  - `Illustration of vision transforms
1543
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1694
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1544
1695
  """
1545
1696
 
1546
1697
  @check_linear_transform
@@ -1606,12 +1757,12 @@ class MixUp(PyTensorOperation):
1606
1757
  >>> image_folder_dataset = image_folder_dataset.batch(batch_size=batch_size)
1607
1758
  >>> # finally mix up the images and labels
1608
1759
  >>> image_folder_dataset = image_folder_dataset.map(
1609
- ... operations=py_vision.MixUp(batch_size=batch_size, alpha=0.2),
1760
+ ... operations=vision.MixUp(batch_size=batch_size, alpha=0.2),
1610
1761
  ... input_columns=["image", "label"])
1611
1762
 
1612
1763
  Tutorial Examples:
1613
1764
  - `Illustration of vision transforms
1614
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1765
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1615
1766
  """
1616
1767
 
1617
1768
  @check_mix_up
@@ -1684,7 +1835,7 @@ class MixUpBatch(ImageTensorOperation):
1684
1835
 
1685
1836
  Tutorial Examples:
1686
1837
  - `Illustration of vision transforms
1687
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1838
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1688
1839
  """
1689
1840
 
1690
1841
  @check_mix_up_batch_c
@@ -1703,7 +1854,8 @@ class Normalize(ImageTensorOperation):
1703
1854
  the input image with: output[channel] = (input[channel] - mean[channel]) / std[channel], where channel >= 1.
1704
1855
 
1705
1856
  Note:
1706
- This operation supports running on Ascend or GPU platforms by Offload.
1857
+ This operation is executed on the CPU by default, but it is also supported
1858
+ to be executed on the GPU or Ascend via heterogeneous acceleration.
1707
1859
 
1708
1860
  Args:
1709
1861
  mean (sequence): List or tuple of mean values for each channel, with respect to channel order.
@@ -1722,7 +1874,7 @@ class Normalize(ImageTensorOperation):
1722
1874
  RuntimeError: If given tensor format is not <H, W> or <..., H, W, C>.
1723
1875
 
1724
1876
  Supported Platforms:
1725
- ``CPU``
1877
+ ``CPU`` ``GPU`` ``Ascend``
1726
1878
 
1727
1879
  Examples:
1728
1880
  >>> import mindspore.dataset as ds
@@ -1737,7 +1889,7 @@ class Normalize(ImageTensorOperation):
1737
1889
 
1738
1890
  Tutorial Examples:
1739
1891
  - `Illustration of vision transforms
1740
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
1892
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1741
1893
  """
1742
1894
 
1743
1895
  @check_normalize
@@ -1749,8 +1901,45 @@ class Normalize(ImageTensorOperation):
1749
1901
  self.random = False
1750
1902
  self.implementation = Implementation.C
1751
1903
 
1904
+ @check_device_target
1905
+ def device(self, device_target="CPU"):
1906
+ """
1907
+ Set the device for the current operator execution.
1908
+
1909
+ Args:
1910
+ device_target (str, optional): The operator will be executed on this device. Currently supports
1911
+ ``CPU`` . Default: ``CPU`` .
1912
+
1913
+ Raises:
1914
+ TypeError: If `device_target` is not of type str.
1915
+ ValueError: If `device_target` is not ``CPU`` .
1916
+
1917
+ Supported Platforms:
1918
+ ``CPU``
1919
+
1920
+ Examples:
1921
+ >>> import mindspore.dataset as ds
1922
+ >>> import mindspore.dataset.vision as vision
1923
+ >>> from mindspore.dataset.vision import Inter
1924
+ >>>
1925
+ >>> decode_op = vision.Decode()
1926
+ >>> resize_op = vision.Resize([100, 75], Inter.BICUBIC)
1927
+ >>> transforms_list = [decode_op, resize_op]
1928
+ >>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
1929
+ >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
1930
+ ... input_columns=["image"])
1931
+ >>> normalize_op = vision.Normalize(mean=[121.0, 115.0, 100.0], std=[70.0, 68.0, 71.0]).device("Ascend")
1932
+ >>> image_folder_dataset = image_folder_dataset.map(operations=normalize_op, input_columns=["image"])
1933
+
1934
+ Tutorial Examples:
1935
+ - `Illustration of vision transforms
1936
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1937
+ """
1938
+ self.device_target = device_target
1939
+ return self
1940
+
1752
1941
  def parse(self):
1753
- return cde.NormalizeOperation(self.mean, self.std, self.is_hwc)
1942
+ return cde.NormalizeOperation(self.mean, self.std, self.is_hwc, self.device_target)
1754
1943
 
1755
1944
 
1756
1945
  class NormalizePad(ImageTensorOperation):
@@ -1857,7 +2046,7 @@ class Pad(ImageTensorOperation, PyTensorOperation):
1857
2046
 
1858
2047
  Tutorial Examples:
1859
2048
  - `Illustration of vision transforms
1860
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2049
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1861
2050
  """
1862
2051
 
1863
2052
  @check_pad
@@ -1935,7 +2124,7 @@ class PadToSize(ImageTensorOperation):
1935
2124
 
1936
2125
  Tutorial Examples:
1937
2126
  - `Illustration of vision transforms
1938
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2127
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
1939
2128
  """
1940
2129
 
1941
2130
  @check_pad_to_size
@@ -1965,23 +2154,13 @@ class Perspective(ImageTensorOperation, PyTensorOperation):
1965
2154
  end_points (Sequence[Sequence[int, int]]): Sequence of the ending point coordinates, containing four
1966
2155
  two-element subsequences, corresponding to [top-left, top-right, bottom-right, bottom-left] of the
1967
2156
  quadrilateral in the target image.
1968
- interpolation (Inter, optional): Method of interpolation. It can be ``Inter.BILINEAR``, ``Inter.LINEAR``,
1969
- ``Inter.NEAREST``, ``Inter.AREA``, ``Inter.PILCUBIC``, ``Inter.CUBIC`` or ``Inter.BICUBIC``.
2157
+ interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
1970
2158
  Default: ``Inter.BILINEAR``.
1971
2159
 
1972
- - ``Inter.BILINEA`` , bilinear interpolation.
1973
- - ``Inter.LINEAR`` , linear interpolation, the same as Inter.BILINEAR.
1974
- - ``Inter.NEAREST`` , nearest-neighbor interpolation.
1975
- - ``Inter.BICUBIC`` , bicubic interpolation.
1976
- - ``Inter.CUBIC`` , cubic interpolation, the same as Inter.BICUBIC.
1977
- - ``Inter.PILCUBIC`` , cubic interpolation based on the implementation of Pillow,
1978
- only numpy.ndarray input is supported.
1979
- - ``Inter.AREA`` :, pixel area interpolation, only numpy.ndarray input is supported.
1980
-
1981
2160
  Raises:
1982
2161
  TypeError: If `start_points` is not of type Sequence[Sequence[int, int]].
1983
2162
  TypeError: If `end_points` is not of type Sequence[Sequence[int, int]].
1984
- TypeError: If `interpolation` is not of type :class:`mindspore.dataset.vision.Inter` .
2163
+ TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
1985
2164
  RuntimeError: If shape of the input image is not <H, W> or <H, W, C>.
1986
2165
 
1987
2166
  Supported Platforms:
@@ -2004,7 +2183,7 @@ class Perspective(ImageTensorOperation, PyTensorOperation):
2004
2183
 
2005
2184
  Tutorial Examples:
2006
2185
  - `Illustration of vision transforms
2007
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2186
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2008
2187
  """
2009
2188
 
2010
2189
  @check_perspective
@@ -2063,7 +2242,7 @@ class Posterize(ImageTensorOperation):
2063
2242
 
2064
2243
  Tutorial Examples:
2065
2244
  - `Illustration of vision transforms
2066
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2245
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2067
2246
  """
2068
2247
 
2069
2248
  @check_posterize
@@ -2090,14 +2269,8 @@ class RandAugment(ImageTensorOperation):
2090
2269
  `num_magnitude_bins`. Default: ``9``.
2091
2270
  num_magnitude_bins (int, optional): The number of different magnitude values,
2092
2271
  must be no less than 2. Default: ``31``.
2093
- interpolation (Inter, optional): Image interpolation method. Default: ``Inter.NEAREST``.
2094
- It can be ``Inter.NEAREST``, ``Inter.BILINEAR``, ``Inter.BICUBIC`` or ``Inter.AREA``.
2095
-
2096
- - ``Inter.NEAREST`` , nearest-neighbor interpolation.
2097
- - ``Inter.BILINEA`` , bilinear interpolation.
2098
- - ``Inter.BICUBIC`` , bicubic interpolation.
2099
- - ``Inter.AREA`` :, pixel area interpolation.
2100
-
2272
+ interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
2273
+ Default: ``Inter.NEAREST``.
2101
2274
  fill_value (Union[int, tuple[int, int, int]], optional): Pixel fill value for the area outside the
2102
2275
  transformed image, must be in range of [0, 255]. Default: ``0``.
2103
2276
  If int is provided, pad all RGB channels with this value.
@@ -2110,7 +2283,7 @@ class RandAugment(ImageTensorOperation):
2110
2283
  ValueError: If `magnitude` is not positive.
2111
2284
  TypeError: If `num_magnitude_bins` is not of type int.
2112
2285
  ValueError: If `num_magnitude_bins` is less than 2.
2113
- TypeError: If `interpolation` not of type :class:`mindspore.dataset.vision.Inter` .
2286
+ TypeError: If `interpolation` not of type :class:`~.vision.Inter` .
2114
2287
  TypeError: If `fill_value` is not of type int or tuple[int, int, int].
2115
2288
  ValueError: If `fill_value` is not in range of [0, 255].
2116
2289
  RuntimeError: If shape of the input image is not <H, W, C>.
@@ -2128,7 +2301,7 @@ class RandAugment(ImageTensorOperation):
2128
2301
 
2129
2302
  Tutorial Examples:
2130
2303
  - `Illustration of vision transforms
2131
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2304
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2132
2305
  """
2133
2306
 
2134
2307
  @check_rand_augment
@@ -2180,7 +2353,7 @@ class RandomAdjustSharpness(ImageTensorOperation):
2180
2353
 
2181
2354
  Tutorial Examples:
2182
2355
  - `Illustration of vision transforms
2183
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2356
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2184
2357
  """
2185
2358
 
2186
2359
  @check_random_adjust_sharpness
@@ -2223,17 +2396,8 @@ class RandomAffine(ImageTensorOperation, PyTensorOperation):
2223
2396
  If Sequence[float, float, float, float] is provided, a shearing parallel to X axis with a factor selected
2224
2397
  from ( `shear` [0], `shear` [1]) and a shearing parallel to Y axis with a factor selected from
2225
2398
  ( `shear` [2], `shear` [3]) will be applied. Default: ``None``, means no shearing.
2226
- resample (Inter, optional): An optional resampling filter. Default: ``Inter.NEAREST``.
2227
- It can be ``Inter.BILINEAR``, ``Inter.NEAREST``, ``Inter.BICUBIC``, ``Inter.AREA``.
2228
-
2229
- - ``Inter.BILINEA`` , means resample method is bilinear interpolation.
2230
-
2231
- - ``Inter.NEAREST`` , means resample method is nearest-neighbor interpolation.
2232
-
2233
- - ``Inter.BICUBIC`` , means resample method is bicubic interpolation.
2234
-
2235
- - ``Inter.AREA`` :, means resample method is pixel area interpolation.
2236
-
2399
+ resample (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
2400
+ Default: ``Inter.NEAREST``.
2237
2401
  fill_value (Union[int, tuple[int]], optional): Optional fill_value to fill the area outside the transform
2238
2402
  in the output image. There must be three elements in tuple and the value of single element is [0, 255].
2239
2403
  Default: ``0``, filling is performed.
@@ -2243,7 +2407,7 @@ class RandomAffine(ImageTensorOperation, PyTensorOperation):
2243
2407
  TypeError: If `translate` is not of type sequence.
2244
2408
  TypeError: If `scale` is not of type sequence.
2245
2409
  TypeError: If `shear` is not of type int, float or sequence.
2246
- TypeError: If `resample` is not of type :class:`mindspore.dataset.vision.Inter` .
2410
+ TypeError: If `resample` is not of type :class:`~.vision.Inter` .
2247
2411
  TypeError: If `fill_value` is not of type int or tuple[int].
2248
2412
  ValueError: If `degrees` is negative.
2249
2413
  ValueError: If `translate` is not in range [-1.0, 1.0].
@@ -2271,7 +2435,7 @@ class RandomAffine(ImageTensorOperation, PyTensorOperation):
2271
2435
 
2272
2436
  Tutorial Examples:
2273
2437
  - `Illustration of vision transforms
2274
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2438
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2275
2439
  """
2276
2440
 
2277
2441
  @check_random_affine
@@ -2378,7 +2542,7 @@ class RandomAutoContrast(ImageTensorOperation):
2378
2542
 
2379
2543
  Tutorial Examples:
2380
2544
  - `Illustration of vision transforms
2381
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2545
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2382
2546
  """
2383
2547
 
2384
2548
  @check_random_auto_contrast
@@ -2426,7 +2590,7 @@ class RandomColor(ImageTensorOperation, PyTensorOperation):
2426
2590
 
2427
2591
  Tutorial Examples:
2428
2592
  - `Illustration of vision transforms
2429
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2593
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2430
2594
  """
2431
2595
 
2432
2596
  @check_positive_degrees
@@ -2456,7 +2620,8 @@ class RandomColorAdjust(ImageTensorOperation, PyTensorOperation):
2456
2620
  Randomly adjust the brightness, contrast, saturation, and hue of the input image.
2457
2621
 
2458
2622
  Note:
2459
- This operation supports running on Ascend or GPU platforms by Offload.
2623
+ This operation is executed on the CPU by default, but it is also supported
2624
+ to be executed on the GPU or Ascend via heterogeneous acceleration.
2460
2625
 
2461
2626
  Args:
2462
2627
  brightness (Union[float, Sequence[float]], optional): Brightness adjustment factor. Default: ``(1, 1)``.
@@ -2487,7 +2652,7 @@ class RandomColorAdjust(ImageTensorOperation, PyTensorOperation):
2487
2652
  RuntimeError: If given tensor shape is not <H, W, C>.
2488
2653
 
2489
2654
  Supported Platforms:
2490
- ``CPU``
2655
+ ``CPU`` ``GPU`` ``Ascend``
2491
2656
 
2492
2657
  Examples:
2493
2658
  >>> import mindspore.dataset as ds
@@ -2504,7 +2669,7 @@ class RandomColorAdjust(ImageTensorOperation, PyTensorOperation):
2504
2669
 
2505
2670
  Tutorial Examples:
2506
2671
  - `Illustration of vision transforms
2507
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2672
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2508
2673
  """
2509
2674
 
2510
2675
  @check_random_color_adjust
@@ -2614,7 +2779,7 @@ class RandomCrop(ImageTensorOperation, PyTensorOperation):
2614
2779
 
2615
2780
  Tutorial Examples:
2616
2781
  - `Illustration of vision transforms
2617
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2782
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2618
2783
  """
2619
2784
 
2620
2785
  @check_random_crop
@@ -2666,20 +2831,8 @@ class RandomCropDecodeResize(ImageTensorOperation):
2666
2831
  original size to be cropped, which must be non-negative. Default: ``(0.08, 1.0)``.
2667
2832
  ratio (Union[list, tuple], optional): Range [min, max) of aspect ratio to be
2668
2833
  cropped, which must be non-negative. Default: ``(3. / 4., 4. / 3.)``.
2669
- interpolation (Inter, optional): Image interpolation mode for resize operation. Default: ``Inter.BILINEAR``.
2670
- It can be ``Inter.BILINEAR``, ``Inter.NEAREST``, ``Inter.BICUBIC``, ``Inter.AREA``, ``Inter.PILCUBIC``.
2671
-
2672
- - ``Inter.BILINEA`` , means interpolation method is bilinear interpolation.
2673
-
2674
- - ``Inter.NEAREST`` , means interpolation method is nearest-neighbor interpolation.
2675
-
2676
- - ``Inter.BICUBIC`` , means interpolation method is bicubic interpolation.
2677
-
2678
- - ``Inter.AREA`` :, means interpolation method is pixel area interpolation.
2679
-
2680
- - ``Inter.PILCUBIC`` , means interpolation method is bicubic interpolation like implemented in pillow, input
2681
- should be in 3 channels format.
2682
-
2834
+ interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
2835
+ Default: ``Inter.BILINEAR``.
2683
2836
  max_attempts (int, optional): The maximum number of attempts to propose a valid crop_area. Default: ``10``.
2684
2837
  If exceeded, fall back to use center_crop instead. The `max_attempts` value must be positive.
2685
2838
 
@@ -2687,7 +2840,7 @@ class RandomCropDecodeResize(ImageTensorOperation):
2687
2840
  TypeError: If `size` is not of type int or Sequence[int].
2688
2841
  TypeError: If `scale` is not of type tuple.
2689
2842
  TypeError: If `ratio` is not of type tuple.
2690
- TypeError: If `interpolation` is not of type :class:`mindspore.dataset.vision.Inter` .
2843
+ TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
2691
2844
  TypeError: If `max_attempts` is not of type integer.
2692
2845
  ValueError: If `size` is not positive.
2693
2846
  ValueError: If `scale` is negative.
@@ -2714,7 +2867,7 @@ class RandomCropDecodeResize(ImageTensorOperation):
2714
2867
 
2715
2868
  Tutorial Examples:
2716
2869
  - `Illustration of vision transforms
2717
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2870
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2718
2871
  """
2719
2872
 
2720
2873
  @check_random_resize_crop
@@ -2807,7 +2960,7 @@ class RandomCropWithBBox(ImageTensorOperation):
2807
2960
 
2808
2961
  Tutorial Examples:
2809
2962
  - `Illustration of vision transforms
2810
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
2963
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2811
2964
  """
2812
2965
 
2813
2966
  @check_random_crop
@@ -2863,7 +3016,7 @@ class RandomEqualize(ImageTensorOperation):
2863
3016
 
2864
3017
  Tutorial Examples:
2865
3018
  - `Illustration of vision transforms
2866
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3019
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2867
3020
  """
2868
3021
 
2869
3022
  @check_prob
@@ -2930,7 +3083,7 @@ class RandomErasing(PyTensorOperation):
2930
3083
 
2931
3084
  Tutorial Examples:
2932
3085
  - `Illustration of vision transforms
2933
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3086
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2934
3087
  """
2935
3088
 
2936
3089
  @check_random_erasing
@@ -2992,7 +3145,7 @@ class RandomGrayscale(PyTensorOperation):
2992
3145
 
2993
3146
  Tutorial Examples:
2994
3147
  - `Illustration of vision transforms
2995
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3148
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
2996
3149
  """
2997
3150
 
2998
3151
  @check_prob
@@ -3050,7 +3203,7 @@ class RandomHorizontalFlip(ImageTensorOperation, PyTensorOperation):
3050
3203
 
3051
3204
  Tutorial Examples:
3052
3205
  - `Illustration of vision transforms
3053
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3206
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3054
3207
  """
3055
3208
 
3056
3209
  @check_prob
@@ -3076,7 +3229,7 @@ class RandomHorizontalFlip(ImageTensorOperation, PyTensorOperation):
3076
3229
 
3077
3230
  class RandomHorizontalFlipWithBBox(ImageTensorOperation):
3078
3231
  """
3079
- Flip the input image horizontally randomly with a given probability and adjust bounding boxes accordingly.
3232
+ Randomly flip the input image and its bounding box horizontally with a given probability.
3080
3233
 
3081
3234
  Args:
3082
3235
  prob (float, optional): Probability of the image being flipped,
@@ -3101,7 +3254,7 @@ class RandomHorizontalFlipWithBBox(ImageTensorOperation):
3101
3254
 
3102
3255
  Tutorial Examples:
3103
3256
  - `Illustration of vision transforms
3104
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3257
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3105
3258
  """
3106
3259
 
3107
3260
  @check_prob
@@ -3141,7 +3294,7 @@ class RandomInvert(ImageTensorOperation):
3141
3294
 
3142
3295
  Tutorial Examples:
3143
3296
  - `Illustration of vision transforms
3144
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3297
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3145
3298
  """
3146
3299
 
3147
3300
  @check_prob
@@ -3181,7 +3334,7 @@ class RandomLighting(ImageTensorOperation, PyTensorOperation):
3181
3334
 
3182
3335
  Tutorial Examples:
3183
3336
  - `Illustration of vision transforms
3184
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3337
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3185
3338
  """
3186
3339
 
3187
3340
  @check_alpha
@@ -3214,17 +3367,13 @@ class RandomPerspective(PyTensorOperation):
3214
3367
  distortion_scale (float, optional): Scale of distortion, in range of [0.0, 1.0]. Default: ``0.5``.
3215
3368
  prob (float, optional): Probability of performing perspective transformation, which
3216
3369
  must be in range of [0.0, 1.0]. Default: ``0.5``.
3217
- interpolation (Inter, optional): Method of interpolation. It can be ``Inter.BILINEAR``,
3218
- ``Inter.NEAREST`` or ``Inter.BICUBIC``. Default: ``Inter.BICUBIC``.
3219
-
3220
- - ``Inter.BILINEA`` , bilinear interpolation.
3221
- - ``Inter.NEAREST`` , nearest-neighbor interpolation.
3222
- - ``Inter.BICUBIC`` , bicubic interpolation.
3370
+ interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
3371
+ Default: ``Inter.BICUBIC``.
3223
3372
 
3224
3373
  Raises:
3225
3374
  TypeError: If `distortion_scale` is not of type float.
3226
3375
  TypeError: If `prob` is not of type float.
3227
- TypeError: If `interpolation` is not of type :class:`mindspore.dataset.vision.Inter` .
3376
+ TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
3228
3377
  ValueError: If `distortion_scale` is not in range of [0.0, 1.0].
3229
3378
  ValueError: If `prob` is not in range of [0.0, 1.0].
3230
3379
 
@@ -3246,7 +3395,7 @@ class RandomPerspective(PyTensorOperation):
3246
3395
 
3247
3396
  Tutorial Examples:
3248
3397
  - `Illustration of vision transforms
3249
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3398
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3250
3399
  """
3251
3400
 
3252
3401
  @check_random_perspective
@@ -3309,7 +3458,7 @@ class RandomPosterize(ImageTensorOperation):
3309
3458
 
3310
3459
  Tutorial Examples:
3311
3460
  - `Illustration of vision transforms
3312
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3461
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3313
3462
  """
3314
3463
 
3315
3464
  @check_random_posterize
@@ -3328,7 +3477,7 @@ class RandomPosterize(ImageTensorOperation):
3328
3477
  class RandomResizedCrop(ImageTensorOperation, PyTensorOperation):
3329
3478
  """
3330
3479
  This operation will crop the input image randomly,
3331
- and resize the cropped image using a selected interpolation mode :class:`mindspore.dataset.vision.Inter` .
3480
+ and resize the cropped image using a selected interpolation mode :class:`~.vision.Inter` .
3332
3481
 
3333
3482
  Note:
3334
3483
  If the input image is more than one, then make sure that the image size is the same.
@@ -3341,22 +3490,8 @@ class RandomResizedCrop(ImageTensorOperation, PyTensorOperation):
3341
3490
  size to be cropped, which must be non-negative. Default: ``(0.08, 1.0)``.
3342
3491
  ratio (Union[list, tuple], optional): Range [min, max) of aspect ratio to be
3343
3492
  cropped, which must be non-negative. Default: ``(3. / 4., 4. / 3.)``.
3344
- interpolation (Inter, optional): Method of interpolation. Default: ``Inter.BILINEAR``.
3345
- It can be ``Inter.BILINEAR``, ``Inter.NEAREST``, ``Inter.BICUBIC``, ``Inter.AREA``, ``Inter.PILCUBIC``.
3346
-
3347
- - ``Inter.BILINEA`` , means interpolation method is bilinear interpolation.
3348
-
3349
- - ``Inter.NEAREST`` , means interpolation method is nearest-neighbor interpolation.
3350
-
3351
- - ``Inter.BICUBIC`` , means interpolation method is bicubic interpolation.
3352
-
3353
- - ``Inter.AREA`` :, means interpolation method is pixel area interpolation.
3354
-
3355
- - ``Inter.PILCUBIC`` , means interpolation method is bicubic interpolation like implemented in pillow, input
3356
- should be in 3 channels format.
3357
-
3358
- - ``Inter.ANTIALIAS`` , means the interpolation method is antialias interpolation.
3359
-
3493
+ interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
3494
+ Default: ``Inter.BILINEAR``.
3360
3495
  max_attempts (int, optional): The maximum number of attempts to propose a valid
3361
3496
  crop_area. Default: ``10``. If exceeded, fall back to use center_crop instead.
3362
3497
 
@@ -3364,7 +3499,7 @@ class RandomResizedCrop(ImageTensorOperation, PyTensorOperation):
3364
3499
  TypeError: If `size` is not of type int or Sequence[int].
3365
3500
  TypeError: If `scale` is not of type tuple or list.
3366
3501
  TypeError: If `ratio` is not of type tuple or list.
3367
- TypeError: If `interpolation` is not of type :class:`mindspore.dataset.vision.Inter` .
3502
+ TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
3368
3503
  TypeError: If `max_attempts` is not of type int.
3369
3504
  ValueError: If `size` is not positive.
3370
3505
  ValueError: If `scale` is negative.
@@ -3389,7 +3524,7 @@ class RandomResizedCrop(ImageTensorOperation, PyTensorOperation):
3389
3524
 
3390
3525
  Tutorial Examples:
3391
3526
  - `Illustration of vision transforms
3392
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3527
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3393
3528
  """
3394
3529
 
3395
3530
  @check_random_resize_crop
@@ -3442,15 +3577,8 @@ class RandomResizedCropWithBBox(ImageTensorOperation):
3442
3577
  size to be cropped, which must be non-negative. Default: ``(0.08, 1.0)``.
3443
3578
  ratio (Union[list, tuple], optional): Range (min, max) of aspect ratio to be
3444
3579
  cropped, which must be non-negative. Default: ``(3. / 4., 4. / 3.)``.
3445
- interpolation (Inter, optional): Image interpolation mode. Default: ``Inter.BILINEAR``.
3446
- It can be ``Inter.BILINEAR``, ``Inter.NEAREST``, ``Inter.BICUBIC``.
3447
-
3448
- - ``Inter.BILINEA`` , means interpolation method is bilinear interpolation.
3449
-
3450
- - ``Inter.NEAREST`` , means interpolation method is nearest-neighbor interpolation.
3451
-
3452
- - ``Inter.BICUBIC`` , means interpolation method is bicubic interpolation.
3453
-
3580
+ interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
3581
+ Default: ``Inter.BILINEAR``.
3454
3582
  max_attempts (int, optional): The maximum number of attempts to propose a valid
3455
3583
  crop area. Default: ``10``. If exceeded, fall back to use center crop instead.
3456
3584
 
@@ -3483,7 +3611,7 @@ class RandomResizedCropWithBBox(ImageTensorOperation):
3483
3611
 
3484
3612
  Tutorial Examples:
3485
3613
  - `Illustration of vision transforms
3486
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3614
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3487
3615
  """
3488
3616
 
3489
3617
  @check_random_resize_crop
@@ -3506,7 +3634,7 @@ class RandomResizedCropWithBBox(ImageTensorOperation):
3506
3634
 
3507
3635
  class RandomResize(ImageTensorOperation):
3508
3636
  """
3509
- Resize the input image using :class:`mindspore.dataset.vision.Inter` , a randomly selected interpolation mode.
3637
+ Resize the input image using :class:`~.vision.Inter` , a randomly selected interpolation mode.
3510
3638
 
3511
3639
  Args:
3512
3640
  size (Union[int, Sequence[int]]): The output size of the resized image. The size value(s) must be positive.
@@ -3538,7 +3666,7 @@ class RandomResize(ImageTensorOperation):
3538
3666
 
3539
3667
  Tutorial Examples:
3540
3668
  - `Illustration of vision transforms
3541
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3669
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3542
3670
  """
3543
3671
 
3544
3672
  @check_resize
@@ -3557,7 +3685,7 @@ class RandomResize(ImageTensorOperation):
3557
3685
  class RandomResizeWithBBox(ImageTensorOperation):
3558
3686
  """
3559
3687
  Tensor operation to resize the input image
3560
- using a randomly selected interpolation mode :class:`mindspore.dataset.vision.Inter` and adjust
3688
+ using a randomly selected interpolation mode :class:`~.vision.Inter` and adjust
3561
3689
  bounding boxes accordingly.
3562
3690
 
3563
3691
  Args:
@@ -3592,7 +3720,7 @@ class RandomResizeWithBBox(ImageTensorOperation):
3592
3720
 
3593
3721
  Tutorial Examples:
3594
3722
  - `Illustration of vision transforms
3595
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3723
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3596
3724
  """
3597
3725
 
3598
3726
  @check_resize
@@ -3616,17 +3744,8 @@ class RandomRotation(ImageTensorOperation, PyTensorOperation):
3616
3744
  degrees (Union[int, float, sequence]): Range of random rotation degrees.
3617
3745
  If `degrees` is a number, the range will be converted to (-degrees, degrees).
3618
3746
  If `degrees` is a sequence, it should be (min, max).
3619
- resample (Inter, optional): An optional resampling filter. Default: ``Inter.NEAREST``.
3620
- It can be ``Inter.BILINEAR``, ``Inter.NEAREST``, ``Inter.BICUBIC``, ``Inter.AREA``.
3621
-
3622
- - ``Inter.BILINEA`` , means resample method is bilinear interpolation.
3623
-
3624
- - ``Inter.NEAREST`` , means resample method is nearest-neighbor interpolation.
3625
-
3626
- - ``Inter.BICUBIC`` , means resample method is bicubic interpolation.
3627
-
3628
- - ``Inter.AREA`` :, means the interpolation method is pixel area interpolation.
3629
-
3747
+ resample (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
3748
+ Default: ``Inter.NEAREST``.
3630
3749
  expand (bool, optional): Optional expansion flag. Default: ``False``. If set to ``True``,
3631
3750
  expand the output image to make it large enough to hold the entire rotated image.
3632
3751
  If set to ``False`` or omitted, make the output image the same size as the input.
@@ -3665,7 +3784,7 @@ class RandomRotation(ImageTensorOperation, PyTensorOperation):
3665
3784
 
3666
3785
  Tutorial Examples:
3667
3786
  - `Illustration of vision transforms
3668
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3787
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3669
3788
  """
3670
3789
 
3671
3790
  @check_random_rotation
@@ -3750,7 +3869,7 @@ class RandomSelectSubpolicy(ImageTensorOperation):
3750
3869
 
3751
3870
  Tutorial Examples:
3752
3871
  - `Illustration of vision transforms
3753
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3872
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3754
3873
  """
3755
3874
 
3756
3875
  @check_random_select_subpolicy_op
@@ -3801,7 +3920,7 @@ class RandomSharpness(ImageTensorOperation, PyTensorOperation):
3801
3920
 
3802
3921
  Tutorial Examples:
3803
3922
  - `Illustration of vision transforms
3804
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3923
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3805
3924
  """
3806
3925
 
3807
3926
  @check_positive_degrees
@@ -3855,7 +3974,7 @@ class RandomSolarize(ImageTensorOperation):
3855
3974
 
3856
3975
  Tutorial Examples:
3857
3976
  - `Illustration of vision transforms
3858
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
3977
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3859
3978
  """
3860
3979
 
3861
3980
  @check_random_solarize
@@ -3895,7 +4014,7 @@ class RandomVerticalFlip(ImageTensorOperation, PyTensorOperation):
3895
4014
 
3896
4015
  Tutorial Examples:
3897
4016
  - `Illustration of vision transforms
3898
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4017
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3899
4018
  """
3900
4019
 
3901
4020
  @check_prob
@@ -3946,7 +4065,7 @@ class RandomVerticalFlipWithBBox(ImageTensorOperation):
3946
4065
 
3947
4066
  Tutorial Examples:
3948
4067
  - `Illustration of vision transforms
3949
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4068
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3950
4069
  """
3951
4070
 
3952
4071
  @check_prob
@@ -3965,7 +4084,8 @@ class Rescale(ImageTensorOperation):
3965
4084
  with: output = image * rescale + shift.
3966
4085
 
3967
4086
  Note:
3968
- This operation supports running on Ascend or GPU platforms by Offload.
4087
+ This operation is executed on the CPU by default, but it is also supported
4088
+ to be executed on the GPU or Ascend via heterogeneous acceleration.
3969
4089
 
3970
4090
  Args:
3971
4091
  rescale (float): Rescale factor.
@@ -3976,7 +4096,7 @@ class Rescale(ImageTensorOperation):
3976
4096
  TypeError: If `shift` is not of type float.
3977
4097
 
3978
4098
  Supported Platforms:
3979
- ``Ascend`` ``GPU`` ``CPU``
4099
+ ``CPU`` ``GPU`` ``Ascend``
3980
4100
 
3981
4101
  Examples:
3982
4102
  >>> import mindspore.dataset as ds
@@ -3989,7 +4109,7 @@ class Rescale(ImageTensorOperation):
3989
4109
 
3990
4110
  Tutorial Examples:
3991
4111
  - `Illustration of vision transforms
3992
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4112
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
3993
4113
  """
3994
4114
 
3995
4115
  @check_rescale
@@ -4005,34 +4125,24 @@ class Rescale(ImageTensorOperation):
4005
4125
 
4006
4126
  class Resize(ImageTensorOperation, PyTensorOperation):
4007
4127
  """
4008
- Resize the input image to the given size with a given interpolation mode :class:`mindspore.dataset.vision.Inter` .
4128
+ Resize the input image to the given size with a given interpolation mode :class:`~.vision.Inter` .
4009
4129
 
4010
4130
  Args:
4011
4131
  size (Union[int, Sequence[int]]): The output size of the resized image. The size value(s) must be positive.
4012
4132
  If size is an integer, the smaller edge of the image will be resized to this value with
4013
4133
  the same image aspect ratio.
4014
4134
  If size is a sequence of length 2, it should be (height, width).
4015
- interpolation (Inter, optional): Image interpolation mode. Default: ``Inter.LINEAR``.
4016
- It can be ``Inter.BILINEAR``, ``Inter.LINEAR``, ``Inter.NEAREST``, ``Inter.BICUBIC``, ``Inter.AREA``,
4017
- ``Inter.PILCUBIC``, ``Inter.ANTIALIAS``.
4018
-
4019
- - ``Inter.BILINEAR``, bilinear interpolation.
4020
- - ``Inter.LINEAR``, bilinear interpolation, here is the same as Inter.BILINEAR.
4021
- - ``Inter.NEAREST``, nearest-neighbor interpolation.
4022
- - ``Inter.BICUBIC``, bicubic interpolation.
4023
- - ``Inter.AREA``, pixel area interpolation.
4024
- - ``Inter.PILCUBIC``, bicubic interpolation like implemented in Pillow, only valid when the input is
4025
- a 3-channel image in the numpy.ndarray format.
4026
- - ``Inter.ANTIALIAS``, antialias interpolation.
4135
+ interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
4136
+ Default: ``Inter.LINEAR``.
4027
4137
 
4028
4138
  Raises:
4029
4139
  TypeError: If `size` is not of type int or Sequence[int].
4030
- TypeError: If `interpolation` is not of type :class:`mindspore.dataset.vision.Inter` .
4140
+ TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
4031
4141
  ValueError: If `size` is not positive.
4032
4142
  RuntimeError: If given tensor shape is not <H, W> or <H, W, C>.
4033
4143
 
4034
4144
  Supported Platforms:
4035
- ``CPU``
4145
+ ``CPU`` ``Ascend``
4036
4146
 
4037
4147
  Examples:
4038
4148
  >>> import mindspore.dataset as ds
@@ -4048,7 +4158,7 @@ class Resize(ImageTensorOperation, PyTensorOperation):
4048
4158
 
4049
4159
  Tutorial Examples:
4050
4160
  - `Illustration of vision transforms
4051
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4161
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4052
4162
  """
4053
4163
 
4054
4164
  @check_resize_interpolation
@@ -4065,10 +4175,48 @@ class Resize(ImageTensorOperation, PyTensorOperation):
4065
4175
  self.implementation = Implementation.PY
4066
4176
  self.random = False
4067
4177
 
4178
+ @check_device_target
4179
+ def device(self, device_target="CPU"):
4180
+ """
4181
+ Set the device for the current operator execution.
4182
+
4183
+ Args:
4184
+ device_target (str, optional): The operator will be executed on this device. Currently supports
4185
+ ``CPU`` . Default: ``CPU`` .
4186
+
4187
+ Raises:
4188
+ TypeError: If `device_target` is not of type str.
4189
+ ValueError: If `device_target` is not ``CPU`` .
4190
+
4191
+ Supported Platforms:
4192
+ ``CPU``
4193
+
4194
+ Examples:
4195
+ >>> import mindspore.dataset as ds
4196
+ >>> import mindspore.dataset.vision as vision
4197
+ >>> from mindspore.dataset.vision import Inter
4198
+ >>>
4199
+ >>> decode_op = vision.Decode()
4200
+ >>> resize_op = vision.Resize([100, 75], Inter.BICUBIC).device("Ascend")
4201
+ >>> transforms_list = [decode_op, resize_op]
4202
+ >>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
4203
+ >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
4204
+ ... input_columns=["image"])
4205
+
4206
+ Tutorial Examples:
4207
+ - `Illustration of vision transforms
4208
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4209
+ """
4210
+ self.device_target = device_target
4211
+ if self.interpolation == Inter.ANTIALIAS and self.device_target == "Ascend":
4212
+ raise ValueError("The current InterpolationMode is not supported by DVPP. It is {}."
4213
+ .format(self.interpolation))
4214
+ return self
4215
+
4068
4216
  def parse(self):
4069
4217
  if self.interpolation == Inter.ANTIALIAS:
4070
- raise TypeError("Current Interpolation is not supported with NumPy input.")
4071
- return cde.ResizeOperation(self.c_size, Inter.to_c_type(self.interpolation))
4218
+ raise TypeError("The current InterpolationMode is not supported with NumPy input.")
4219
+ return cde.ResizeOperation(self.c_size, Inter.to_c_type(self.interpolation), self.device_target)
4072
4220
 
4073
4221
  def _execute_py(self, img):
4074
4222
  """
@@ -4098,14 +4246,8 @@ class ResizedCrop(ImageTensorOperation):
4098
4246
  If int is provided, the smaller edge of the image will be resized to this value,
4099
4247
  keeping the image aspect ratio the same.
4100
4248
  If Sequence[int, int] is provided, it should be (height, width).
4101
- interpolation (Inter, optional): Image interpolation method. Default: ``Inter.BILINEAR``.
4102
- It can be ``Inter.LINEAR``, ``Inter.NEAREST``, ``Inter.BICUBIC``, ``Inter.AREA`` or ``Inter.PILCUBIC``.
4103
-
4104
- - ``Inter.LINEAR`` , bilinear interpolation.
4105
- - ``Inter.NEAREST`` , nearest-neighbor interpolation.
4106
- - ``Inter.BICUBIC`` , bicubic interpolation.
4107
- - ``Inter.AREA`` :, pixel area interpolation.
4108
- - ``Inter.PILCUBIC`` , cubic interpolation based on the implementation of Pillow
4249
+ interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
4250
+ Default: ``Inter.BILINEAR``.
4109
4251
 
4110
4252
  Raises:
4111
4253
  TypeError: If `top` is not of type int.
@@ -4118,7 +4260,7 @@ class ResizedCrop(ImageTensorOperation):
4118
4260
  ValueError: If `width` is not positive.
4119
4261
  TypeError: If `size` is not of type int or Sequence[int, int].
4120
4262
  ValueError: If `size` is not posotive.
4121
- TypeError: If `interpolation` is not of type :class:`mindspore.dataset.vision.Inter` .
4263
+ TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
4122
4264
  RuntimeError: If shape of the input image is not <H, W> or <H, W, C>.
4123
4265
 
4124
4266
  Supported Platforms:
@@ -4136,7 +4278,7 @@ class ResizedCrop(ImageTensorOperation):
4136
4278
 
4137
4279
  Tutorial Examples:
4138
4280
  - `Illustration of vision transforms
4139
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4281
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4140
4282
  """
4141
4283
 
4142
4284
  @check_resized_crop
@@ -4167,18 +4309,12 @@ class ResizeWithBBox(ImageTensorOperation):
4167
4309
  If size is an integer, smaller edge of the image will be resized to this value with
4168
4310
  the same image aspect ratio.
4169
4311
  If size is a sequence of length 2, it should be (height, width).
4170
- interpolation (Inter, optional): Image interpolation mode. Default: ``Inter.LINEAR``.
4171
- It can be ``Inter.LINEAR``, ``Inter.NEAREST``, ``Inter.BICUBIC``.
4172
-
4173
- - ``Inter.LINEAR`` , means interpolation method is bilinear interpolation.
4174
-
4175
- - ``Inter.NEAREST`` , means interpolation method is nearest-neighbor interpolation.
4176
-
4177
- - ``Inter.BICUBIC`` , means interpolation method is bicubic interpolation.
4312
+ interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
4313
+ Default: ``Inter.LINEAR``.
4178
4314
 
4179
4315
  Raises:
4180
4316
  TypeError: If `size` is not of type int or Sequence[int].
4181
- TypeError: If `interpolation` is not of type :class:`mindspore.dataset.vision.Inter` .
4317
+ TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
4182
4318
  ValueError: If `size` is not positive.
4183
4319
  RuntimeError: If given tensor shape is not <H, W> or <H, W, C>.
4184
4320
 
@@ -4199,7 +4335,7 @@ class ResizeWithBBox(ImageTensorOperation):
4199
4335
 
4200
4336
  Tutorial Examples:
4201
4337
  - `Illustration of vision transforms
4202
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4338
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4203
4339
  """
4204
4340
 
4205
4341
  @check_resize_interpolation
@@ -4246,7 +4382,7 @@ class RgbToHsv(PyTensorOperation):
4246
4382
 
4247
4383
  Tutorial Examples:
4248
4384
  - `Illustration of vision transforms
4249
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4385
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4250
4386
  """
4251
4387
 
4252
4388
  @check_rgb_to_hsv
@@ -4275,14 +4411,8 @@ class Rotate(ImageTensorOperation):
4275
4411
 
4276
4412
  Args:
4277
4413
  degrees (Union[int, float]): Rotation degrees.
4278
-
4279
- resample (Inter, optional): An optional resampling filter. Default: ``Inter.NEAREST``.
4280
- It can be ``Inter.BILINEAR``, ``Inter.NEAREST``, ``Inter.BICUBIC``.
4281
-
4282
- - ``Inter.BILINEA`` , means resample method is bilinear interpolation.
4283
- - ``Inter.NEAREST`` , means resample method is nearest-neighbor interpolation.
4284
- - ``Inter.BICUBIC`` , means resample method is bicubic interpolation.
4285
-
4414
+ resample (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
4415
+ Default: ``Inter.NEAREST``.
4286
4416
  expand (bool, optional): Optional expansion flag. Default: ``False``. If set to ``True``,
4287
4417
  expand the output image to make it large enough to hold the entire rotated image.
4288
4418
  If set to ``False`` or omitted, make the output image the same size as the input.
@@ -4296,7 +4426,7 @@ class Rotate(ImageTensorOperation):
4296
4426
 
4297
4427
  Raises:
4298
4428
  TypeError: If `degrees` is not of type integer, float or sequence.
4299
- TypeError: If `resample` is not of type :class:`mindspore.dataset.vision.Inter` .
4429
+ TypeError: If `resample` is not of type :class:`~.vision.Inter` .
4300
4430
  TypeError: If `expand` is not of type bool.
4301
4431
  TypeError: If `center` is not of type tuple.
4302
4432
  TypeError: If `fill_value` is not of type int or tuple[int].
@@ -4321,7 +4451,7 @@ class Rotate(ImageTensorOperation):
4321
4451
 
4322
4452
  Tutorial Examples:
4323
4453
  - `Illustration of vision transforms
4324
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4454
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4325
4455
  """
4326
4456
 
4327
4457
  @check_rotate
@@ -4394,7 +4524,7 @@ class SlicePatches(ImageTensorOperation):
4394
4524
 
4395
4525
  Tutorial Examples:
4396
4526
  - `Illustration of vision transforms
4397
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4527
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4398
4528
  """
4399
4529
 
4400
4530
  @check_slice_patches
@@ -4438,7 +4568,7 @@ class Solarize(ImageTensorOperation):
4438
4568
 
4439
4569
  Tutorial Examples:
4440
4570
  - `Illustration of vision transforms
4441
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4571
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4442
4572
  """
4443
4573
 
4444
4574
  @check_solarize
@@ -4489,7 +4619,7 @@ class TenCrop(PyTensorOperation):
4489
4619
 
4490
4620
  Tutorial Examples:
4491
4621
  - `Illustration of vision transforms
4492
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4622
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4493
4623
  """
4494
4624
 
4495
4625
  @check_ten_crop
@@ -4540,7 +4670,7 @@ class ToNumpy(PyTensorOperation):
4540
4670
 
4541
4671
  Tutorial Examples:
4542
4672
  - `Illustration of vision transforms
4543
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4673
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4544
4674
  """
4545
4675
 
4546
4676
  def __init__(self):
@@ -4566,9 +4696,6 @@ class ToPIL(PyTensorOperation):
4566
4696
  """
4567
4697
  Convert the input decoded numpy.ndarray image to PIL Image.
4568
4698
 
4569
- Note:
4570
- The conversion mode will be determined by the data type using `PIL.Image.fromarray` .
4571
-
4572
4699
  Raises:
4573
4700
  TypeError: If the input image is not of type :class:`numpy.ndarray` or `PIL.Image.Image` .
4574
4701
 
@@ -4591,7 +4718,7 @@ class ToPIL(PyTensorOperation):
4591
4718
 
4592
4719
  Tutorial Examples:
4593
4720
  - `Illustration of vision transforms
4594
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4721
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4595
4722
  """
4596
4723
 
4597
4724
  def __init__(self):
@@ -4644,7 +4771,7 @@ class ToTensor(ImageTensorOperation):
4644
4771
 
4645
4772
  Tutorial Examples:
4646
4773
  - `Illustration of vision transforms
4647
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4774
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4648
4775
  """
4649
4776
 
4650
4777
  @check_to_tensor
@@ -4669,7 +4796,8 @@ class ToType(TypeCast):
4669
4796
  It is the same as that of :class:`mindspore.dataset.transforms.TypeCast` .
4670
4797
 
4671
4798
  Note:
4672
- This operation supports running on Ascend or GPU platforms by Offload.
4799
+ This operation is executed on the CPU by default, but it is also supported
4800
+ to be executed on the GPU or Ascend via heterogeneous acceleration.
4673
4801
 
4674
4802
  Args:
4675
4803
  data_type (Union[mindspore.dtype, numpy.dtype]): The desired data type of the output image,
@@ -4679,7 +4807,7 @@ class ToType(TypeCast):
4679
4807
  TypeError: If `data_type` is not of type :class:`mindspore.dtype` or :class:`numpy.dtype` .
4680
4808
 
4681
4809
  Supported Platforms:
4682
- ``Ascend`` ``GPU`` ``CPU``
4810
+ ``CPU`` ``GPU`` ``Ascend``
4683
4811
 
4684
4812
  Examples:
4685
4813
  >>> import mindspore.dataset as ds
@@ -4698,7 +4826,7 @@ class ToType(TypeCast):
4698
4826
 
4699
4827
  Tutorial Examples:
4700
4828
  - `Illustration of vision transforms
4701
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4829
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4702
4830
  """
4703
4831
 
4704
4832
 
@@ -4714,14 +4842,8 @@ class TrivialAugmentWide(ImageTensorOperation):
4714
4842
  Args:
4715
4843
  num_magnitude_bins (int, optional): The number of different magnitude values,
4716
4844
  must be greater than or equal to 2. Default: ``31``.
4717
- interpolation (Inter, optional): Image interpolation method. Default: ``Inter.NEAREST``.
4718
- It can be ``Inter.NEAREST``, ``Inter.BILINEAR``, ``Inter.BICUBIC`` or ``Inter.AREA``.
4719
-
4720
- - ``Inter.NEAREST`` , nearest-neighbor interpolation.
4721
- - ``Inter.BILINEA`` , bilinear interpolation.
4722
- - ``Inter.BICUBIC`` , bicubic interpolation.
4723
- - ``Inter.AREA`` :, pixel area interpolation.
4724
-
4845
+ interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
4846
+ Default: ``Inter.NEAREST``.
4725
4847
  fill_value (Union[int, tuple[int, int, int]], optional): Pixel fill value for the area outside the
4726
4848
  transformed image, must be in range of [0, 255]. Default: ``0``.
4727
4849
  If int is provided, pad all RGB channels with this value.
@@ -4730,7 +4852,7 @@ class TrivialAugmentWide(ImageTensorOperation):
4730
4852
  Raises:
4731
4853
  TypeError: If `num_magnitude_bins` is not of type int.
4732
4854
  ValueError: If `num_magnitude_bins` is less than 2.
4733
- TypeError: If `interpolation` not of type :class:`mindspore.dataset.vision.Inter` .
4855
+ TypeError: If `interpolation` not of type :class:`~.vision.Inter` .
4734
4856
  TypeError: If `fill_value` is not of type int or tuple[int, int, int].
4735
4857
  ValueError: If `fill_value` is not in range of [0, 255].
4736
4858
  RuntimeError: If shape of the input image is not <H, W, C>.
@@ -4752,7 +4874,7 @@ class TrivialAugmentWide(ImageTensorOperation):
4752
4874
 
4753
4875
  Tutorial Examples:
4754
4876
  - `Illustration of vision transforms
4755
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4877
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4756
4878
  """
4757
4879
 
4758
4880
  @check_trivial_augment_wide
@@ -4811,7 +4933,7 @@ class UniformAugment(CompoundOperation):
4811
4933
 
4812
4934
  Tutorial Examples:
4813
4935
  - `Illustration of vision transforms
4814
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4936
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4815
4937
  """
4816
4938
 
4817
4939
  @check_uniform_augment
@@ -4858,7 +4980,7 @@ class VerticalFlip(ImageTensorOperation):
4858
4980
 
4859
4981
  Tutorial Examples:
4860
4982
  - `Illustration of vision transforms
4861
- <https://www.mindspore.cn/docs/en/r2.1/api_python/samples/dataset/vision_gallery.html>`_
4983
+ <https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
4862
4984
  """
4863
4985
 
4864
4986
  def __init__(self):