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 > * 数据 ()
 
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 (&)  shape[D],
DeviceOrd  device,
Order  order = 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 >  shape,
DeviceOrd  device,
Order  order = 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 ( It  begin,
It  end,
I const (&)  shape[D],
DeviceOrd  device,
Order  order = kC 
)
内联显式

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

◆ 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 (&)  shape[D],
DeviceOrd  device,
Order  order = kC 
)
内联显式

成员函数文档

◆ Data() [1/2]

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

◆ Data() [2/2]

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

◆ Device()

template<typename T , int32_t kDim = 5>
DeviceOrd xgboost::linalg::Tensor< T, kDim >::Device ( ) const
inline

◆ Empty()

template<typename T , int32_t kDim = 5>
bool xgboost::linalg::Tensor< T, kDim >::Empty ( ) const
inline

◆ HostView() [1/2]

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

◆ HostView() [2/2]

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

◆ ModifyInplace()

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

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

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

◆ operator()() [1/2]

template<typename T , int32_t kDim = 5>
template<typename... Index>
T& xgboost::linalg::Tensor< T, kDim >::operator() ( Index &&...  idx)
inline

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

◆ operator()() [2/2]

template<typename T , int32_t kDim = 5>
template<typename... Index>
T const& xgboost::linalg::Tensor< T, kDim >::operator() ( Index &&...  idx) const
inline

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

◆ 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 >  shape)
inline

重塑张量。

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

◆ 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)
inline

重塑张量。

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

◆ Reshape() [3/3]

template<typename T , int32_t kDim = 5>
template<size_t D>
void xgboost::linalg::Tensor< T, kDim >::Reshape ( size_t(&)  shape[D])
inline

◆ SetDevice()

template<typename T , int32_t kDim = 5>
void xgboost::linalg::Tensor< T, kDim >::SetDevice ( DeviceOrd  device) const
inline

设置此张量的设备序号。

◆ Shape() [1/2]

template<typename T , int32_t kDim = 5>
auto xgboost::linalg::Tensor< T, kDim >::Shape ( ) const
inline

◆ Shape() [2/2]

template<typename T , int32_t kDim = 5>
auto xgboost::linalg::Tensor< T, kDim >::Shape ( size_t  i) const
inline

◆ Size()

template<typename T , int32_t kDim = 5>
std::size_t xgboost::linalg::Tensor< T, kDim >::Size ( ) const
inline

◆ Slice() [1/2]

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

获取切片的主机视图。

◆ Slice() [2/2]

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

获取切片的主机视图。

◆ View() [1/2]

template<typename T , int32_t kDim = 5>
auto xgboost::linalg::Tensor< T, kDim >::View ( DeviceOrd  device)
inline

获取此张量的 TensorView

◆ View() [2/2]

template<typename T , int32_t kDim = 5>
auto xgboost::linalg::Tensor< T, kDim >::View ( DeviceOrd  device) const
inline

此类的文档由以下文件生成