diff --git a/docs/source_en/constraints_on_network_construction.md b/docs/source_en/constraints_on_network_construction.md index 486e3e0eeda6f9219f52f690591f719a30da9475..c50480af806c604a5402613c6d7113092c9431f4 100644 --- a/docs/source_en/constraints_on_network_construction.md +++ b/docs/source_en/constraints_on_network_construction.md @@ -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 diff --git a/docs/source_zh_cn/constraints_on_network_construction.md b/docs/source_zh_cn/constraints_on_network_construction.md index 5ba6c2f87dd2c7d976af9b01dcfdd2c0e9c35605..7d270dd3563c3b690407c3f85b5c5901529f6a6f 100644 --- a/docs/source_zh_cn/constraints_on_network_construction.md +++ b/docs/source_zh_cn/constraints_on_network_construction.md @@ -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`。 ## 网络定义约束