GenericTensor 2.0
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 20/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- csharp
- 领域
- data, performance
调研方向
首先,盘点 issue 中描述的当前大型接口、通用张量类型、稀疏变换以及现有入口点。在解决尚未确定的维度问题之前,比较提议的特定操作接口、dense Tensor 和 TensorView API、加速选项、命名变更以及 ConvolutedMap 操作。完成意味着设计已经确定,并且兼容的 API 方案已经实现,而不是完成一次孤立的单独修改。
由索引模型根据 Issue 内容生成。
描述
GenericTensor 2.0: plan
Alright, time for improvement
1 action - 1 interface
Currently we have a large interface which forces the user to implement all its methods. It's not as good as it was thought to be:
- You may want not to implement a method, but you can't guess whether some GT's function uses it or not
- The interface is not extendable - adding a new method immediately breaks backward comaptibility
Instead, we will have one method in each interface (there will be multiple interfaces - like IAddAction<A, B, C> etc.).
Now we will be able to constrain each function separately, and the tensor itself won't be constrained (the type will have only one type argument - T). It makes all things much more convenient, and it also allows for more advanced API - for example, adding tensors would look like:
Tensor<C> AddElementwise<A, B, C, TAdd>(Tensor<A> a, Tensor<B> b) where TAdd : IAdd<A, B, C>
Non-generic entry point class API
Currently we need to type the typename with its arguments. Instead, there will be a non-generic static class to handle those things: thanks to type inference, we will type less.
No sparse transformation
Currently, there are some transformations, like transposition and slicing, which makes the tensor "sparse" - that is, instead of rewriting elements themselves, they rewrite the meanings of indices. That means, that going over a just created 2D tensor by width and height would be much faster than if we transpose that tensor beforehand.
In new API such a feature will remain in some different more explicit form, for example, TensorView<T>. It behaves similarly to BCL's Span<T>, which is basically a view on some piece of memory. Likewise, TensorView just allows to read/write to a tensor, but is not a tensor itself. Might be useful for some operations, where the user doesn't want to think about the order of axes or size of a tensor. Though not all API will be available for TensorView<T>.
But tensors itself will be strictly linear/dense. Slicing and transposition will produce a new dense tensor.
Hardware acceleration
Now, with dense tensors we can use three types of acceleration:
- Multithreading
- SIMD (HonkPerf.NET.GenericSIMD)
- GPU
Though the third one is questioned, the first two are definitely doable and will require new methods with type constrained to unmanaged. As simple as that.
New project name - GenericTensor.NET. New type name - Tensor.
Alright, this one is questionable. Should we rename to a more "modern" name? It would mean a new "slot" in nuget packages, and hence, not visible by current users (if there are any aside from AngouriMath, hehe).
New operations
We could implement convoluted map for it. Example of convoluted map:
Imagine matrix A
1 2 3
4 5 6
7 8 9
and then code:
B = A.ConvolutedMap(width: 2, height: 2, step: 1, view: TensorView -> view[0, 0] + view[0, 1] + view[1, 0] + view[1, 1]);
then B is
12 16
24 28
This way we can basically process, reshape, "bend", collapse or add axes anyhow we need. Upscale for instance:
A =
1 2 3
4 5 6
7 8 9
B = A.ConvolutedMap(
inputWidth: 2,
inputHeight: 2,
step: 2,
outputWidth: 3,
outputHeight: 3,
(source: TensorView, destination: TensorView) ->
destination[0, 0] = source[0, 0]
destination[0, 2] = source[0, 1]
destination[2, 0] = source[1, 0]
destination[2, 2] = source[1, 1]
destination[0, 1] = (destination[0, 0] + destination[0, 2]) / 2
destination[1, 0] = (destination[0, 0] + destination[2, 1]) / 2
etc...
)
Note, that we don't limit to 2d convolution here, though not sure where we could ever need 4D+ convolutions.
Unresolved questions
Should there be single type Tensor or by dimension - Tensor1D, Tensor2D, etc.? If the latter, should there be TensorND or just cover a fixed number of dimensions?
- 主要语言
- C#
- 星标
- 52
- 派生
- 6
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ASC-Community/GenericTensor 的其他 Issue
-
Determinant and Inverse return wrong values when called from more than one thread可能已有人在做 @Rafael-SOWNet 于 30 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
-
good first issue
难度 4/5 3-5 天 新手友好度 25/100
-
proposal
难度 4/5 3-5 天 新手友好度 35/100
ASC-Community/GenericTensor#36 · 1 条评论 ·
-
Opinions wanted proposal
难度 5/5 一周以上 新手友好度 25/100
ASC-Community/GenericTensor#31 · 2 条评论 ·
-
Will this package support MKL or OpenBlas as backend to accelerate matrix inverse computing speed未关闭
难度 5/5 一周以上 新手友好度 25/100
ASC-Community/GenericTensor#30 · 1 条评论 ·
查看 ASC-Community/GenericTensor 的全部 Issue
相似的 Issue
-
type/automation type/tech-debt
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
has-image has-readme needs-attention new-tool repo-verified
难度 1/5 1-3 小时 新手友好度 62/100
shanselman/TinyToolTown#844 · 2 条评论 ·
维护者通常 3 天内回复
-
StoreImmediately test is flaky and fails on Linux and macOS可能已有人在做 @jcannon98188 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
-
area:frontend FE P3
难度 2/5 1-3 小时 新手友好度 74/100
klasolsson81/jobbliggaren#2067 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
grame-cncm/faust#1344 · 1 条评论 ·
维护者通常 1 天内回复