-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRFC
54 lines (36 loc) · 1.43 KB
/
RFC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# stdtensor
## Overview
The goal of stdtensor is to provide a C++ library for tensors in STL style.
It will allow user to write program in a type safe and generic way.
## Components
### generic container data types
```cpp
template <typename R, rank_t r>
tensor<R, r>; // the data owner type
template <typename R, rank_t r>
tensor_ref<R, r>; // the reference type
template <typename R, rank_t r>
tensor_view<R, r>; // the read only reference type, like https://en.cppreference.com/w/cpp/header/string_view
```
All the 3 kinds of data types should have the following methods:
They should be as consist as https://en.cppreference.com/w/cpp/container/vector
```cpp
R* data();
const R* data();
R &at(...);
const R at();
rank_t rank();
std::array<dim_t, r> dims();
size_t size(); // the product of all dims
```
### generic algorithms for tensors
TODO
### advanced features
- allow memory to be allocated on GPU via [`thrust::device_vector`](https://github.com/thrust/thrust)
- small tensors with constexpr shape
## Potential usages
- type safe memory buffer
- the tensor counter part of [`std::vector`](https://en.cppreference.com/w/cpp/container/vector)
- the C++ port of [`np.array`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.array.html)
- build deep neural network framework (like http://github.com/lgarithm/crystalnet)
- as a wrapper interface to other linear algebra libraries, including the Blas family, Eigen, OpenCV, thrust, etc.