xgboost
span.h
Go to the documentation of this file.
1 
29 #ifndef XGBOOST_SPAN_H_
30 #define XGBOOST_SPAN_H_
31 
32 #include <xgboost/base.h>
33 
34 #include <cstddef> // size_t
35 #include <cstdio>
36 #include <iterator>
37 #include <limits> // numeric_limits
38 #include <type_traits>
39 #include <utility> // for move
40 
41 #if defined(__CUDACC__)
42 #include <cuda_runtime.h>
43 #endif // defined(__CUDACC__)
44 
62 #if defined(_MSC_VER) && _MSC_VER < 1910
63 
64 #define __span_noexcept
65 
66 #pragma push_macro("constexpr")
67 #define constexpr /*constexpr*/
68 
69 #else
70 
71 #define __span_noexcept noexcept
72 
73 #endif // defined(_MSC_VER) && _MSC_VER < 1910
74 
75 namespace xgboost::common {
76 
77 #if defined(__CUDA_ARCH__)
78 // Usual logging facility is not available inside device code.
79 
80 #if defined(_MSC_VER)
81 
82 // Windows CUDA doesn't have __assert_fail.
83 #define CUDA_KERNEL_CHECK(cond) \
84  do { \
85  if (XGBOOST_EXPECT(!(cond), false)) { \
86  asm("trap;"); \
87  } \
88  } while (0)
89 
90 #else // defined(_MSC_VER)
91 
92 #define __ASSERT_STR_HELPER(x) #x
93 
94 #define CUDA_KERNEL_CHECK(cond) \
95  (XGBOOST_EXPECT((cond), true) \
96  ? static_cast<void>(0) \
97  : __assert_fail(__ASSERT_STR_HELPER((cond)), __FILE__, __LINE__, __PRETTY_FUNCTION__))
98 
99 #endif // defined(_MSC_VER)
100 
101 #define KERNEL_CHECK CUDA_KERNEL_CHECK
102 
103 #define SPAN_CHECK KERNEL_CHECK
104 
105 #else // ------------------------------ not CUDA ----------------------------
106 
107 #if defined(XGBOOST_STRICT_R_MODE) && XGBOOST_STRICT_R_MODE == 1
108 
109 #define KERNEL_CHECK(cond)
110 
111 #define SPAN_CHECK(cond) KERNEL_CHECK(cond)
112 
113 #else
114 
115 #define KERNEL_CHECK(cond) (XGBOOST_EXPECT((cond), true) ? static_cast<void>(0) : std::terminate())
116 
117 #define SPAN_CHECK(cond) KERNEL_CHECK(cond)
118 
119 #endif // defined(XGBOOST_STRICT_R_MODE)
120 
121 #endif // __CUDA_ARCH__
122 
123 #define SPAN_LT(lhs, rhs) SPAN_CHECK((lhs) < (rhs))
124 
125 namespace detail {
132 using ptrdiff_t = typename std::conditional< // NOLINT
133  std::is_same<std::ptrdiff_t, std::int64_t>::value,
134  std::ptrdiff_t, std::int64_t>::type;
135 } // namespace detail
136 
137 #if defined(_MSC_VER) && _MSC_VER < 1910
138 constexpr const std::size_t
139 dynamic_extent = std::numeric_limits<std::size_t>::max(); // NOLINT
140 #else
141 constexpr std::size_t dynamic_extent = std::numeric_limits<std::size_t>::max(); // NOLINT
142 #endif // defined(_MSC_VER) && _MSC_VER < 1910
143 
144 enum class byte : unsigned char {}; // NOLINT
145 
146 template <class ElementType, std::size_t Extent>
147 class Span;
148 
149 namespace detail {
150 
151 template <typename SpanType, bool IsConst>
153  using ElementType = typename SpanType::element_type;
154 
155  public:
156  using iterator_category = std::random_access_iterator_tag; // NOLINT
157  using value_type = typename SpanType::value_type; // NOLINT
159 
160  using reference = typename std::conditional< // NOLINT
161  IsConst, const ElementType, ElementType>::type&;
162  using pointer = typename std::add_pointer<reference>::type; // NOLINT
163 
164  constexpr SpanIterator() = default;
165 
167  const SpanType* _span,
168  typename SpanType::index_type _idx) __span_noexcept :
169  span_(_span), index_(_idx) {}
170 
172  template <bool B, typename std::enable_if<!B && IsConst>::type* = nullptr>
173  XGBOOST_DEVICE constexpr SpanIterator( // NOLINT
175  : SpanIterator(other_.span_, other_.index_) {}
176 
178  SPAN_CHECK(index_ < span_->size());
179  return *(span_->data() + index_);
180  }
182  return *(*this + n);
183  }
184 
186  SPAN_CHECK(index_ != span_->size());
187  return span_->data() + index_;
188  }
189 
191  SPAN_CHECK(index_ != span_->size());
192  index_++;
193  return *this;
194  }
195 
197  auto ret = *this;
198  ++(*this);
199  return ret;
200  }
201 
203  SPAN_CHECK(index_ != 0 && index_ <= span_->size());
204  index_--;
205  return *this;
206  }
207 
209  auto ret = *this;
210  --(*this);
211  return ret;
212  }
213 
215  auto ret = *this;
216  return ret += n;
217  }
218 
220  SPAN_CHECK((index_ + n) <= span_->size());
221  index_ += n;
222  return *this;
223  }
224 
226  SPAN_CHECK(span_ == rhs.span_);
227  return index_ - rhs.index_;
228  }
229 
231  auto ret = *this;
232  return ret -= n;
233  }
234 
236  return *this += -n;
237  }
238 
239  // friends
240  XGBOOST_DEVICE constexpr friend bool operator==(
242  return _lhs.span_ == _rhs.span_ && _lhs.index_ == _rhs.index_;
243  }
244 
245  XGBOOST_DEVICE constexpr friend bool operator!=(
247  return !(_lhs == _rhs);
248  }
249 
250  XGBOOST_DEVICE constexpr friend bool operator<(
252  return _lhs.index_ < _rhs.index_;
253  }
254 
255  XGBOOST_DEVICE constexpr friend bool operator<=(
257  return !(_rhs < _lhs);
258  }
259 
260  XGBOOST_DEVICE constexpr friend bool operator>(
262  return _rhs < _lhs;
263  }
264 
265  XGBOOST_DEVICE constexpr friend bool operator>=(
267  return !(_rhs > _lhs);
268  }
269 
270  protected:
271  const SpanType *span_ { nullptr };
272  typename SpanType::index_type index_ { 0 };
273 };
274 
275 
276 // It's tempting to use constexpr instead of structs to do the following meta
277 // programming. But remember that we are supporting MSVC 2013 here.
278 
286 template <std::size_t Extent, std::size_t Offset, std::size_t Count>
287 struct ExtentValue : public std::integral_constant<
288  std::size_t, Count != dynamic_extent ?
289  Count : (Extent != dynamic_extent ? Extent - Offset : Extent)> {};
290 
295 template <typename T, std::size_t Extent>
296 struct ExtentAsBytesValue : public std::integral_constant<
297  std::size_t,
298  Extent == dynamic_extent ?
299  Extent : sizeof(T) * Extent> {};
300 
301 template <std::size_t From, std::size_t To>
302 struct IsAllowedExtentConversion : public std::integral_constant<
303  bool, From == To || From == dynamic_extent || To == dynamic_extent> {};
304 
305 template <class From, class To>
306 struct IsAllowedElementTypeConversion : public std::integral_constant<
307  bool, std::is_convertible<From(*)[], To(*)[]>::value> {};
308 
309 template <class T>
310 struct IsSpanOracle : std::false_type {};
311 
312 template <class T, std::size_t Extent>
313 struct IsSpanOracle<Span<T, Extent>> : std::true_type {};
314 
315 template <class T>
316 struct IsSpan : public IsSpanOracle<typename std::remove_cv<T>::type> {};
317 
318 // Re-implement std algorithms here to adopt CUDA.
319 template <typename T>
320 struct Less {
321  XGBOOST_DEVICE constexpr bool operator()(const T& _x, const T& _y) const {
322  return _x < _y;
323  }
324 };
325 
326 template <typename T>
327 struct Greater {
328  XGBOOST_DEVICE constexpr bool operator()(const T& _x, const T& _y) const {
329  return _x > _y;
330  }
331 };
332 
333 template <class InputIt1, class InputIt2,
334  class Compare =
336 XGBOOST_DEVICE bool LexicographicalCompare(InputIt1 first1, InputIt1 last1,
337  InputIt2 first2, InputIt2 last2) {
338  Compare comp;
339  for (; first1 != last1 && first2 != last2; ++first1, ++first2) {
340  if (comp(*first1, *first2)) {
341  return true;
342  }
343  if (comp(*first2, *first1)) {
344  return false;
345  }
346  }
347  return first1 == last1 && first2 != last2;
348 }
349 
350 } // namespace detail
351 
352 
420 template <typename T,
421  std::size_t Extent = dynamic_extent>
422 class Span {
423  public:
424  using element_type = T; // NOLINT
425  using value_type = typename std::remove_cv<T>::type; // NOLINT
426  using index_type = std::size_t; // NOLINT
428  using pointer = T*; // NOLINT
429  using reference = T&; // NOLINT
430 
432  using const_iterator = const detail::SpanIterator<Span<T, Extent>, true>; // NOLINT
433  using reverse_iterator = std::reverse_iterator<iterator>; // NOLINT
434  using const_reverse_iterator = const std::reverse_iterator<const_iterator>; // NOLINT
435 
436  // constructors
437  constexpr Span() __span_noexcept = default;
438 
440  size_(_count), data_(_ptr) {
441  SPAN_CHECK(!(Extent != dynamic_extent && _count != Extent));
442  SPAN_CHECK(_ptr || _count == 0);
443  }
444 
446  size_(_last - _first), data_(_first) {
447  SPAN_CHECK(data_ || size_ == 0);
448  }
449 
450  template <std::size_t N>
451  XGBOOST_DEVICE constexpr Span(element_type (&arr)[N]) // NOLINT
452  __span_noexcept : size_(N), data_(&arr[0]) {}
453 
454  template <class Container,
455  class = typename std::enable_if<
456  !std::is_const<element_type>::value &&
458  std::is_convertible<typename Container::pointer, pointer>::value &&
459  std::is_convertible<typename Container::pointer,
460  decltype(std::declval<Container>().data())>::value>::type>
461  Span(Container& _cont) : // NOLINT
462  size_(_cont.size()), data_(_cont.data()) {
463  static_assert(!detail::IsSpan<Container>::value, "Wrong constructor of Span is called.");
464  }
465 
466  template <class Container,
467  class = typename std::enable_if<
468  std::is_const<element_type>::value &&
470  std::is_convertible<typename Container::pointer, pointer>::value &&
471  std::is_convertible<typename Container::pointer,
472  decltype(std::declval<Container>().data())>::value>::type>
473  Span(const Container& _cont) : size_(_cont.size()), // NOLINT
474  data_(_cont.data()) {
475  static_assert(!detail::IsSpan<Container>::value, "Wrong constructor of Span is called.");
476  }
477 
478  template <class U, std::size_t OtherExtent,
479  class = typename std::enable_if<
482  XGBOOST_DEVICE constexpr Span(const Span<U, OtherExtent>& _other) // NOLINT
483  __span_noexcept : size_(_other.size()), data_(_other.data()) {}
484 
485  XGBOOST_DEVICE constexpr Span(const Span& _other)
486  __span_noexcept : size_(_other.size()), data_(_other.data()) {}
487 
489  size_ = _other.size();
490  data_ = _other.data();
491  return *this;
492  }
493 
495 
496  XGBOOST_DEVICE constexpr iterator begin() const __span_noexcept { // NOLINT
497  return {this, 0};
498  }
499 
500  XGBOOST_DEVICE constexpr iterator end() const __span_noexcept { // NOLINT
501  return {this, size()};
502  }
503 
504  XGBOOST_DEVICE constexpr const_iterator cbegin() const __span_noexcept { // NOLINT
505  return {this, 0};
506  }
507 
508  XGBOOST_DEVICE constexpr const_iterator cend() const __span_noexcept { // NOLINT
509  return {this, size()};
510  }
511 
512  constexpr reverse_iterator rbegin() const __span_noexcept { // NOLINT
513  return reverse_iterator{end()};
514  }
515 
516  constexpr reverse_iterator rend() const __span_noexcept { // NOLINT
517  return reverse_iterator{begin()};
518  }
519 
521  return const_reverse_iterator{cend()};
522  }
523 
525  return const_reverse_iterator{cbegin()};
526  }
527 
528  // element access
529 
530  XGBOOST_DEVICE reference front() const { // NOLINT
531  return (*this)[0];
532  }
533 
534  XGBOOST_DEVICE reference back() const { // NOLINT
535  return (*this)[size() - 1];
536  }
537 
539  SPAN_LT(_idx, size());
540  return data()[_idx];
541  }
542 
544  return this->operator[](_idx);
545  }
546 
547  XGBOOST_DEVICE constexpr pointer data() const __span_noexcept { // NOLINT
548  return data_;
549  }
550 
551  // Observers
552  XGBOOST_DEVICE constexpr index_type size() const __span_noexcept { // NOLINT
553  return size_;
554  }
555  XGBOOST_DEVICE constexpr index_type size_bytes() const __span_noexcept { // NOLINT
556  return size() * sizeof(T);
557  }
558 
559  XGBOOST_DEVICE constexpr bool empty() const __span_noexcept { // NOLINT
560  return size() == 0;
561  }
562 
563  // Subviews
564  template <std::size_t Count>
566  SPAN_CHECK(Count <= size());
567  return {data(), Count};
568  }
569 
571  std::size_t _count) const {
572  SPAN_CHECK(_count <= size());
573  return {data(), _count};
574  }
575 
576  template <std::size_t Count>
578  SPAN_CHECK(Count <= size());
579  return {data() + size() - Count, Count};
580  }
581 
583  std::size_t _count) const {
584  SPAN_CHECK(_count <= size());
585  return subspan(size() - _count, _count);
586  }
587 
592  template <std::size_t Offset,
593  std::size_t Count = dynamic_extent>
594  XGBOOST_DEVICE auto subspan() const -> // NOLINT
596  detail::ExtentValue<Extent, Offset, Count>::value> {
597  SPAN_CHECK((Count == dynamic_extent) ?
598  (Offset <= size()) : (Offset + Count <= size()));
599  return {data() + Offset, Count == dynamic_extent ? size() - Offset : Count};
600  }
601 
603  index_type _offset,
604  index_type _count = dynamic_extent) const {
605  SPAN_CHECK((_count == dynamic_extent) ?
606  (_offset <= size()) : (_offset + _count <= size()));
607  return {data() + _offset, _count ==
608  dynamic_extent ? size() - _offset : _count};
609  }
610 
611  private:
612  index_type size_ { 0 };
613  pointer data_ { nullptr };
614 };
615 
616 template <class T, std::size_t X, class U, std::size_t Y>
618  if (l.size() != r.size()) {
619  return false;
620  }
621  for (auto l_beg = l.cbegin(), r_beg = r.cbegin(); l_beg != l.cend();
622  ++l_beg, ++r_beg) {
623  if (*l_beg != *r_beg) {
624  return false;
625  }
626  }
627  return true;
628 }
629 
630 template <class T, std::size_t X, class U, std::size_t Y>
632  return !(l == r);
633 }
634 
635 template <class T, std::size_t X, class U, std::size_t Y>
637  return detail::LexicographicalCompare(l.begin(), l.end(),
638  r.begin(), r.end());
639 }
640 
641 template <class T, std::size_t X, class U, std::size_t Y>
643  return !(l > r);
644 }
645 
646 template <class T, std::size_t X, class U, std::size_t Y>
649  typename Span<T, X>::iterator, typename Span<U, Y>::iterator,
651  r.begin(), r.end());
652 }
653 
654 template <class T, std::size_t X, class U, std::size_t Y>
656  return !(l < r);
657 }
658 
659 template <class T, std::size_t E>
662  return {reinterpret_cast<const byte*>(s.data()), s.size_bytes()};
663 }
664 
665 template <class T, std::size_t E>
668  return {reinterpret_cast<byte*>(s.data()), s.size_bytes()};
669 }
670 
674 template <typename It>
675 class IterSpan {
676  public:
677  using value_type = typename std::iterator_traits<It>::value_type; // NOLINT
678  using index_type = std::size_t; // NOLINT
679  using iterator = It; // NOLINT
680 
681  private:
682  It it_;
683  index_type size_{0};
684 
685  public:
686  IterSpan() = default;
687  XGBOOST_DEVICE IterSpan(It it, index_type size) : it_{std::move(it)}, size_{size} {}
689  : it_{span.data()}, size_{span.size()} {}
690 
691  [[nodiscard]] XGBOOST_DEVICE index_type size() const noexcept { return size_; } // NOLINT
692  [[nodiscard]] XGBOOST_DEVICE decltype(auto) operator[](index_type i) const { return it_[i]; }
693  [[nodiscard]] XGBOOST_DEVICE decltype(auto) operator[](index_type i) { return it_[i]; }
694  [[nodiscard]] XGBOOST_DEVICE bool empty() const noexcept { return size() == 0; } // NOLINT
695  [[nodiscard]] XGBOOST_DEVICE It data() const noexcept { return it_; } // NOLINT
696  [[nodiscard]] XGBOOST_DEVICE IterSpan<It> subspan( // NOLINT
697  index_type _offset, index_type _count = dynamic_extent) const {
698  SPAN_CHECK((_count == dynamic_extent) ? (_offset <= size()) : (_offset + _count <= size()));
699  return {data() + _offset, _count == dynamic_extent ? size() - _offset : _count};
700  }
701  [[nodiscard]] XGBOOST_DEVICE constexpr iterator begin() const noexcept { // NOLINT
702  return it_;
703  }
704  [[nodiscard]] XGBOOST_DEVICE constexpr iterator end() const noexcept { // NOLINT
705  return it_ + size();
706  }
707 };
708 } // namespace xgboost::common
709 
710 
711 #if defined(_MSC_VER) &&_MSC_VER < 1910
712 #undef constexpr
713 #pragma pop_macro("constexpr")
714 #undef __span_noexcept
715 #endif // _MSC_VER < 1910
716 
717 #endif // XGBOOST_SPAN_H_
Defines configuration macros and basic types for xgboost.
#define XGBOOST_DEVICE
Tag function as usable by device.
Definition: base.h:62
A simple custom Span type that uses general iterator instead of pointer.
Definition: span.h:675
It iterator
Definition: span.h:679
constexpr XGBOOST_DEVICE iterator begin() const noexcept
Definition: span.h:701
std::size_t index_type
Definition: span.h:678
XGBOOST_DEVICE IterSpan(common::Span< It, dynamic_extent > span)
Definition: span.h:688
constexpr XGBOOST_DEVICE iterator end() const noexcept
Definition: span.h:704
XGBOOST_DEVICE IterSpan(It it, index_type size)
Definition: span.h:687
XGBOOST_DEVICE bool empty() const noexcept
Definition: span.h:694
XGBOOST_DEVICE IterSpan< It > subspan(index_type _offset, index_type _count=dynamic_extent) const
Definition: span.h:696
XGBOOST_DEVICE index_type size() const noexcept
Definition: span.h:691
XGBOOST_DEVICE It data() const noexcept
Definition: span.h:695
typename std::iterator_traits< It >::value_type value_type
Definition: span.h:677
span class implementation, based on ISO++20 span<T>. The interface should be the same.
Definition: span.h:422
T & reference
Definition: span.h:429
XGBOOST_DEVICE Span(pointer _first, pointer _last)
Definition: span.h:445
T * pointer
Definition: span.h:428
detail::ptrdiff_t difference_type
Definition: span.h:427
XGBOOST_DEVICE reference operator()(index_type _idx) const
Definition: span.h:543
XGBOOST_DEVICE reference front() const
Definition: span.h:530
constexpr XGBOOST_DEVICE const_iterator cbegin() const __span_noexcept
Definition: span.h:504
constexpr XGBOOST_DEVICE iterator begin() const __span_noexcept
Definition: span.h:496
constexpr XGBOOST_DEVICE pointer data() const __span_noexcept
Definition: span.h:547
std::size_t index_type
Definition: span.h:426
XGBOOST_DEVICE reference back() const
Definition: span.h:534
XGBOOST_DEVICE auto subspan() const -> Span< element_type, detail::ExtentValue< Extent, Offset, Count >::value >
Definition: span.h:594
constexpr XGBOOST_DEVICE index_type size() const __span_noexcept
Definition: span.h:552
XGBOOST_DEVICE Span< element_type, Count > last() const
Definition: span.h:577
Span(Container &_cont)
Definition: span.h:461
XGBOOST_DEVICE Span< element_type, Count > first() const
Definition: span.h:565
constexpr XGBOOST_DEVICE Span(const Span &_other) __span_noexcept
Definition: span.h:485
constexpr XGBOOST_DEVICE bool empty() const __span_noexcept
Definition: span.h:559
constexpr XGBOOST_DEVICE index_type size_bytes() const __span_noexcept
Definition: span.h:555
constexpr XGBOOST_DEVICE Span(element_type(&arr)[N]) __span_noexcept
Definition: span.h:451
constexpr reverse_iterator rbegin() const __span_noexcept
Definition: span.h:512
T element_type
Definition: span.h:424
const std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: span.h:434
XGBOOST_DEVICE Span< element_type, dynamic_extent > first(std::size_t _count) const
Definition: span.h:570
constexpr XGBOOST_DEVICE const_reverse_iterator crbegin() const __span_noexcept
Definition: span.h:520
constexpr XGBOOST_DEVICE const_iterator cend() const __span_noexcept
Definition: span.h:508
XGBOOST_DEVICE ~Span() __span_noexcept
Definition: span.h:494
constexpr XGBOOST_DEVICE const_reverse_iterator crend() const __span_noexcept
Definition: span.h:524
constexpr Span() __span_noexcept=default
constexpr XGBOOST_DEVICE iterator end() const __span_noexcept
Definition: span.h:500
XGBOOST_DEVICE reference operator[](index_type _idx) const
Definition: span.h:538
constexpr reverse_iterator rend() const __span_noexcept
Definition: span.h:516
XGBOOST_DEVICE Span & operator=(const Span &_other) __span_noexcept
Definition: span.h:488
std::reverse_iterator< iterator > reverse_iterator
Definition: span.h:433
XGBOOST_DEVICE Span< element_type, dynamic_extent > subspan(index_type _offset, index_type _count=dynamic_extent) const
Definition: span.h:602
Span(const Container &_cont)
Definition: span.h:473
constexpr XGBOOST_DEVICE Span(const Span< U, OtherExtent > &_other) __span_noexcept
Definition: span.h:482
typename std::remove_cv< T >::type value_type
Definition: span.h:425
XGBOOST_DEVICE Span< element_type, dynamic_extent > last(std::size_t _count) const
Definition: span.h:582
XGBOOST_DEVICE pointer operator->() const
Definition: span.h:185
XGBOOST_DEVICE SpanIterator & operator--()
Definition: span.h:202
std::random_access_iterator_tag iterator_category
Definition: span.h:156
XGBOOST_DEVICE reference operator*() const
Definition: span.h:177
constexpr XGBOOST_DEVICE friend bool operator<(SpanIterator _lhs, SpanIterator _rhs) __span_noexcept
Definition: span.h:250
typename SpanType::value_type value_type
Definition: span.h:157
constexpr XGBOOST_DEVICE SpanIterator(const SpanType *_span, typename SpanType::index_type _idx) __span_noexcept
Definition: span.h:166
constexpr XGBOOST_DEVICE friend bool operator>(SpanIterator _lhs, SpanIterator _rhs) __span_noexcept
Definition: span.h:260
constexpr XGBOOST_DEVICE SpanIterator(const SpanIterator< SpanType, B > &other_) __span_noexcept
Definition: span.h:173
XGBOOST_DEVICE SpanIterator operator++(int)
Definition: span.h:196
constexpr XGBOOST_DEVICE friend bool operator==(SpanIterator _lhs, SpanIterator _rhs) __span_noexcept
Definition: span.h:240
XGBOOST_DEVICE SpanIterator & operator+=(difference_type n)
Definition: span.h:219
XGBOOST_DEVICE SpanIterator operator-(difference_type n) const
Definition: span.h:230
XGBOOST_DEVICE SpanIterator & operator-=(difference_type n)
Definition: span.h:235
detail::ptrdiff_t difference_type
Definition: span.h:158
typename std::conditional< IsConst, const ElementType, ElementType >::type & reference
Definition: span.h:161
XGBOOST_DEVICE reference operator[](difference_type n) const
Definition: span.h:181
typename std::add_pointer< reference >::type pointer
Definition: span.h:162
XGBOOST_DEVICE difference_type operator-(SpanIterator rhs) const
Definition: span.h:225
const SpanType * span_
Definition: span.h:271
constexpr XGBOOST_DEVICE friend bool operator>=(SpanIterator _lhs, SpanIterator _rhs) __span_noexcept
Definition: span.h:265
XGBOOST_DEVICE SpanIterator operator+(difference_type n) const
Definition: span.h:214
constexpr XGBOOST_DEVICE friend bool operator!=(SpanIterator _lhs, SpanIterator _rhs) __span_noexcept
Definition: span.h:245
constexpr XGBOOST_DEVICE friend bool operator<=(SpanIterator _lhs, SpanIterator _rhs) __span_noexcept
Definition: span.h:255
XGBOOST_DEVICE SpanIterator operator--(int)
Definition: span.h:208
SpanType::index_type index_
Definition: span.h:272
XGBOOST_DEVICE SpanIterator & operator++()
Definition: span.h:190
Definition: intrusive_ptr.h:207
XGBOOST_DEVICE bool LexicographicalCompare(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2)
Definition: span.h:336
typename std::conditional< std::is_same< std::ptrdiff_t, std::int64_t >::value, std::ptrdiff_t, std::int64_t >::type ptrdiff_t
Definition: span.h:134
Definition: span.h:75
constexpr XGBOOST_DEVICE bool operator>=(Span< T, X > l, Span< U, Y > r)
Definition: span.h:655
constexpr XGBOOST_DEVICE bool operator!=(Span< T, X > l, Span< U, Y > r)
Definition: span.h:631
constexpr std::size_t dynamic_extent
Definition: span.h:141
byte
Definition: span.h:144
XGBOOST_DEVICE auto as_writable_bytes(Span< T, E > s) __span_noexcept -> Span< byte, detail::ExtentAsBytesValue< T, E >::value >
Definition: span.h:666
XGBOOST_DEVICE bool operator==(Span< T, X > l, Span< U, Y > r)
Definition: span.h:617
XGBOOST_DEVICE auto as_bytes(Span< T, E > s) __span_noexcept -> Span< const byte, detail::ExtentAsBytesValue< T, E >::value >
Definition: span.h:660
constexpr XGBOOST_DEVICE bool operator>(Span< T, X > l, Span< U, Y > r)
Definition: span.h:647
constexpr XGBOOST_DEVICE bool operator<=(Span< T, X > l, Span< U, Y > r)
Definition: span.h:642
constexpr XGBOOST_DEVICE bool operator<(Span< T, X > l, Span< U, Y > r)
Definition: span.h:636
constexpr size_t Offset(S(&strides)[D], size_t n, Head head)
Definition: linalg.h:53
#define SPAN_LT(lhs, rhs)
Definition: span.h:123
#define __span_noexcept
span class based on ISO++20 span
Definition: span.h:71
#define SPAN_CHECK(cond)
Definition: span.h:117
Definition: span.h:327
constexpr XGBOOST_DEVICE bool operator()(const T &_x, const T &_y) const
Definition: span.h:328
Definition: span.h:316
Definition: span.h:320
constexpr XGBOOST_DEVICE bool operator()(const T &_x, const T &_y) const
Definition: span.h:321