xgboost
公有类型 | 公有成员函数 | 所有成员列表
xgboost::linalg::Tensor< T, kDim > 类模板参考

张量存储。若要使用切片等其他功能,需要先获取一个视图。这样我们就可以在主机和设备上使用它。更多...

#include <linalg.h>

xgboost::linalg::Tensor< T, kDim > 的协作图
Collaboration graph

公有类型

使用 ShapeT = std::size_t[kDim]
 
使用 StrideT = ShapeT
 

公有成员函数

 Tensor ()=default
 
template<typename I , int32_t D>
 Tensor (I const (&shape)[D], DeviceOrd device, Order order=kC)
 创建具有形状和设备序号的张量。存储会自动初始化。更多...
 
template<typename I , size_t D>
 Tensor (common::Span< I const, D > shape, DeviceOrd device, Order order=kC)
 
template<typename It , typename I , int32_t D>
 Tensor (It begin, It end, I const (&shape)[D], DeviceOrd device, Order order=kC)
 
template<typename I , int32_t D>
 Tensor (std::initializer_list< T > data, I const (&shape)[D], DeviceOrd device, Order order=kC)
 
template<typename... Index>
T & operator() (Index &&...idx)
 索引操作符。非线程安全,不应在性能关键区域使用。为了更高效的索引,请考虑先获取一个视图。更多...
 
template<typename... Index>
T const & operator() (Index &&...idx) const
 索引操作符。非线程安全,不应在性能关键区域使用。为了更高效的索引,请考虑先获取一个视图。更多...
 
auto View (DeviceOrd device)
 获取此张量的 TensorView更多...
 
auto View (DeviceOrd device) const
 
auto HostView ()
 
auto HostView () const
 
std::size_t Size () const
 
bool Empty () const
 
auto Shape () const
 
auto Shape (size_t i) const
 
HostDeviceVector< T > * Data ()
 
HostDeviceVector< T > const * Data () const
 
template<typename Fn >
void ModifyInplace (Fn &&fn)
 用于修改形状和数据的访问函数。更多...
 
template<typename... S, detail::EnableIfIntegral< S... > * = nullptr>
void Reshape (S &&...s)
 重塑张量。更多...
 
template<size_t D>
void Reshape (common::Span< size_t const, D > shape)
 重塑张量。更多...
 
template<size_t D>
void Reshape (size_t(&shape)[D])
 
template<typename... S>
auto Slice (S &&...slices) const
 获取切片的主机视图。更多...
 
template<typename... S>
auto Slice (S &&...slices)
 获取切片的主机视图。更多...
 
void SetDevice (DeviceOrd device) const
 设置此张量的设备序号。更多...
 
DeviceOrd Device () const
 

详细描述

template<typename T, int32_t kDim = 5>
class xgboost::linalg::Tensor< T, kDim >

张量存储。若要使用切片等其他功能,需要先获取一个视图。这样我们就可以在主机和设备上使用它。

成员类型定义文档

◆ ShapeT

template<typename T , int32_t kDim = 5>
使用 xgboost::linalg::Tensor< T, kDim >::ShapeT = std::size_t[kDim]

◆ StrideT

template<typename T , int32_t kDim = 5>
使用 xgboost::linalg::Tensor< T, kDim >::StrideT = ShapeT

构造函数 & 析构函数文档

◆ Tensor() [1/5]

template<typename T , int32_t kDim = 5>
xgboost::linalg::Tensor< T, kDim >::Tensor ( )
默认

◆ Tensor() [2/5]

template<typename T , int32_t kDim = 5>
template<typename I , int32_t D>
xgboost::linalg::Tensor< T, kDim >::Tensor ( I const (&)  形状[D],
DeviceOrd  设备,
顺序  顺序 = kC 
)
内联显式

创建具有形状和设备序号的张量。存储会自动初始化。

请参阅 TensorView 以了解此构造函数的参数。

◆ Tensor() [3/5]

template<typename T , int32_t kDim = 5>
template<typename I , size_t D>
xgboost::linalg::Tensor< T, kDim >::Tensor ( common::Span< I const, D >  形状,
DeviceOrd  设备,
顺序  顺序 = kC 
)
内联显式

◆ Tensor() [4/5]

template<typename T , int32_t kDim = 5>
template<typename It , typename I , int32_t D>
xgboost::linalg::Tensor< T, kDim >::Tensor ( 它  开始,
它  结束,
I const (&)  形状[D],
DeviceOrd  设备,
顺序  顺序 = kC 
)
内联显式

从 2 个主机迭代器初始化。

◆ Tensor() [5/5]

