xgboost
命名空间 | | 类型定义 | 枚举 | 函数
xgboost::linalg 命名空间参考

命名空间

 detail
 

class  TensorView
 具有静态类型和维度的张量视图。它实现了索引和切片。更多...
 
class  Tensor
 张量存储。要使用它进行切片等其他功能,首先需要获取一个视图。通过这种方式,我们可以在主机和设备上使用它。更多...
 

类型定义

template<typename T >
using VectorView = TensorView< T, 1 >
 向量视图,是 Tensor 的特化。更多...
 
template<typename T >
using MatrixView = TensorView< T, 2 >
 矩阵视图,是 Tensor 的特化。更多...
 
template<typename T >
using Matrix = Tensor< T, 2 >
 
template<typename T >
using Vector = Tensor< T, 1 >
 

枚举

enum  Order : std::uint8_t { kC , kF }
 

函数

constexpr detail::AllTag All ()
 指定轴上的所有元素用于切片。更多...
 
template<typename I >
constexpr detail::RangeTag< I > Range (I beg, I end)
 指定轴上元素的范围用于切片。更多...
 
template<typename Container , typename... S, std::enable_if_t<!common::detail::IsSpan< Container >::value &&!std::is_pointer_v< Container >> * = nullptr>
auto MakeTensorView (Context const *ctx, Container &data, S &&...shape)
 用于自动类型推导的构造函数。更多...
 
template<typename T , decltype(common::dynamic_extent) ext, typename... S>
LINALG_HD auto MakeTensorView (DeviceOrd device, common::Span< T, ext > data, S &&...shape)
 
template<typename T , decltype(common::dynamic_extent) ext, typename... S>
auto MakeTensorView (Context const *ctx, common::Span< T, ext > data, S &&...shape)
 
template<typename T , decltype(common::dynamic_extent) ext, typename... S>
auto MakeTensorView (Context const *ctx, Order order, common::Span< T, ext > data, S &&...shape)
 
template<typename T , typename... S>
auto MakeTensorView (Context const *ctx, HostDeviceVector< T > *data, S &&...shape)
 
template<typename T , typename... S>
auto MakeTensorView (Context const *ctx, HostDeviceVector< T > const *data, S &&...shape)
 
template<size_t D>
LINALG_HD auto UnravelIndex (size_t idx, common::Span< size_t const, D > shape)
 将线性索引转换为多维索引。类似于 numpy unravel。更多...
 
template<size_t D>
LINALG_HD auto UnravelIndex (size_t idx, std::size_t const (&shape)[D])
 
template<typename... S>
LINALG_HD auto UnravelIndex (std::size_t idx, S... shape)
 
template<typename T >
auto MakeVec (T *ptr, size_t s, DeviceOrd device=DeviceOrd::CPU())
 从连续内存创建向量视图。更多...
 
template<typename T >
auto MakeVec (HostDeviceVector< T > *data)
 
template<typename T >
auto MakeVec (HostDeviceVector< T > const *data)
 
template<typename T , std::int32_t D>
Json ArrayInterface (TensorView< T const, D > const &t)
 numpy 定义的数组接口。更多...
 
template<typename T , int32_t D>
Json ArrayInterface (TensorView< T, D > const &t)
 与 const 版本相同,但返回非只读数据指针。更多...
 
template<typename T , int32_t D>
auto ArrayInterfaceStr (TensorView< T const, D > const &t)
 返回数组接口的字符串表示形式。更多...
 
template<typename T , int32_t D>
auto ArrayInterfaceStr (TensorView< T, D > const &t)
 
template<typename T >
auto Make1dInterface (T const *vec, std::size_t len)
 
template<typename T , typename... Index>
auto Empty (Context const *ctx, Index &&...index)
 创建未初始化的数组。更多...
 
template<typename T , typename... Index>
auto Constant (Context const *ctx, T v, Index &&...index)
 创建值为 v 的数组。更多...
 
template<typename T , typename... Index>
auto Zeros (Context const *ctx, Index &&...index)
 类似于 np.zeros,返回指定形状和类型的新数组,填充零。更多...
 
template<typename T , int32_t D>
void Stack (Tensor< T, D > *l, Tensor< T, D > const &r)
 

类型定义文档

◆ Matrix

template<typename T >
using xgboost::linalg::Matrix = typedef Tensor<T, 2>
示例
inference.c.

◆ MatrixView

template<typename T >
using xgboost::linalg::MatrixView = typedef TensorView<T, 2>

矩阵视图,是 Tensor 的特化。

模板参数
T矩阵的数据类型

◆ Vector

template<typename T >
using xgboost::linalg::Vector = typedef Tensor<T, 1>

◆ VectorView

template<typename T >
using xgboost::linalg::VectorView = typedef TensorView<T, 1>

向量视图,是 Tensor 的特化。

模板参数
T向量的数据类型

枚举类型文档

◆ Order

enum xgboost::linalg::Order : std::uint8_t
枚举成员
kC 
kF 

