py:tensor __getitem__ 已支持 #74
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
getitem
让我帮你分析
__getitem__当前支持的索引能力,以便你提交 PR 说明文档:Tensor.getitem 索引能力支持
1. 基础索引类型
整数索引:
tensor[0]Tensor索引:
tensor[index_tensor]indexselect实现2. 切片操作
tensor[:]slice(None, None, None)slice(start, stop, step)3. 维度操作
None插入新维度:
tensor[None]或tensor[:, None]unsqueeze实现省略号:
tensor[..., 0]...(Ellipsis)4. 组合索引
支持上述索引类型的任意组合:
5. 实现细节
dim_cursor追踪当前处理的维度6. 底层算子支持
indexselect: 处理张量索引sliceselect: 处理切片操作unsqueeze: 处理维度扩展squeeze: 处理维度压缩7. 限制
建议在后续版本中添加这些功能支持。