template<typename T , int32_t kDim = 5>
template<typename I , int32_t D>
xgboost::linalg::Tensor< T, kDim >::Tensor ( std::initializer_list< T >  数据,
I const (&)  形状[D],
DeviceOrd  设备,
顺序  顺序 = kC 
)
内联显式

成员函数文档

◆ Data() [1/2]

template<typename T , int32_t kDim = 5>
HostDeviceVector<T>* xgboost::linalg::Tensor< T, kDim >::Data ( )
内联

◆ Data() [2/2]

template<typename T , int32_t kDim = 5>
HostDeviceVector<T> const* xgboost::linalg::Tensor< T, kDim >::Data ( ) 常量
内联

◆ Device()

template<typename T , int32_t kDim = 5>
DeviceOrd xgboost::linalg::Tensor< T, kDim >::Device ( ) 常量
内联

◆ Empty()

template<typename T , int32_t kDim = 5>
bool xgboost::linalg::Tensor< T, kDim >::Empty ( ) 常量
内联

◆ HostView() [1/2]

template<typename T , int32_t kDim = 5>
auto xgboost::linalg::Tensor< T, kDim >::HostView ( )
内联

◆ HostView() [2/2]

template<typename T , int32_t kDim = 5>
auto xgboost::linalg::Tensor< T, kDim >::HostView ( ) 常量
内联

◆ ModifyInplace()

template<typename T , int32_t kDim = 5>
template<typename Fn >
void xgboost::linalg::Tensor< T, kDim >::ModifyInplace ( Fn &&  fn)
内联

用于修改形状和数据的访问函数。

模板参数
Fn一个函数,它接受指向 HostDeviceVector 的指针和一个静态大小的 Span 作为参数。

◆ operator()() [1/2]

template<typename T , int32_t kDim = 5>
template<typename... Index>
T& xgboost::linalg::Tensor< T, kDim >::operator() ( Index &&...  索引)
内联

索引操作符。非线程安全,不应在性能关键区域使用。为了更高效的索引,请考虑先获取一个视图。

◆ operator()() [2/2]

template<typename T , int32_t kDim = 5>
template<typename... Index>
T const& xgboost::linalg::Tensor< T, kDim >::operator() ( Index &&...  索引) 常量
内联

索引操作符。非线程安全,不应在性能关键区域使用。为了更高效的索引,请考虑先获取一个视图。

◆ Reshape() [1/3]

template<typename T , int32_t kDim = 5>
template<size_t D>
void xgboost::linalg::Tensor< T, kDim >::Reshape ( common::Span< size_t const, D >  形状)
内联

重塑张量。

如果总大小发生改变,则此张量中的数据将不再有效。

◆ Reshape() [2/3]

template<typename T , int32_t kDim = 5>
template<typename... S, detail::EnableIfIntegral< S... > * = nullptr>
void xgboost::linalg::Tensor< T, kDim >::Reshape ( S &&...  s)
内联

重塑张量。

如果总大小发生改变,则此张量中的数据将不再有效。

◆ Reshape() [3/3]

template<typename T , int32_t kDim = 5>
template<size_t D>
void xgboost::linalg::Tensor< T, kDim >::Reshape ( size_t(&)  形状[D])
内联

◆ SetDevice()

template<typename T , int32_t kDim = 5>
void xgboost::linalg::Tensor< T, kDim >::SetDevice ( DeviceOrd  设备) 常量
内联

设置此张量的设备序号。

◆ Shape() [1/2]

template<typename T , int32_t kDim = 5>
auto xgboost::linalg::Tensor< T, kDim >::Shape ( ) 常量
内联

◆ Shape() [2/2]

template<typename T , int32_t kDim = 5>
auto xgboost::linalg::Tensor< T, kDim >::Shape ( size_t  i) 常量
内联

◆ Size()

template<typename T , int32_t kDim = 5>
std::size_t xgboost::linalg::Tensor< T, kDim >::Size ( ) 常量
内联

◆ Slice() [1/2]

template<typename T , int32_t kDim = 5>
template<typename... S>
auto xgboost::linalg::Tensor< T, kDim >::Slice ( S &&...  切片)
内联

获取切片的主机视图。

◆ Slice() [2/2]

template<typename T , int32_t kDim = 5>
template<typename... S>
auto xgboost::linalg::Tensor< T, kDim >::Slice ( S &&...  切片) 常量
内联

获取切片的主机视图。

◆ View() [1/2]

template<typename T , int32_t kDim = 5>
auto xgboost::linalg::Tensor< T, kDim >::View ( DeviceOrd  设备)
内联

获取此张量的 TensorView

◆ View() [2/2]

template<typename T , int32_t kDim = 5>
auto xgboost::linalg::Tensor< T, kDim >::View ( DeviceOrd  设备) 常量
内联

此类的文档生成自以下文件: