Tensor< T > Struct Template Reference

Tensor&lt; T &gt; Struct Template Reference#

Composable Kernel: ck::Tensor< T > Struct Template Reference
ck::Tensor< T > Struct Template Reference

#include <host_tensor.hpp>

Public Types

using Descriptor = HostTensorDescriptor
 
using Data = std::vector< T >
 

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)
 
template<typename X , typename... Rest, std::enable_if_t<(sizeof...(Rest) > 0), int > = 0>
 Tensor (std::initializer_list< X > lens, Rest &&... rest)
 
template<typename X , typename Y , typename... Rest, std::enable_if_t<(sizeof...(Rest) > 0), int > = 0>
 Tensor (std::initializer_list< X > lens, std::initializer_list< Y > strides, Rest &&... rest)
 
template<typename Lengths , typename... Rest, std::enable_if_t<(sizeof...(Rest) > 0), int > = 0>
 Tensor (const Lengths &lens, Rest &&... rest)
 
template<typename Lengths , typename Strides , typename... Rest, std::enable_if_t<(sizeof...(Rest) > 0), int > = 0>
 Tensor (const Lengths &lens, const Strides &strides, Rest &&... rest)
 
 Tensor (const Descriptor &desc)
 
template<typename OutT >
Tensor< OutT > CopyAsType () const
 
 Tensor ()=delete
 
 Tensor (const Tensor &)=default
 
 Tensor (Tensor &&)=default
 
 ~Tensor ()=default
 
Tensoroperator= (const Tensor &)=default
 
Tensoroperator= (Tensor &&)=default
 
template<typename FromT >
 Tensor (const Tensor< FromT > &other)
 
