Tensor< T > Struct Template Reference#
Public Types |
Public Member Functions |
Public Attributes |
Static Public Attributes |
List of all members
Tensor< T > 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 <host_tensor.hpp>
Public Types | |
using | Descriptor = HostTensorDescriptor |
using | Data = std::vector< T > |
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 | |
template<typename X > | |
Tensor (std::initializer_list< X > lens) | |
template<typename X , typename Y > | |
Tensor (std::initializer_list< X > lens, std::initializer_list< Y > strides) | |
template<typename Lengths > | |
Tensor (const Lengths &lens) | |
template<typename Lengths , typename Strides > | |
Tensor (const Lengths &lens, const Strides &strides) | |
Tensor (const Descriptor &desc) | |
template<typename OutT > | |
Tensor< OutT > | CopyAsType () const |
Tensor ()=delete | |
Tensor (const Tensor &)=default | |
Tensor (Tensor &&)=default | |
~Tensor ()=default | |
Tensor & | operator= (const Tensor &)=default |
Tensor & | operator= (Tensor &&)=default |
template<typename FromT > | |
Tensor (const Tensor< FromT > &other) | |
decltype(auto) | GetLengths () const |
decltype(auto) | GetStrides () const |
std::size_t | GetNumOfDimension () const |
std::size_t | GetElementSize () const |
std::size_t | GetElementSpaceSize () const |
std::size_t | GetElementSpaceSizeInBytes () const |
void | SetZero () |
template<typename F > | |
void | ForEach_impl (F &&f, std::vector< size_t > &idx, size_t rank) |
template<typename F > | |
void | ForEach (F &&f) |
template<typename F > | |
void | ForEach_impl (const F &&f, std::vector< size_t > &idx, size_t rank) const |
template<typename F > | |
void | ForEach (const F &&f) const |
template<typename G > | |
void | GenerateTensorValue (G g, std::size_t num_thread=1) |
template<typename... Is> | |
std::size_t | GetOffsetFromMultiIndex (Is... is) const |
template<typename... Is> | |
T & | operator() (Is... is) |
template<typename... Is> | |
const T & | operator() (Is... is) const |
T & | operator() (std::vector< std::size_t > idx) |
const T & | operator() (std::vector< std::size_t > idx) const |
Data::iterator | begin () |
Data::iterator | end () |
Data::pointer | data () |
Data::const_iterator | begin () const |
Data::const_iterator | end () const |
Data::const_pointer | data () const |
Data::size_type | size () const |
template<typename U = T> | |
auto | AsSpan () const |
template<typename U = T> | |
auto | AsSpan () |
__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... | |
Public Attributes | |
Descriptor | mDesc |
Data | mData |
Static Public Attributes | |
static constexpr MemoryTypeEnum | TensorBufferAddressSpace = BufferAddressSpace |
static constexpr bool | IsDynamicBuffer |
Detailed Description
template<typename T>
struct Tensor< T >
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
◆ Data
◆ Descriptor
template<typename T >
using Tensor< T >::Descriptor = HostTensorDescriptor |
◆ ElementSpaceSize
template<typename T >
using Tensor< T >::ElementSpaceSize = decltype(Layout<Shape, UnrolledDescriptorType>{ Shape{}, UnrolledDescriptorType{}}.GetElementSpaceSize()) |
◆ TensorElementType
template<typename T >
using Tensor< T >::TensorElementType = std::conditional_t< is_scalar_type<ElementType>::value, ElementType, typename scalar_type<std::remove_const_t<ElementType> >::type> |
Constructor & Destructor Documentation
◆ Tensor() [1/12]
template<typename T >
template<typename X >
|
inline |
◆ Tensor() [2/12]
template<typename T >
template<typename X , typename Y >
|
inline |
◆ Tensor() [3/12]
template<typename T >
template<typename Lengths >
|
inline |
◆ Tensor() [4/12]
template<typename T >
template<typename Lengths , typename Strides >
|
inline |
◆ Tensor() [5/12]
template<typename T >
|
inline |
◆ Tensor() [6/12]
◆ Tensor() [7/12]
◆ Tensor() [8/12]
◆ ~Tensor()
◆ Tensor() [9/12]
template<typename T >
template<typename FromT >
|
inlineexplicit |
◆ Tensor() [10/12]
◆ Tensor() [11/12]
template<typename T >
|
inlineconstexpr |
◆ Tensor() [12/12]
template<typename T >
|
inlineconstexpr |
Member Function Documentation
◆ AsSpan() [1/2]
◆ AsSpan() [2/2]
◆ begin() [1/2]
template<typename T >
|
inline |
◆ begin() [2/2]
template<typename T >
|
inline |
◆ CopyAsType()
template<typename T >
template<typename OutT >
|
inline |
◆ data() [1/2]
template<typename T >
|
inline |
◆ data() [2/2]
template<typename T >
|
inline |
◆ end() [1/2]
template<typename T >
|
inline |
◆ end() [2/2]
template<typename T >
|
inline |
◆ ForEach() [1/2]
◆ ForEach() [2/2]
◆ ForEach_impl() [1/2]
template<typename T >
template<typename F >
|
inline |
◆ ForEach_impl() [2/2]
template<typename T >
template<typename F >
|
inline |
◆ GenerateTensorValue()
template<typename T >
template<typename G >
|
inline |
◆ GetBuffer() [1/2]
template<typename T >
|
inlineconstexpr |
◆ GetBuffer() [2/2]
template<typename T >
|
inlineconstexpr |
◆ GetElementSize()
template<typename T >
|
inline |
◆ GetElementSpaceSize()
template<typename T >
|
inline |
◆ GetElementSpaceSizeInBytes()
template<typename T >
|
inline |
◆ GetLayout()
template<typename T >
|
inlineconstexpr |
◆ GetLengths()
template<typename T >
|
inline |
◆ GetMergedNestingDescriptor()
template<typename T >
|
inlineconstexpr |
Get descriptor with all nested dimensions merged.
- Returns
- Merged nests descriptor.
◆ GetMultiIdxOffsets()
template<typename T >
|
inlineconstexpr |
Get multi index offset to the data.
- Returns
- Multi index offset.
◆ GetNumOfDimension()
template<typename T >
|
inline |
◆ GetOffsetFromMultiIndex()
template<typename T >
template<typename... Is>
|
inline |
◆ GetPointer()
template<typename T >
|
inline |
Get pointer to the data.
- Returns
- Pointer.
◆ GetStrides()
template<typename T >
|
inline |
◆ operator()() [1/10]
template<typename T >
template<typename... Ts, enable_if_t< detail::HasSlice(Tuple< Ts... >{}), bool > = false>
|
inline |
◆ operator()() [2/10]
template<typename T >
template<typename... Ts, enable_if_t<!detail::HasSlice(Tuple< Ts... >{}), bool > = false>
|
inline |
◆ operator()() [3/10]
template<typename T >
template<typename... Ts, enable_if_t<!detail::HasSlice(Tuple< Ts... >{}), bool > = false>
|
inline |
◆ operator()() [4/10]
template<typename T >
template<typename... Idxs, enable_if_t< detail::HasSlice(Tuple< Idxs... >{}), bool > = false>
|
inline |
◆ operator()() [5/10]
template<typename T >
template<typename... Idxs, enable_if_t<!detail::HasSlice(Tuple< Idxs... >{}), bool > = false>
|
inline |
◆ operator()() [6/10]
template<typename T >
template<typename... Idxs, enable_if_t<!detail::HasSlice(Tuple< Idxs... >{}), bool > = false>
|
inline |
◆ operator()() [7/10]
◆ operator()() [8/10]
template<typename T >
template<typename... Is>
|
inline |
◆ operator()() [9/10]
template<typename T >
|
inline |
◆ operator()() [10/10]
template<typename T >
|
inline |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ operator[]() [1/3]
template<typename T >
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<typename T >
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<typename T >
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<typename T >
template<typename MultiIdxOffsets >
|
inlineconstexpr |
Apply multi index offset on the tensor.
- Parameters
-
multi_idx_offset Multi index offset.
◆ SetZero()
template<typename T >
|
inline |
◆ size()
template<typename T >
|
inline |
Member Data Documentation
◆ IsDynamicBuffer
template<typename T >
|
staticconstexpr |
Initial value:
= !(BufferAddressSpace == MemoryTypeEnum ::Sgpr ||
BufferAddressSpace == MemoryTypeEnum ::Vgpr)
◆ mData
◆ mDesc
template<typename T >
Descriptor Tensor< T >::mDesc |
◆ TensorBufferAddressSpace
template<typename T >
|
staticconstexpr |
The documentation for this struct was generated from the following files:
- /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/docs-6.4.3/include/ck/library/utility/host_tensor.hpp
- /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/docs-6.4.3/include/ck/wrapper/tensor.hpp