Tensor< BufferAddressSpace, ElementType, Shape, UnrolledDescriptorType > Struct Template Reference#
Tensor< BufferAddressSpace, ElementType, Shape, UnrolledDescriptorType > Struct Template Reference
Tensor wrapper that performs static and dynamic buffer logic. The tensor is based on a descriptor stored in the Layout. Additionally, tensor can be sliced or shifted using multi-index offset. More...
#include <tensor.hpp>
Public Types | |
| using | ElementSpaceSize = decltype(Layout< Shape, UnrolledDescriptorType >{ Shape{}, UnrolledDescriptorType{}}.GetElementSpaceSize()) |
| using | TensorElementType = std::conditional_t< is_scalar_type< ElementType >::value, ElementType, typename scalar_type< std::remove_const_t< ElementType > >::type > |
Public Member Functions | |
| __host__ __device__ | Tensor ()=delete |
| __host__ constexpr __device__ | Tensor (ElementType *pointer, const Layout< Shape, UnrolledDescriptorType > &layout) |
| __host__ constexpr __device__ | Tensor (const Layout< Shape, UnrolledDescriptorType > &layout) |
| __host__ constexpr __device__ const Layout< Shape, UnrolledDescriptorType > & | GetLayout () const |
| template<typename... Ts, enable_if_t< detail::HasSlice(Tuple< Ts... >{}), bool > = false> | |
| __host__ __device__ auto | operator[] (const Tuple< Ts... > &idx) |
| Get the new sliced tensor. More... | |
| template<typename... Ts, enable_if_t< detail::HasSlice(Tuple< Ts... >{}), bool > = false> | |
| __host__ __device__ auto | operator() (const Tuple< Ts... > &idx) |
| template<typename... Idxs, enable_if_t< detail::HasSlice(Tuple< Idxs... >{}), bool > = false> | |
| __host__ __device__ auto | operator() (Idxs... idxs) |
| template<typename... Ts, enable_if_t<!detail::HasSlice(Tuple< Ts... >{}), bool > = false> | |
| __host__ __device__ const TensorElementType & | operator[] (const Tuple< Ts... > &idx) const |
| Getter of the tensor's const value reference. More... | |
| template<typename... Ts, enable_if_t<!detail::HasSlice(Tuple< Ts... >{}), bool > = false> | |
| __host__ __device__ const TensorElementType & | operator() (const Tuple< Ts... > &idx) const |
| template<typename... Idxs, enable_if_t<!detail::HasSlice(Tuple< Idxs... >{}), bool > = false> | |
| __host__ __device__ const TensorElementType & | operator() (Idxs... idxs) const |
| template<typename... Ts, enable_if_t<!detail::HasSlice(Tuple< Ts... >{}), bool > = false> | |
| __host__ __device__ TensorElementType & | operator[] (const Tuple< Ts... > &idx) |
| Getter of tensor value reference. More... | |
| template<typename... Ts, enable_if_t<!detail::HasSlice(Tuple< Ts... >{}), bool > = false> | |
| __host__ __device__ TensorElementType & | operator() (const Tuple< Ts... > &idx) |
| template<typename... Idxs, enable_if_t<!detail::HasSlice(Tuple< Idxs... >{}), bool > = false> | |
| __host__ __device__ TensorElementType & | operator() (Idxs... idxs) |
| __host__ constexpr __device__ auto | GetMergedNestingDescriptor () |
| Get descriptor with all nested dimensions merged. More... | |
| __host__ __device__ TensorElementType * | GetPointer () const |
| Get pointer to the data. More... | |
| __host__ constexpr __device__ auto & | GetBuffer () |
| __host__ constexpr __device__ auto & | GetBuffer () const |
| __host__ constexpr __device__ auto & | GetMultiIdxOffsets () const |
| Get multi index offset to the data. More... | |
| template<typename MultiIdxOffsets > | |
| __host__ constexpr __device__ void | SetMultiIdxOffset (const MultiIdxOffsets multi_idx_offset) |
| Apply multi index offset on the tensor. More... | |
Static Public Attributes | |
| static constexpr MemoryTypeEnum | TensorBufferAddressSpace = BufferAddressSpace |
| static constexpr bool | IsDynamicBuffer |
Detailed Description
template<MemoryTypeEnum BufferAddressSpace, typename ElementType, typename Shape, typename UnrolledDescriptorType>
struct Tensor< BufferAddressSpace, ElementType, Shape, UnrolledDescriptorType >
Tensor wrapper that performs static and dynamic buffer logic. The tensor is based on a descriptor stored in the Layout. Additionally, tensor can be sliced or shifted using multi-index offset.
- Template Parameters
-
BufferAddressSpace Memory type (Generic, Global, LDS, VGPR, SGPR). ElementType Element data type. Shape Tensor shape (layout component). UnrolledDescriptorType Flatten descriptor (layout component).
Member Typedef Documentation
◆ ElementSpaceSize
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
| using Tensor< BufferAddressSpace, ElementType, Shape, UnrolledDescriptorType >::ElementSpaceSize = decltype(Layout<Shape, UnrolledDescriptorType>{ Shape{}, UnrolledDescriptorType{}}.GetElementSpaceSize()) |
◆ TensorElementType
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
| using Tensor< BufferAddressSpace, ElementType, Shape, UnrolledDescriptorType >::TensorElementType = std::conditional_t< is_scalar_type<ElementType>::value, ElementType, typename scalar_type<std::remove_const_t<ElementType> >::type> |
Constructor & Destructor Documentation
◆ Tensor() [1/3]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
|
delete |
◆ Tensor() [2/3]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
|
inlineconstexpr |
◆ Tensor() [3/3]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
|
inlineconstexpr |
Member Function Documentation
◆ GetBuffer() [1/2]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
|
inlineconstexpr |
◆ GetBuffer() [2/2]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
|
inlineconstexpr |
◆ GetLayout()
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
|
inlineconstexpr |
◆ GetMergedNestingDescriptor()
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
|
inlineconstexpr |
Get descriptor with all nested dimensions merged.
- Returns
- Merged nests descriptor.
◆ GetMultiIdxOffsets()
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
|
inlineconstexpr |
Get multi index offset to the data.
- Returns
- Multi index offset.
◆ GetPointer()
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
|
inline |
Get pointer to the data.
- Returns
- Pointer.
◆ operator()() [1/6]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
template<typename... Ts, enable_if_t< detail::HasSlice(Tuple< Ts... >{}), bool > = false>
|
inline |
◆ operator()() [2/6]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
template<typename... Ts, enable_if_t<!detail::HasSlice(Tuple< Ts... >{}), bool > = false>
|
inline |
◆ operator()() [3/6]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
template<typename... Ts, enable_if_t<!detail::HasSlice(Tuple< Ts... >{}), bool > = false>
|
inline |
◆ operator()() [4/6]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
template<typename... Idxs, enable_if_t< detail::HasSlice(Tuple< Idxs... >{}), bool > = false>
|
inline |
◆ operator()() [5/6]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
template<typename... Idxs, enable_if_t<!detail::HasSlice(Tuple< Idxs... >{}), bool > = false>
|
inline |
◆ operator()() [6/6]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
template<typename... Idxs, enable_if_t<!detail::HasSlice(Tuple< Idxs... >{}), bool > = false>
|
inline |
◆ operator[]() [1/3]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
template<typename... Ts, enable_if_t< detail::HasSlice(Tuple< Ts... >{}), bool > = false>
|
inline |
Get the new sliced tensor.
- Parameters
-
idx Tuple of indices: slice(from,to) or scalar.
- Returns
- Sliced tensor.
◆ operator[]() [2/3]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
template<typename... Ts, enable_if_t<!detail::HasSlice(Tuple< Ts... >{}), bool > = false>
|
inline |
Getter of tensor value reference.
- Parameters
-
idx Tuple of indices.
- Returns
- Requested value.
◆ operator[]() [3/3]
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
template<typename... Ts, enable_if_t<!detail::HasSlice(Tuple< Ts... >{}), bool > = false>
|
inline |
Getter of the tensor's const value reference.
- Parameters
-
idx Tuple of indices.
- Returns
- Requested value.
◆ SetMultiIdxOffset()
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
template<typename MultiIdxOffsets >
|
inlineconstexpr |
Apply multi index offset on the tensor.
- Parameters
-
multi_idx_offset Multi index offset.
Member Data Documentation
◆ IsDynamicBuffer
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
|
staticconstexpr |
Initial value:
= !(BufferAddressSpace == MemoryTypeEnum ::Sgpr ||
BufferAddressSpace == MemoryTypeEnum ::Vgpr)
◆ TensorBufferAddressSpace
template<MemoryTypeEnum BufferAddressSpace, typename ElementType , typename Shape , typename UnrolledDescriptorType >
|
staticconstexpr |
The documentation for this struct was generated from the following file:
- /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/wrapper/tensor.hpp