dsharlet / array

C++ multidimensional arrays in the spirit of the STL
Apache License 2.0
198 stars 15 forks source link

make_compact should give dimensions constexpr strides where possible #31

Closed dsharlet closed 4 years ago

dsharlet commented 4 years ago
shape<dense_dim<0, 10>, dim<>> s({}, {0, 20});
auto compact = make_compact(s);

Currently, compact will be of the same shape type as s. However, we could produce shape<dense_dim<0, 10>, strided_dim<10>> safely instead.

This arises in practice when tiling algorithms:

for (auto yo : split<4>(output.y()) {
  for (auto xo : split<4>(output.x()) {
    auto output_tile = input(xo, yo);
    auto tile_buffer = make_array<T>(make_compact(output_tile.shape()));
  }
}

In an example like this, we'd like tile_buffer.shape().y().stride() to evaluate to a constant, rather than a runtime value.