57 typename Storage_ = uint8_t
68 "Size of Element must not be greater than Storage.");
71 "Storage must be divisible by Element");
108 int64_t offset_in_vectors = offset / kElementsPerVector;
109 int64_t offset_in_elements = offset % kElementsPerVector;
111 ptr_ += offset_in_vectors;
112 offset_ = int(offset_in_elements);
137 return reinterpret_cast<Element const &
>(item);
152 int offset_in_vectors = offset / kElementsPerVector;
153 int offset_in_elements = offset % kElementsPerVector;
155 ptr_ += offset_in_vectors;
156 offset_ = offset_in_elements;
167 long long offset_in_vectors = offset / kElementsPerVector;
168 int offset_in_elements = int(offset % kElementsPerVector);
170 ptr_ += offset_in_vectors;
171 offset_ = offset_in_elements;
180 int offset_in_vectors = offset / kElementsPerVector;
181 int offset_in_elements = offset % kElementsPerVector;
183 ptr_ -= offset_in_vectors;
184 offset_ -= offset_in_elements;
187 offset_ += kElementsPerVector;
198 long long offset_in_vectors = offset / kElementsPerVector;
199 int offset_in_elements = int(offset % kElementsPerVector);
201 ptr_ -= offset_in_vectors;
202 offset_ -= offset_in_elements;
205 offset_ += kElementsPerVector;
255 return (ptr_ - ref.ptr_) * kElementsPerVector + (offset_ - ref.offset_);
260 explicit operator int()
const {
266 explicit operator int64_t()
const {
267 return int64_t(
get());
272 explicit operator uint64_t()
const {
273 return uint64_t(
get());
278 explicit operator float()
const {
284 explicit operator double()
const {
285 return double(
get());
291 typename Storage_ = uint8_t
302 "Size of Element must not be greater than Storage.");
305 "Storage must be divisible by Element");
342 int64_t offset_in_vectors = offset / kElementsPerVector;
343 int64_t offset_in_elements = offset % kElementsPerVector;
345 ptr_ += offset_in_vectors;
346 offset_ = int(offset_in_elements);
371 return reinterpret_cast<Element const &
>(item);
381 *ptr_ =
Storage((*ptr_ & kUpdateMask) |
Storage(item << (offset_ * sizeof_bits<Element>::value)));
417 int offset_in_vectors = offset / kElementsPerVector;
418 int offset_in_elements = offset % kElementsPerVector;
420 ptr_ += offset_in_vectors;
421 offset_ = offset_in_elements;
432 long long offset_in_vectors = offset / kElementsPerVector;
433 int offset_in_elements = int(offset % kElementsPerVector);
435 ptr_ += offset_in_vectors;
436 offset_ = offset_in_elements;
445 int offset_in_vectors = offset / kElementsPerVector;
446 int offset_in_elements = offset % kElementsPerVector;
448 ptr_ -= offset_in_vectors;
449 offset_ -= offset_in_elements;
452 offset_ += kElementsPerVector;
463 long long offset_in_vectors = offset / kElementsPerVector;
464 int offset_in_elements = int(offset % kElementsPerVector);
466 ptr_ -= offset_in_vectors;
467 offset_ -= offset_in_elements;
470 offset_ += kElementsPerVector;
520 return (ptr_ - ref.ptr_) * kElementsPerVector + (offset_ - ref.offset_);
525 explicit operator int()
const {
531 explicit operator int64_t()
const {
532 return int64_t(
get());
537 explicit operator uint64_t()
const {
538 return uint64_t(
get());
543 explicit operator float()
const {
549 explicit operator double()
const {
550 return double(
get());
556 template <typename Element, bool subbyte = (sizeof_bits<Element>::value < 8)>
559 template <
typename Element>
572 template <
typename Element>
Definition: subbyte_reference.h:60
Definition: aligned_buffer.h:35
CUTLASS_HOST_DEVICE int element_offset() const
Gets element offset within storage vector.
Definition: subbyte_reference.h:363
CUTLASS_HOST_DEVICE SubbyteReference & operator=(Element const &x)
Stores an element to memory.
Definition: subbyte_reference.h:394
CUTLASS_HOST_DEVICE SubbyteReference()
Definition: subbyte_reference.h:331
CUTLASS_HOST_DEVICE SubbyteReference operator-=(long long offset) const
Returns a reference to an element with a given offset from the current reference. ...
Definition: subbyte_reference.h:509
CUTLASS_HOST_DEVICE SubbyteReference(Element *ptr, int64_t offset)
Constructor.
Definition: subbyte_reference.h:335
CUTLASS_HOST_DEVICE SubbyteReference operator+(int offset) const
Returns a reference to an element with a given offset from the current reference. ...
Definition: subbyte_reference.h:479
CUTLASS_HOST_DEVICE ConstSubbyteReference operator-=(long long offset) const
Returns a reference to an element with a given offset from the current reference. ...
Definition: subbyte_reference.h:244
Storage_ Storage
Definition: subbyte_reference.h:64
CUTLASS_HOST_DEVICE ConstSubbyteReference & operator+=(long long offset)
Adds an offset in units of elements to the reference.
Definition: subbyte_reference.h:163
CUTLASS_HOST_DEVICE SubbyteReference operator+(long long offset) const
Returns a reference to an element with a given offset from the current reference. ...
Definition: subbyte_reference.h:489
CUTLASS_HOST_DEVICE ptrdiff_t operator-(ConstSubbyteReference ref) const
Computes the difference in elements between references.
Definition: subbyte_reference.h:254
CUTLASS_HOST_DEVICE ConstSubbyteReference & operator+=(int offset)
Adds an offset in units of elements to the reference.
Definition: subbyte_reference.h:148
CUTLASS_HOST_DEVICE SubbyteReference & operator-=(long long offset)
Adds an offset in units of elements to the reference.
Definition: subbyte_reference.h:461
Defines the size of an element in bits.
Definition: numeric_types.h:42
CUTLASS_HOST_DEVICE Element get() const
Unpacks an element from memory.
Definition: subbyte_reference.h:135
Element_ Element
Definition: subbyte_reference.h:297
Definition: subbyte_reference.h:557
CUTLASS_HOST_DEVICE StoragePointer storage_pointer() const
Gets storage pointer.
Definition: subbyte_reference.h:123
CUTLASS_HOST_DEVICE SubbyteReference & operator+=(long long offset)
Adds an offset in units of elements to the reference.
Definition: subbyte_reference.h:428
#define CUTLASS_HOST_DEVICE
Definition: cutlass.h:89
Top-level include for all CUTLASS numeric types.
CUTLASS_HOST_DEVICE StoragePointer storage_pointer() const
Gets storage pointer.
Definition: subbyte_reference.h:357
CUTLASS_HOST_DEVICE ConstSubbyteReference(Element const *ptr, int64_t offset)
Constructor.
Definition: subbyte_reference.h:101
CUTLASS_HOST_DEVICE ConstSubbyteReference operator+(int offset) const
Returns a reference to an element with a given offset from the current reference. ...
Definition: subbyte_reference.h:214
CUTLASS_HOST_DEVICE ConstSubbyteReference & operator-=(int offset)
Adds an offset in units of elements to the reference.
Definition: subbyte_reference.h:178
CUTLASS_HOST_DEVICE ConstSubbyteReference()
Definition: subbyte_reference.h:97
CUTLASS_HOST_DEVICE ConstSubbyteReference operator+(long long offset) const
Returns a reference to an element with a given offset from the current reference. ...
Definition: subbyte_reference.h:224
CUTLASS_HOST_DEVICE SubbyteReference & operator=(SubbyteReference const &x)
Stores an element to memory.
Definition: subbyte_reference.h:400
Storage_ Storage
Definition: subbyte_reference.h:298
CUTLASS_HOST_DEVICE ConstSubbyteReference(Element *ptr=nullptr)
Constructor.
Definition: subbyte_reference.h:117
Definition: subbyte_reference.h:294
CUTLASS_HOST_DEVICE int element_offset() const
Gets element offset within storage vector.
Definition: subbyte_reference.h:129
CUTLASS_HOST_DEVICE Element get() const
Unpacks an element from memory.
Definition: subbyte_reference.h:369
CUTLASS_HOST_DEVICE SubbyteReference & operator=(ConstSubbyteReference< Element, Storage > const &x)
Stores an element to memory.
Definition: subbyte_reference.h:406
Storage * StoragePointer
Definition: subbyte_reference.h:299
Storage const * StoragePointer
Definition: subbyte_reference.h:65
CUTLASS_HOST_DEVICE SubbyteReference(Element *ptr=nullptr)
Constructor.
Definition: subbyte_reference.h:351
CUTLASS_HOST_DEVICE SubbyteReference & operator-=(int offset)
Adds an offset in units of elements to the reference.
Definition: subbyte_reference.h:443
Element_ Element
Definition: subbyte_reference.h:63
CUTLASS_HOST_DEVICE ConstSubbyteReference & operator-=(long long offset)
Adds an offset in units of elements to the reference.
Definition: subbyte_reference.h:196
CUTLASS_HOST_DEVICE SubbyteReference operator-(int offset) const
Returns a reference to an element with a given offset from the current reference. ...
Definition: subbyte_reference.h:499
CUTLASS_HOST_DEVICE ConstSubbyteReference operator-(int offset) const
Returns a reference to an element with a given offset from the current reference. ...
Definition: subbyte_reference.h:234
CUTLASS_HOST_DEVICE ptrdiff_t operator-(SubbyteReference ref) const
Computes the difference in elements between references.
Definition: subbyte_reference.h:519
CUTLASS_HOST_DEVICE SubbyteReference & operator+=(int offset)
Adds an offset in units of elements to the reference.
Definition: subbyte_reference.h:413