45 class Array<T, N, false> {
49 "Array<> specialized for sub-byte types assume the actual stored element size is 1 byte");
55 ((kSizeBits % 32) != 0),
57 ((kSizeBits % 16) != 0),
71 static size_t const kStorageElements = N / kElementsPerStoredItem;
74 static size_t const kElements = N;
117 *ptr_ =
Storage(((*ptr_ & kUpdateMask) | (item << idx_ * sizeof_bits<T>::value)));
125 return reinterpret_cast<T
const &
>(item);
136 explicit operator int()
const {
142 explicit operator float()
const {
148 class const_reference {
167 const T
get()
const {
169 return reinterpret_cast<T
const &
>(item);
176 return reinterpret_cast<T
const &
>(item);
181 explicit operator int()
const {
187 explicit operator float()
const {
216 if (idx_ == kElementsPerStoredItem) {
227 idx_ = kElementsPerStoredItem - 1;
239 if (idx_ == kElementsPerStoredItem) {
251 idx_ = kElementsPerStoredItem - 1;
261 return reference(ptr_, idx_);
266 return ptr_ == other.ptr_ && idx_ == other.idx_;
271 return !(*
this == other);
276 class const_iterator {
295 if (idx_ == kElementsPerStoredItem) {
306 idx_ = kElementsPerStoredItem - 1;
318 if (idx_ == kElementsPerStoredItem) {
330 idx_ = kElementsPerStoredItem - 1;
340 return const_reference(ptr_, idx_);
345 return ptr_ == other.ptr_ && idx_ == other.idx_;
350 return !(*
this == other);
355 class reverse_iterator {
375 class const_reverse_iterator {
397 Storage storage[kStorageElements];
407 for (
int i = 0; i < int(kStorageElements); ++i) {
408 storage[i] = x.storage[i];
417 for (
int i = 0; i < int(kStorageElements); ++i) {
424 return reference(storage + pos / kElementsPerStoredItem, pos % kElementsPerStoredItem);
429 return const_reference(storage + pos / kElementsPerStoredItem, pos % kElementsPerStoredItem);
454 return reference(storage + kStorageElements - 1, kElementsPerStoredItem - 1);
459 return const_reference(storage + kStorageElements - 1, kElementsPerStoredItem - 1);
464 return reinterpret_cast<pointer>(storage);
505 return iterator(storage);
510 return const_iterator(storage);
515 return iterator(storage + kStorageElements);
520 return const_iterator(storage + kStorageElements);
525 return reverse_iterator(storage + kStorageElements);
530 return const_reverse_iterator(storage + kStorageElements);
535 return reverse_iterator(storage);
539 const_reverse_iterator
crend()
const {
540 return const_reverse_iterator(storage);
CUTLASS_HOST_DEVICE const_reference(Storage const *ptr, int idx=0)
Ctor.
Definition: array_subbyte.h:164
CUTLASS_HOST_DEVICE const_reference at(size_type pos) const
Definition: array_subbyte.h:428
CUTLASS_HOST_DEVICE const_reference back() const
Definition: array_subbyte.h:458
Definition: aligned_buffer.h:35
CUTLASS_HOST_DEVICE reverse_iterator()
Definition: array_subbyte.h:366
CUTLASS_HOST_DEVICE iterator operator--(int)
Definition: array_subbyte.h:326
CUTLASS_HOST_DEVICE Array(Array const &x)
Definition: array_subbyte.h:405
CUTLASS_HOST_DEVICE reference operator[](size_type pos)
Definition: array_subbyte.h:433
CUTLASS_HOST_DEVICE const_reverse_iterator crend() const
Definition: array_subbyte.h:539
CUTLASS_HOST_DEVICE reverse_iterator rbegin()
Definition: array_subbyte.h:524
CUTLASS_HOST_DEVICE bool operator==(iterator const &other) const
Definition: array_subbyte.h:265
size_t size_type
Definition: array_subbyte.h:84
CUTLASS_HOST_DEVICE iterator & operator++()
Definition: array_subbyte.h:214
CUTLASS_HOST_DEVICE const_reverse_iterator crbegin() const
Definition: array_subbyte.h:529
CUTLASS_HOST_DEVICE reverse_iterator rend()
Definition: array_subbyte.h:534
CUTLASS_HOST_DEVICE constexpr bool empty() const
Definition: array_subbyte.h:484
CUTLASS_HOST_DEVICE const_iterator(Storage const *ptr, int idx=0)
Definition: array_subbyte.h:290
ptrdiff_t difference_type
Definition: array_subbyte.h:85
CUTLASS_HOST_DEVICE const_pointer data() const
Definition: array_subbyte.h:468
CUTLASS_HOST_DEVICE reference operator*() const
Definition: array_subbyte.h:260
CUTLASS_HOST_DEVICE reference()
Default ctor.
Definition: array_subbyte.h:105
CUTLASS_HOST_DEVICE const_iterator cend() const
Definition: array_subbyte.h:519
CUTLASS_HOST_DEVICE reference(Storage *ptr, int idx=0)
Ctor.
Definition: array_subbyte.h:109
Statically sized array of elements that accommodates all CUTLASS-supported numeric types and is safe ...
#define CUTLASS_PRAGMA_UNROLL
Definition: cutlass.h:110
CUTLASS_HOST_DEVICE Storage * raw_data()
Definition: array_subbyte.h:473
CUTLASS_HOST_DEVICE const_reference()
Default ctor.
Definition: array_subbyte.h:160
CUTLASS_HOST_DEVICE reference back()
Definition: array_subbyte.h:453
CUTLASS_HOST_DEVICE iterator begin()
Definition: array_subbyte.h:504
Defines the size of an element in bits.
Definition: numeric_types.h:42
CUTLASS_HOST_DEVICE void fill(T const &value)
Definition: array_subbyte.h:499
CUTLASS_HOST_DEVICE iterator & operator--()
Definition: array_subbyte.h:303
CUTLASS_HOST_DEVICE Array()
Definition: array_subbyte.h:402
T Element
Element type.
Definition: array_subbyte.h:65
CUTLASS_HOST_DEVICE const_reference operator*() const
Definition: array_subbyte.h:339
CUTLASS_HOST_DEVICE iterator operator--(int)
Definition: array_subbyte.h:247
CUTLASS_HOST_DEVICE reference & operator=(T x)
Assignment.
Definition: array_subbyte.h:113
CUTLASS_HOST_DEVICE iterator end()
Definition: array_subbyte.h:514
CUTLASS_HOST_DEVICE reverse_iterator(Storage *ptr, int idx=0)
Definition: array_subbyte.h:369
CUTLASS_HOST_DEVICE pointer data()
Definition: array_subbyte.h:463
#define CUTLASS_HOST_DEVICE
Definition: cutlass.h:89
CUTLASS_HOST_DEVICE reference front()
Definition: array_subbyte.h:443
CUTLASS_HOST_DEVICE const_reverse_iterator(Storage const *ptr, int idx=0)
Definition: array_subbyte.h:389
CUTLASS_HOST_DEVICE const_iterator cbegin() const
Definition: array_subbyte.h:509
CUTLASS_HOST_DEVICE const_iterator()
Definition: array_subbyte.h:287
CUTLASS_HOST_DEVICE reference at(size_type pos)
Definition: array_subbyte.h:423
CUTLASS_HOST_DEVICE const_reverse_iterator()
Definition: array_subbyte.h:386
CUTLASS_HOST_DEVICE iterator operator++(int)
Definition: array_subbyte.h:315
CUTLASS_HOST_DEVICE Storage const * raw_data() const
Definition: array_subbyte.h:478
value_type const * const_pointer
Definition: array_subbyte.h:87
CUTLASS_HOST_DEVICE constexpr size_type size() const
Definition: array_subbyte.h:489
CUTLASS_HOST_DEVICE constexpr size_type max_size() const
Definition: array_subbyte.h:494
CUTLASS_HOST_DEVICE void clear()
Efficient clear method.
Definition: array_subbyte.h:414
CUTLASS_HOST_DEVICE const_reference front() const
Definition: array_subbyte.h:448
CUTLASS_HOST_DEVICE iterator()
Definition: array_subbyte.h:208
CUTLASS_HOST_DEVICE iterator(Storage *ptr, int idx=0)
Definition: array_subbyte.h:211
typename platform::conditional< ((kSizeBits%32)!=0), typename platform::conditional< ((kSizeBits%16)!=0), uint8_t, uint16_t >::type, uint32_t >::type Storage
Storage type.
Definition: array_subbyte.h:62
CUTLASS_HOST_DEVICE iterator operator++(int)
Definition: array_subbyte.h:236
CUTLASS_HOST_DEVICE iterator & operator--()
Definition: array_subbyte.h:224
CUTLASS_HOST_DEVICE bool operator!=(iterator const &other) const
Definition: array_subbyte.h:349
CUTLASS_HOST_DEVICE bool operator!=(iterator const &other) const
Definition: array_subbyte.h:270
T value_type
Definition: array_subbyte.h:83
value_type * pointer
Definition: array_subbyte.h:86
CUTLASS_HOST_DEVICE bool operator==(iterator const &other) const
Definition: array_subbyte.h:344
CUTLASS_HOST_DEVICE iterator & operator++()
Definition: array_subbyte.h:293
Basic include for CUTLASS.
CUTLASS_HOST_DEVICE const_reference operator[](size_type pos) const
Definition: array_subbyte.h:438