void savetxt (std::string file_name, std::string dtype="float")
 
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 Distribution = std::uniform_real_distribution<float>, typename Mapping = ck::identity, typename Generator = std::minstd_rand>
void GenerateTensorDistr (Distribution dis={0.f, 1.f}, Mapping fn={}, const Generator g=Generator(0), 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() (const std::vector< std::size_t > &idx)
 
const T & operator() (const 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 ()
 

Public Attributes

Descriptor mDesc
 
Data mData
 

Member Typedef Documentation

◆ Data

template<typename T >
using ck::Tensor< T >::Data = std::vector<T>

◆ Descriptor

template<typename T >
using ck::Tensor< T >::Descriptor = HostTensorDescriptor

Constructor & Destructor Documentation

◆ Tensor() [1/13]

template<typename T >
template<typename X >
ck::Tensor< T >::Tensor ( std::initializer_list< X >  lens)
inline

◆ Tensor() [2/13]

template<typename T >
template<typename X , typename Y >
ck::Tensor< T >::Tensor ( std::initializer_list< X >  lens,
std::initializer_list< Y >  strides 
)
inline

◆ Tensor() [3/13]

template<typename T >
template<typename Lengths >
ck::Tensor< T >::Tensor ( const Lengths &  lens)
inline

◆ Tensor() [4/13]

template<typename T >
template<typename Lengths , typename Strides >
ck::Tensor< T >::Tensor ( const Lengths &  lens,
const Strides &  strides 
)
inline

◆ Tensor() [5/13]

template<typename T >
template<typename X , typename... Rest, std::enable_if_t<(sizeof...(Rest) > 0), int > = 0>
ck::Tensor< T >::Tensor ( std::initializer_list< X >  lens,
Rest &&...  rest 
)
inline

◆ Tensor() [6/13]

template<typename T >
template<typename X , typename Y , typename... Rest, std::enable_if_t<(sizeof...(Rest) > 0), int > = 0>
ck::Tensor< T >::Tensor ( std::initializer_list< X >  lens,
std::initializer_list< Y >  strides,
Rest &&...  rest 
)
inline

◆ Tensor() [7/13]

template<typename T >
template<typename Lengths , typename... Rest, std::enable_if_t<(sizeof...(Rest) > 0), int > = 0>
ck::Tensor< T >::Tensor ( const Lengths &  lens,
Rest &&...  rest 
)
inline

◆ Tensor() [8/13]

template<typename T >
template<typename Lengths , typename Strides , typename... Rest, std::enable_if_t<(sizeof...(Rest) > 0), int > = 0>
ck::Tensor< T >::Tensor ( const Lengths &  lens,
const Strides &  strides,
Rest &&...  rest 
)
inline

◆ Tensor() [9/13]

template<typename T >
ck::Tensor< T >::Tensor ( const Descriptor desc)
inline

◆ Tensor() [10/13]

template<typename T >
ck::Tensor< T >::Tensor ( )
delete

◆ Tensor() [11/13]

template<typename T >
ck::Tensor< T >::Tensor ( const Tensor< T > &  )
default

◆ Tensor() [12/13]

template<typename T >
ck::Tensor< T >::Tensor ( Tensor< T > &&  )
default

◆ ~Tensor()

template<typename T >
ck::Tensor< T >::~Tensor ( )
default

◆ Tensor() [13/13]

template<typename T >
template<typename FromT >
ck::Tensor< T >::Tensor ( const Tensor< FromT > &  other)
inlineexplicit

Member Function Documentation

◆ AsSpan() [1/2]

template<typename T >
template<typename U = T>
auto ck::Tensor< T >::AsSpan ( )
inline

◆ AsSpan() [2/2]

template<typename T >
template<typename U = T>
auto ck::Tensor< T >::AsSpan ( ) const
inline

◆ begin() [1/2]

template<typename T >
Data::iterator ck::Tensor< T >::begin ( )
inline

◆ begin() [2/2]

template<typename T >
Data::const_iterator ck::Tensor< T >::begin ( ) const
inline

◆ CopyAsType()

template<typename T >
template<typename OutT >
Tensor<OutT> ck::Tensor< T >::CopyAsType ( ) const
inline

◆ data() [1/2]

template<typename T >
Data::pointer ck::Tensor< T >::data ( )
inline

◆ data() [2/2]

template<typename T >
Data::const_pointer ck::Tensor< T >::data ( ) const
inline

◆ end() [1/2]

template<typename T >
Data::iterator ck::Tensor< T >::end ( )
inline

◆ end() [2/2]

template<typename T >
Data::const_iterator ck::Tensor< T >::end ( ) const
inline

◆ ForEach() [1/2]

template<typename T >
template<typename F >
void ck::Tensor< T >::ForEach ( const F &&  f) const
inline

◆ ForEach() [2/2]

template<typename T >
template<typename F >
void ck::Tensor< T >::ForEach ( F &&  f)
inline

◆ ForEach_impl() [1/2]

template<typename T >
template<typename F >
void ck::Tensor< T >::ForEach_impl ( const F &&  f,
std::vector< size_t > &  idx,
size_t  rank 
) const
inline

◆ ForEach_impl() [2/2]

template<typename T >
template<typename F >
void ck::Tensor< T >::ForEach_impl ( F &&  f,
std::vector< size_t > &  idx,
size_t  rank 
)
inline

◆ GenerateTensorDistr()

template<typename T >
template<typename Distribution = std::uniform_real_distribution<float>, typename Mapping = ck::identity, typename Generator = std::minstd_rand>
void ck::Tensor< T >::GenerateTensorDistr ( Distribution  dis = {0.f, 1.f},
Mapping  fn = {},
const Generator  g = Generator(0),
std::size_t  num_thread = -1 
)
inline

◆ GenerateTensorValue()

template<typename T >
template<typename G >
void ck::Tensor< T >::GenerateTensorValue ( g,
std::size_t  num_thread = 1 
)
inline

◆ GetElementSize()

template<typename T >
std::size_t ck::Tensor< T >::GetElementSize ( ) const
inline

◆ GetElementSpaceSize()

template<typename T >
std::size_t ck::Tensor< T >::GetElementSpaceSize ( ) const
inline

◆ GetElementSpaceSizeInBytes()

template<typename T >
std::size_t ck::Tensor< T >::GetElementSpaceSizeInBytes ( ) const
inline

◆ GetLengths()

template<typename T >
decltype(auto) ck::Tensor< T >::GetLengths ( ) const
inline

◆ GetNumOfDimension()

template<typename T >
std::size_t ck::Tensor< T >::GetNumOfDimension ( ) const
inline

◆ GetOffsetFromMultiIndex()

template<typename T >
template<typename... Is>
std::size_t ck::Tensor< T >::GetOffsetFromMultiIndex ( Is...  is) const
inline

◆ GetStrides()

template<typename T >
decltype(auto) ck::Tensor< T >::GetStrides ( ) const
inline

◆ operator()() [1/4]

template<typename T >
T& ck::Tensor< T >::operator() ( const std::vector< std::size_t > &  idx)
inline

◆ operator()() [2/4]

template<typename T >
const T& ck::Tensor< T >::operator() ( const std::vector< std::size_t > &  idx) const
inline

◆ operator()() [3/4]

template<typename T >
template<typename... Is>
T& ck::Tensor< T >::operator() ( Is...  is)
inline

◆ operator()() [4/4]

template<typename T >
template<typename... Is>
const T& ck::Tensor< T >::operator() ( Is...  is) const
inline

◆ operator=() [1/2]

template<typename T >
Tensor& ck::Tensor< T >::operator= ( const Tensor< T > &  )
default

◆ operator=() [2/2]

template<typename T >
Tensor& ck::Tensor< T >::operator= ( Tensor< T > &&  )
default

◆ savetxt()

template<typename T >
void ck::Tensor< T >::savetxt ( std::string  file_name,
std::string  dtype = "float" 
)
inline

◆ SetZero()

template<typename T >
void ck::Tensor< T >::SetZero ( )
inline

◆ size()

template<typename T >
Data::size_type ck::Tensor< T >::size ( ) const
inline

Member Data Documentation

◆ mData

template<typename T >
Data ck::Tensor< T >::mData

◆ mDesc

template<typename T >
Descriptor ck::Tensor< T >::mDesc

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/library/utility/host_tensor.hpp