TAPPorg / tensor-interfaces

A place to store information for the tensor discussions and possible specifications.
14 stars 6 forks source link

Aligned ISO/C++ standardization proposal #5

Open hcedwar opened 6 years ago

hcedwar commented 6 years ago

There is an ISO/C++ standard proposal in progress which is well-aligned with this effort. https://github.com/ORNL/cpp-proposals-pub/tree/master/P0009

devinamatthews commented 6 years ago

Thanks for the link, looks like a huge step forward for C++ tensor interfaces. One question: I couldn't find the justification for the wording in the table in mdspan.layout.reqs: "Returns: one plus the maximum value of m(i...)." which goes along with "Requires: 0 <= m(i...)" just above.

1) This seems to require positive strides in all cases. 2) Even then, it also tacitly assumes that m(i...) == 0 for some i....

evaleev commented 6 years ago

@devinamatthews my reading is that layout maps index pack (or multi-index) to the (scalar) position/address in the underlying (1-d) span. No assumption is made about the mapping method, it does not need to be stride-based at all (e.g. addressing a lower triangle of a matrix). There is no need to assume that all element in span are in the domain of layout, some may not be addressable. So I do not see where m(i...) == 0 is assumed.

devinamatthews commented 6 years ago

The phrasing for m.required_span_size() that I quoted above is the problem. If this is to be the exact number of elements in the required span then the m(i...) == 0 assumption kicks in. I suppose it could be taken as an upper bound, though. If one had a strided layout with negative strides then m(i...) < 0 would be possible and the required_span_size() calculation would be too small.

My preferred wording for that concept is something like "The difference between the maximum and minimum values of m(i...), plus one."

evaleev commented 6 years ago

I suppose it could be taken as an upper bound, though.

that's how I read it.

My preferred wording for that concept is something like "The difference between the maximum and minimum values of m(i...), plus one."

This is intended for checking that the domain of layout is valid for the given span (i.e. every multi-index maps to inside the span) ... only the maximum value of m(i...) is needed. What you are propose is best described by e.g. domain_size()