函数文档

◆ All()

constexpr detail::AllTag xgboost::linalg::All ( )
constexpr

指定轴上的所有元素用于切片。

◆ ArrayInterface() [1/2]

template<typename T , std::int32_t D>
Json xgboost::linalg::ArrayInterface ( TensorView< T const, D > const &  t)

numpy 定义的数组接口。

当数据在 CUDA 设备上时,可选地包含 stream

◆ ArrayInterface() [2/2]

template<typename T , int32_t D>
Json xgboost::linalg::ArrayInterface ( TensorView< T, D > const &  t)

与 const 版本相同,但返回非只读数据指针。

◆ ArrayInterfaceStr() [1/2]

template<typename T , int32_t D>
auto xgboost::linalg::ArrayInterfaceStr ( TensorView< T const, D > const &  t)

返回数组接口的字符串表示形式。

◆ ArrayInterfaceStr() [2/2]

template<typename T , int32_t D>
auto xgboost::linalg::ArrayInterfaceStr ( TensorView< T, D > const &  t)

◆ Constant()

template<typename T , typename... Index>
auto xgboost::linalg::Constant ( Context const *  ctx,
v,
Index &&...  index 
)

创建值为 v 的数组。

◆ Empty()

template<typename T , typename... Index>
auto xgboost::linalg::Empty ( Context const *  ctx,
Index &&...  index 
)

创建未初始化的数组。

◆ Make1dInterface()

template<typename T >
auto xgboost::linalg::Make1dInterface ( T const *  vec,
std::size_t  len 
)

◆ MakeTensorView() [1/6]

template<typename T , decltype(common::dynamic_extent) ext, typename... S>
auto xgboost::linalg::MakeTensorView ( Context const *  ctx,
common::Span< T, ext >  data,
S &&...  shape 
)

◆ MakeTensorView() [2/6]

template<typename Container , typename... S, std::enable_if_t<!common::detail::IsSpan< Container >::value &&!std::is_pointer_v< Container >> * = nullptr>
auto xgboost::linalg::MakeTensorView ( Context const *  ctx,
Container &  data,
S &&...  shape 
)

用于自动类型推导的构造函数。

◆ MakeTensorView() [3/6]

template<typename T , typename... S>
auto xgboost::linalg::MakeTensorView ( Context const *  ctx,
HostDeviceVector< T > *  data,
S &&...  shape 
)

◆ MakeTensorView() [4/6]

template<typename T , typename... S>
auto xgboost::linalg::MakeTensorView ( Context const *  ctx,
HostDeviceVector< T > const *  data,
S &&...  shape 
)

◆ MakeTensorView() [5/6]

template<typename T , decltype(common::dynamic_extent) ext, typename... S>
auto xgboost::linalg::MakeTensorView ( Context const *  ctx,
Order  order,
common::Span< T, ext >  data,
S &&...  shape 
)

◆ MakeTensorView() [6/6]

template<typename T , decltype(common::dynamic_extent) ext, typename... S>
LINALG_HD auto xgboost::linalg::MakeTensorView ( DeviceOrd  device,
common::Span< T, ext >  data,
S &&...  shape 
)

◆ MakeVec() [1/3]

template<typename T >
auto xgboost::linalg::MakeVec ( HostDeviceVector< T > *  data)

◆ MakeVec() [2/3]

template<typename T >
auto xgboost::linalg::MakeVec ( HostDeviceVector< T > const *  data)

◆ MakeVec() [3/3]

template<typename T >
auto xgboost::linalg::MakeVec ( T *  ptr,
size_t  s,
DeviceOrd  device = DeviceOrd::CPU() 
)

从连续内存创建向量视图。

参数
ptr指向连续内存的指针。
s向量的大小。
device(可选)设备序号,默认为主机。

◆ Range()

template<typename I >
constexpr detail::RangeTag<I> xgboost::linalg::Range ( beg,
end 
)
constexpr

指定轴上元素的范围用于切片。

◆ Stack()

template<typename T , int32_t D>
void xgboost::linalg::Stack ( Tensor< T, D > *  l,
Tensor< T, D > const &  r 
)

◆ UnravelIndex() [1/3]

template<size_t D>
LINALG_HD auto xgboost::linalg::UnravelIndex ( size_t  idx,
common::Span< size_t const, D >  shape 
)

将线性索引转换为多维索引。类似于 numpy unravel。

◆ UnravelIndex() [2/3]

template<size_t D>
LINALG_HD auto xgboost::linalg::UnravelIndex ( size_t  idx,
std::size_t const (&)  shape[D] 
)

◆ UnravelIndex() [3/3]

template<typename... S>
LINALG_HD auto xgboost::linalg::UnravelIndex ( std::size_t  idx,
S...  shape 
)

◆ Zeros()

template<typename T , typename... Index>
auto xgboost::linalg::Zeros ( Context const *  ctx,
Index &&...  index 
)

类似于 np.zeros,返回指定形状和类型的新数组,填充零。