提交 d3191a08 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!175 Update parse grammar support tensor get item and set item by tensor index.

Merge pull request !175 from zhangbuxue/support_tensor_get_item_and_set_item_by_tensor_index
......@@ -103,12 +103,28 @@ The index operation includes `tuple` and` Tensor`. The following focuses on the
- Boolean constant index: index is `True`, index is `False` is not supported temporarily.
- Value: `tensor_x[True]`.
- Assignment: Not supported yet.
- Tensor index: index is `Tensor`
- Value: Not supported yet.
- Assignment: `tensor_x[index] = u`, `index` only supports `Tensor` of type` bool`.
- Value: `tensor_x [index]`, `index` must be `Tensor` of type `int32`, the element value range is `[0, tensor_x.shape[0])`.
- Assignment: `tensor_x [index] = U`.
- `tensor_x` data type must be one of the following: `float16`, `float32`, `int8`, `uint8`.
- `index` must be `Tensor` of type `int32`, the element value range is `[0, tensor_x.shape [0])`.
- `U` can be `Number`, `Tensor`, `Tuple` only containing `Number`, `Tuple` only containing `Tensor`.
- Single `Number` or every `Number` in `Tuple` must be the same type as `tensor_x`, ie
When the data type of `tensor_x` is `uint8` or `int8`, the `Number` type should be `int`;
When the data type of `tensor_x` is `float16` or `float32`, the `Number` type should be `float`.
- Single `Tensor` or every `Tensor in Tuple` must be consistent with the data type of `tensor_x`,
when single `Tensor`, the `shape` should be equal to or broadcast as `index.shape + tensor_x.shape [1:]`.
- `Tuple` containing `Number` must meet requirement:
`len (Tuple) = (index.shape + tensor_x.shape [1:]) [-1]`.
- `Tuple` containing `Tensor` must meet requirements:
the `shape` of each `Tensor` should be the same,
`(len (Tuple),) + Tensor.shape` should be equal to or broadcast as `index.shape + tensor_x.shape [1:]`.
- None constant index: index is `None`
- Value: `tensor_x[None]`, results are consistent with numpy.
- Assignment: Not supported yet.
- tuple index: index is `tuple`
- The tuple element is a slice:
- Value: for example `tensor_x[::,: 4, 3: 0: -1]`.
......@@ -126,7 +142,7 @@ In addition, tuple also supports slice value operation, `tuple_x [start: stop: s
### Unsupported Syntax
Currently, the following syntax is not supported in network constructors:
`break`, `continue`, `pass`, `raise`, `yield`, `async for`, `with`, `async with`, `assert`, `import`, and `await`.
`raise`, `yield`, `async for`, `with`, `async with`, `assert`, `import`, and `await`.
## Network Definition Constraints
......
......@@ -102,8 +102,22 @@
- 取值:`tensor_x[True]`
- 赋值:暂不支持。
- Tensor索引:index为`Tensor`
- 取值:暂不支持。
- 赋值:`tensor_x[index]=u``index`仅支持`bool`类型的`Tensor`
- 取值:`tensor_x[index]``index`必须是`int32`类型的`Tensor`,元素取值范围在`[0, tensor_x.shape[0])`
- 赋值:`tensor_x[index]=U`
- `tensor_x`的数据类型必须是下面一种: `float16``float32``int8``uint8`
- `index`必须是`int32`类型的`Tensor`,元素取值范围在`[0, tensor_x.shape[0])`
- `U`可以是`Number``Tensor`,只包含`Number``Tuple`,只包含`Tensor``Tuple`
- 单个`Number``Tuple`里的每个`Number`必须与`tensor_x`的数据类型属于同一类,即
`tensor_x`的数据类型是`uint8`或者`int8`时,`Number`类型应该是`int`
`tensor_x`的数据类型是`float16`或者`float32`时,`Number`类型应该是`float`
- 单个`Tensor``Tuple`里的每个`Tensor`必须与`tensor_x`的数据类型一致,
单个`Tensor`时,其`shape`需等于或者可广播为`index.shape + tensor_x.shape[1:]`
- 包含`Number``Tuple`需满足下面条件:
`len(Tuple) = (index.shape + tensor_x.shape[1:])[-1]`
- 包含`Tensor``Tuple`需满足下面条件:
每个`Tensor``shape`一样;
`(len(Tuple),) + Tensor.shape`等于或者可广播为`index.shape + tensor_x.shape[1:]`
- None常量索引:index为`None`
- 取值:`tensor_x[None]`,结果与numpy保持一致。
- 赋值:暂不支持。
......@@ -124,7 +138,7 @@
### 不支持的语法
目前在网络构造函数里面暂不支持以下语法:
`break``continue``pass``raise``yield``async for``with``async with``assert``import``await`
`raise``yield``async for``with``async with``assert``import``await`
## 网络定义约束
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册