mindspore/docs/api/api_python/ops/mindspore.ops.Gather.rst

33 lines
1.3 KiB
ReStructuredText
Raw Normal View History

2021-12-07 12:17:56 +08:00
mindspore.ops.Gather
======================
2021-12-21 18:09:08 +08:00
.. py:class:: mindspore.ops.Gather()
2021-12-07 12:17:56 +08:00
返回输入Tensor在指定 `axis``input_indices` 索引对应的元素组成的切片。
下图展示了Gather常用的计算过程
2022-01-25 16:00:34 +08:00
.. image:: Gather.png
2022-01-25 16:41:47 +08:00
其中params代表输入 `input_params` indices代表要切片的索引 `input_indices`
.. note::
2022-01-29 09:45:45 +08:00
1.input_indices的值必须在 `[0, input_param.shape[axis])` 范围内,超出该范围结果未定义。
2022-04-08 09:41:47 +08:00
2.Ascend平台上input_params的数据类型当前不能是 `bool_ <https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore.html#mindspore.dtype>`_
2021-12-07 12:17:56 +08:00
**输入:**
- **input_params** (Tensor) - 原始Tensorshape为 :math:`(x_1, x_2, ..., x_R)`
2021-12-21 18:09:08 +08:00
- **input_indices** (Tensor) - 要切片的索引Tensorshape为 :math:`(y_1, y_2, ..., y_S)` 。指定原始Tensor中要切片的索引。数据类型必须是int32或int64。
2021-12-07 12:17:56 +08:00
- **axis** (int) - 指定要切片的维度索引。
**输出:**
Tensorshape为 :math:`input\_params.shape[:axis] + input\_indices.shape + input\_params.shape[axis + 1:]`
**异常:**
- **TypeError** - `axis` 不是int。
- **TypeError** - `input_params` 不是Tensor。
2021-12-21 18:09:08 +08:00
- **TypeError** - `input_indices` 不是int类型的Tensor。