You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-5Lines changed: 8 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,8 +18,9 @@ where:
18
18
*`strideN` are the distances in the flat offsets between elements in each dimension.
19
19
20
20
Arrays efficiently support advanced manipulations like [cropping, slicing, and splitting](#slicing-cropping-and-splitting) arrays and loops, all while preserving compile-time constant parameters when possible.
21
-
Although it is a heavily templated library, most features do not have significant code size or compile time implications, and incorrect usage generates informative and helpful error messages.
21
+
Although it is a heavily templated library, incorrect usage generates informative and helpful error messages.
22
22
Typically, an issue will result in only one error message, located at the site of the problem in user code.
23
+
This is something [we test for](https://github.com/dsharlet/array/blob/master/test/errors.cpp#L18-L19).
23
24
24
25
Many other libraries offering multi-dimensional arrays or tensors allow compile-time constant shapes.
25
26
*However*, most if not all of them only allow either all of the shape parameters to be compile-time constant, or none of them.
@@ -293,8 +294,8 @@ We can use arbitrary functions as expression operands:
293
294
```
294
295
295
296
These operations generally produce loop nests that are as readily optimized by the compiler as hand-written loops.
296
-
For example, consider the cross product: `crosses`, `xs`, and `ys` have shape `shape<dim<0, 3>, dense_dim<>>`, so the compiler will see small constant-range loops and likely be able to optimize this to similar efficiency as hand-written code, by unrolling and evaluating the function at compile time.
297
-
The compiler will also likely be able to efficiently vectorize the `l` dimension of the `ein_reduce`, because that dimension has a constant stride 1.
297
+
In this example, `crosses`, `xs`, and `ys` have shape `shape<dim<0, 3>, dense_dim<>>`, so the compiler will see small constant loops and likely be able to optimize this to similar efficiency as hand-written code, by unrolling and evaluating the function at compile time.
298
+
The compiler also should be able to efficiently vectorize the `l` dimension of the `ein_reduce`, because that dimension has a constant stride 1.
298
299
299
300
The expression can be another kind of reduction, or not a reduction at all:
300
301
```c++
@@ -303,10 +304,10 @@ The expression can be another kind of reduction, or not a reduction at all:
303
304
ein_reduce(ein<i, j>(AT) = ein<j, i>(A));
304
305
305
306
// Maximum of each x-y plane of a 3D volume:
306
-
dense_array<float, 3> T({8, 12, 20});
307
+
dense_array<float, 3> volume({8, 12, 20});
307
308
dense_array<float, 1> max_xy({20});
308
309
auto r = ein<k>(max_xy);
309
-
ein_reduce(r = max(r, ein<i, j, k>(T)));
310
+
ein_reduce(r = max(r, ein<i, j, k>(volume)));
310
311
```
311
312
312
313
Reductions can have a mix of result and operand types:
@@ -317,7 +318,9 @@ Reductions can have a mix of result and operand types:
0 commit comments