Comments (1)
Thanks for the good suggestion. I think this deserves e.g. a README section, but I'm not sure I have a strong enough understanding of mdspan
and mdarray
at this point for that. Here's my current thinking, please correct me if you know better!
Basic multi-dimensional array storage and access
mdspan
looks like it is less flexible, and similarly easy to use, thanarray_ref
.basic_mdspan
looks more flexible, but more verbose to use, thanarray_ref
.
I think that as long as your LayoutPolicy
is an affine mapping, and isn't a trivial shape type, this library will be easier to use. But LayoutPolicy
can be anything, so basic_mdspan
is more flexible, if you need something like tiled or other non-affine shapes.
The one significant thing I've noticed: it appears that layout_strides
doesn't support compile-time constant strides, which is really critical for the stride 1 dimension at least. https://github.com/kokkos/mdspan#caveats mentions this as the first caveat. Hopefully the mdspan that becomes standard fixes this...
It's hard to compare mdarray
because a lot of the detail is missing from the proposal, and I can't find an implementation to look at (like https://github.com/kokkos/mdspan), particularly tests can be very helpful (though TBH, I haven't found as many mdspan tests as I'd like).
It looks like the current design of mdarray
is to own a "flat" container like std::vector
(the ContainerPolicy
). I started with a similar design, but found it to have some issues and ended up going with what I have now, which is array
doing its own memory management with an std::allocator
-like allocator object. To be honest, I'm struggling to remember exactly why I ended up giving up on the flat container approach. Part of it may have been what happens when shapes have padding, and there are elements in the array that are unaddressable by the shape (what these tests cover).
Higher-level algorithms
This library provides some higher level algorithms and tools that are integrated with the array types. I think the mdspan
and mdarray
proposals probably consider these things to be out of scope. Some examples are:
for_all_indices
andfor_each_index
: without these, it's hard to write rank-agnostic algorithms.split<>
: This allows splitting and tiling loops easily and "transparently".- Helpers for accessing arrays in ways that are order agnostic (
for_each_value
andcopy
), that can really significantly optimize some kinds of tasks. Some examples are covered by these performance tests. - Einstein reductions.
I think most of these could be implemented on top of mdspan
, but there are some issues. For example, I can't see how to create a subspan
with a constexpr extent, which is really a key part of tiling loops efficiently. This is why interval<>
in this library is (unfortunately necessarily) represented [begin, begin + extent)
instead of [begin, end)
.
Non-zero mins being part of the shape are also very helpful for tiling. Of course, the mins can be passed separately, but now it's not "transparent" tiling any more. But at the same time, people might prefer the numpy style slicing rather than the style this library uses (#24).
from array.
Related Issues (20)
- Automatic strides for a final dim of extent 1 is 1 instead of product of previous extents in the default and dense_array case
- whole-matrix einsum is slower than hand-written code HOT 2
- Remove copies from Einstein expression construction HOT 1
- Consider removing make_dense* functions
- auto_allocator could fall back to a base allocator when the allocation is too big
- array's move constructor default constructs an allocator before using the other allocator
- Reshape an array in runtime HOT 1
- Host doxygen generated docs somewhere HOT 1
- Template argument order issue in make_* functions that return an array
- Write a FAQ with examples of how to do common tasks HOT 1
- Need a version of generate() that takes indices HOT 3
- Numpy -> nda::array cheat sheet?
- Alias for a fixed size array allocated on the stack HOT 6
- call of overloaded βfor_each_value_in_order<(nda::shape<>::rank() - 1)>(nda::shape<>::index_type, void (&)(const int&, int&), std::pair<const int*, std::tuple<> >&, std::pair<int*, std::tuple<> >&)β is ambiguous HOT 4
- `make` broken on Apple Silicon Macs with Xcode HOT 1
- reinterpret_shape doesn't resolve bare shape HOT 3
- const_cast for array_ref<const T> HOT 8
- 3x1x3 interleaved layout returns y().stride() of 1 instead of 9 HOT 4
- errors.cpp test is failing silently on gcc
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from array.