123 typename MapFunc_ = IdentityTensorMapFunc<Rank_>,
125 int StorageRank_ = MapFunc_::kStorageRank,
127 typename Index_ = int,
129 typename LongIndex_ =
long long 256 stride_[i] = ref.stride(i);
291 return ptr_ !=
nullptr;
316 return stride_.
at(dim);
326 return coord_map_(coord);
332 return stride().template dot<LongIndex>(
map(coord));
338 return ptr_[
offset(coord)];
348 return ptr_[
offset(coord)];
412 class TensorRef<Storage_, Rank_, MapFunc_, 1, Index_, LongIndex_> {
541 return ptr_ !=
nullptr;
570 return coord_map_(coord);
576 return stride().template dot<LongIndex>(
map(coord));
582 return ptr_[
offset(coord)];
592 return ptr_[
offset(coord)];
Coord< kStorageRank > StorageCoord
Coordinate in storage n-D array.
Definition: tensor_ref.h:436
CUTLASS_HOST_DEVICE Storage & operator[](LongIndex idx) const
Returns a reference to the element at a given linear index.
Definition: tensor_ref.h:353
CUTLASS_HOST_DEVICE TensorRef(TensorRef< typename platform::remove_const< Storage >::type, kRank, MapFunc, kStorageRank, Index, LongIndex > const &ref)
Enables conversion from TensorRef of non-const type.
Definition: tensor_ref.h:501
TensorCoord Coord_t
Coordinate in logical tensor space.
Definition: tensor_ref.h:173
CUTLASS_HOST_DEVICE TensorRef & add_pointer_offset(LongIndex delta)
Adds an offset to each pointer.
Definition: tensor_ref.h:601
CUTLASS_HOST_DEVICE Storage * data() const
Returns the pointer to referenced data.
Definition: tensor_ref.h:296
CUTLASS_HOST_DEVICE void reset(Storage *ptr, StorageCoord const &stride)
Updates the pointer, stride, and location within a TensorRef.
Definition: tensor_ref.h:527
CUTLASS_HOST_DEVICE Storage & at(TensorCoord const &coord) const
Returns a reference to the element at a given Coord.
Definition: tensor_ref.h:581
CUTLASS_HOST_DEVICE TensorRef(Storage *ptr=nullptr)
Helper for 1-D memory. All higher ranks are projected onto the fastest changing rank.
Definition: tensor_ref.h:477
static int const kRank
Logical rank of tensor index space.
Definition: tensor_ref.h:137
A Coord is a coordinate of arbitrary rank into a tensor or matrix.
CUTLASS_HOST_DEVICE void reset(Storage *ptr, StorageCoord const &stride)
Updates the pointer, stride, and location within a TensorRef.
Definition: tensor_ref.h:274
CUTLASS_HOST_DEVICE Storage * data() const
Returns the pointer to referenced data.
Definition: tensor_ref.h:546
CUTLASS_HOST_DEVICE void reset(Storage *ptr=nullptr)
Updates only the pointer.
Definition: tensor_ref.h:268
CUTLASS_HOST_DEVICE Storage & operator[](LongIndex idx) const
Returns a reference to the element at a given linear index.
Definition: tensor_ref.h:597
CUTLASS_HOST_DEVICE TensorRef(TensorRef< typename platform::remove_const< Storage >::type, kRank, MapFunc, kStorageRank, Index, LongIndex > const &ref)
Enables conversion from TensorRef of non-const type.
Definition: tensor_ref.h:245
CUTLASS_HOST_DEVICE TensorRef operator+(TensorCoord const &b) const
Returns a TensorRef offset by a given amount.
Definition: tensor_ref.h:364
MapFunc_ MapFunc
Mapping function from logical coordinate to internal n-D array.
Definition: tensor_ref.h:140
Storage_ Storage
Data type of individual access.
Definition: tensor_ref.h:134
CUTLASS_HOST_DEVICE Index stride(int dim) const
Returns the stride of the tensor in the given dimension.
Definition: tensor_ref.h:311
CUTLASS_HOST_DEVICE Index stride(int dim) const
Returns the stride of the tensor in the given dimension.
Definition: tensor_ref.h:558
CUTLASS_HOST_DEVICE TensorRef(Storage *ptr, StrideVector const &stride)
Constructs from a single pointer and stride vector.
Definition: tensor_ref.h:481
CUTLASS_HOST_DEVICE TensorRef & operator-=(TensorCoord const &b)
Returns a TensorRef offset by a given amount.
Definition: tensor_ref.h:631
CUTLASS_HOST_DEVICE StorageCoord stride() const
Returns the stride of the tensor.
Definition: tensor_ref.h:300
CUTLASS_HOST_DEVICE TensorRef & add_pointer_offset(LongIndex delta)
Adds an offset to each pointer.
Definition: tensor_ref.h:357
CUTLASS_HOST_DEVICE void reset(Storage *ptr=nullptr)
Updates only the pointer.
Definition: tensor_ref.h:521
Index_ Index
Index type.
Definition: tensor_ref.h:146
CUTLASS_HOST_DEVICE Storage & operator[](TensorCoord const &coord) const
Returns a reference to the element at a given Coord.
Definition: tensor_ref.h:347
TensorRef< typename platform::remove_const< Storage >::type const, Rank_, MapFunc_, kStorageRank, Index_, LongIndex_ > ConstTensorRef
Tensor reference to of constant value.
Definition: tensor_ref.h:449
CUTLASS_HOST_DEVICE Storage & at(LongIndex idx) const
Returns a reference to the element at a given linear index.
Definition: tensor_ref.h:587
CUTLASS_HOST_DEVICE TensorRef operator-(TensorCoord const &b) const
Returns a TensorRef offset by a given amount.
Definition: tensor_ref.h:623
CUTLASS_HOST_DEVICE TensorRef(Storage *ptr, Index ldm)
Helper to construct from a pointer and single stride element for 2-D pitch linear memory...
Definition: tensor_ref.h:213
CUTLASS_HOST_DEVICE StorageCoord map(TensorCoord const &coord) const
Maps a logical coordinate to an n-D array in memory.
Definition: tensor_ref.h:325
CUTLASS_HOST_DEVICE Storage & at(LongIndex idx) const
Returns a reference to the element at a given linear index.
Definition: tensor_ref.h:343
LongIndex_ LongIndex
Typically, strides in memory can be very large.
Definition: tensor_ref.h:149
Coord< kStorageRank > StorageCoord
Coordinate in storage n-D array.
Definition: tensor_ref.h:155
Storage_ Storage
Data type of individual access.
Definition: tensor_ref.h:415
CUTLASS_HOST_DEVICE TensorRef operator+(TensorCoord const &b) const
Returns a TensorRef offset by a given amount.
Definition: tensor_ref.h:608
CUTLASS_HOST_DEVICE TensorRef(Storage *ptr=nullptr)
Helper for 1-D memory. All higher ranks are projected onto the fastest changing rank.
Definition: tensor_ref.h:204
CUTLASS_HOST_DEVICE TensorRef & operator+=(TensorCoord const &b)
Returns a TensorRef offset by a given amount.
Definition: tensor_ref.h:372
TensorRef< typename platform::remove_const< Storage >::type const, Rank_, MapFunc_, StorageRank_, Index_, LongIndex_ > ConstTensorRef
Tensor reference to of constant value.
Definition: tensor_ref.h:168
Definition: tensor_ref.h:131
CUTLASS_HOST_DEVICE StorageCoord stride() const
Returns the stride of the tensor.
Definition: tensor_ref.h:550
Coord< kRank > TensorCoord
Coordinate in logical tensor space.
Definition: tensor_ref.h:152
static int const kStorageRank
Rank of internal storage.
Definition: tensor_ref.h:143
static int const Rank
Logical rank of tensor index space.
Definition: tensor_ref.h:183
TensorCoord Coord_t
Coordinate in logical tensor space.
Definition: tensor_ref.h:456
CUTLASS_HOST_DEVICE TensorRef(Storage *ptr, StorageCoord const &stride)
Definition: tensor_ref.h:488
#define CUTLASS_HOST_DEVICE
Definition: cutlass.h:46
CUTLASS_HOST_DEVICE bool good() const
Returns true if the TensorRef may be safely accessed.
Definition: tensor_ref.h:540
CUTLASS_HOST_DEVICE Index leading_dim(int idx=0) const
Returns the maximum stride element as the 'leading dimension'.
Definition: tensor_ref.h:565
CUTLASS_HOST_DEVICE Index & at()
Gets the index of a given Coord element.
Definition: coord.h:240
CUTLASS_HOST_DEVICE Storage & operator[](TensorCoord const &coord) const
Returns a reference to the element at a given Coord.
Definition: tensor_ref.h:591
CUTLASS_HOST_DEVICE TensorRef & operator+=(TensorCoord const &b)
Returns a TensorRef offset by a given amount.
Definition: tensor_ref.h:616
CUTLASS_HOST_DEVICE LongIndex offset(TensorCoord const &coord) const
Computes the offset of an index from the origin of the tensor.
Definition: tensor_ref.h:331
CUTLASS_HOST_DEVICE Coord< Rank > operator()(Coord< Rank > const &coord) const
Definition: tensor_ref.h:44
LongIndex_ LongIndex
Typically, strides in memory can be very large.
Definition: tensor_ref.h:430
Statically-sized array specifying Coords within a tensor.
Definition: coord.h:49
Defines a 1D vector of elements held in the registers of each thread.
CUTLASS_HOST_DEVICE LongIndex offset(TensorCoord const &coord) const
Computes the offset of an index from the origin of the tensor.
Definition: tensor_ref.h:575
CUTLASS_HOST_DEVICE Storage & at(TensorCoord const &coord) const
Returns a reference to the element at a given Coord.
Definition: tensor_ref.h:337
CUTLASS_HOST_DEVICE ConstTensorRef const_ref() const
Returns a reference to constant-valued tensor.
Definition: tensor_ref.h:515
Index_ Index
Index type.
Definition: tensor_ref.h:427
static int const kStorageRank
Definition: tensor_ref.h:42
CUTLASS_HOST_DEVICE ConstTensorRef const_ref() const
Returns a reference to constant-valued tensor.
Definition: tensor_ref.h:262
CUTLASS_HOST_DEVICE StorageCoord map(TensorCoord const &coord) const
Maps a logical coordinate to an n-D array in memory.
Definition: tensor_ref.h:569
CUTLASS_HOST_DEVICE TensorRef(Storage *ptr, StorageCoord const &stride)
Definition: tensor_ref.h:229
MapFunc_ MapFunc
Mapping function from logical coordinate to internal n-D array.
Definition: tensor_ref.h:421
CUTLASS_HOST_DEVICE TensorRef(Storage *ptr, StrideVector const &stride)
Constructs from a single pointer and stride vector.
Definition: tensor_ref.h:222
Coord< kStorageRank - 1 > StrideVector
Definition: tensor_ref.h:159
Coord< kRank > TensorCoord
Coordinate in logical tensor space.
Definition: tensor_ref.h:433
Basic include for CUTLASS macros.
CUTLASS_HOST_DEVICE TensorRef operator-(TensorCoord const &b) const
Returns a TensorRef offset by a given amount.
Definition: tensor_ref.h:379
CUTLASS_HOST_DEVICE bool good() const
Returns true if the TensorRef may be safely accessed.
Definition: tensor_ref.h:290
Definition: tensor_ref.h:41
CUTLASS_HOST_DEVICE Index leading_dim(int idx=0) const
Returns the maximum stride element as the 'leading dimension'.
Definition: tensor_ref.h:321
CUTLASS_HOST_DEVICE TensorRef & operator-=(TensorCoord const &b)
Returns a TensorRef offset by a given amount.
Definition: tensor_ref.h:387