Giter Club home page Giter Club logo

Comments (1)

dsharlet avatar dsharlet commented on June 26, 2024

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, than array_ref.
  • basic_mdspan looks more flexible, but more verbose to use, than array_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:

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.