25 #ifndef TVM_SUPPORT_SPAN_H_ 26 #define TVM_SUPPORT_SPAN_H_ 30 #include <type_traits> 41 template <
class T,
class W>
45 using const_W = typename ::std::add_const<W>::type;
48 class iterator_base :
public std::iterator<std::input_iterator_tag, W> {
55 if (ptr_ != end_) ptr_++;
60 return ptr_ == other.ptr_ && end_ == other.end_;
65 template <class X = W1, typename = ::std::enable_if_t<!::std::is_const<X>::value> >
89 ICHECK_LT(to_return, end_) <<
"Span access out of bounds: " << i;
93 inline operator std::vector<W>() {
return std::vector<W>(
begin(),
end()); }
103 #endif // TVM_SUPPORT_SPAN_H_ bool operator==(iterator_base< W1 > other)
Definition: span.h:59
iterator_base(T *ptr, T *end)
Definition: span.h:50
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
Span(T *begin, int num_elements)
Definition: span.h:78
iterator end() const
Definition: span.h:83
Span(T *begin, T *end)
Definition: span.h:79
W operator[](int i)
Definition: span.h:87
iterator begin() const
Definition: span.h:81
iterator_base< W1 > & operator++()
Definition: span.h:54
iterator_base< W > iterator
Definition: span.h:75
typename ::std::add_const< W >::type const_W
Definition: span.h:45
W1 operator*()
Definition: span.h:52
A partial implementation of the C++20 std::span.
Definition: span.h:42
bool operator!=(iterator_base< W1 > other)
Definition: span.h:63
size_t size() const
Definition: span.h:85
T * begin_
Definition: span.h:96
T * end_
Definition: span.h:97
W value_type
Definition: span.h:44