xgboost
Namespaces | Classes | Typedefs | Enumerations | Functions
xgboost::linalg Namespace Reference

Namespaces

 detail
 

Classes

class  TensorView
 A tensor view with static type and dimension. It implements indexing and slicing. More...
 
class  Tensor
 A tensor storage. To use it for other functionality like slicing one needs to obtain a view first. This way we can use it on both host and device. More...
 

Typedefs

template<typename T >
using VectorView = TensorView< T, 1 >
 A view over a vector, specialization of Tensor. More...
 
template<typename T >
using MatrixView = TensorView< T, 2 >
 A view over a matrix, specialization of Tensor. More...
 
template<typename T >
using Matrix = Tensor< T, 2 >
 
template<typename T >
using Vector = Tensor< T, 1 >
 

Enumerations

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

Functions

constexpr detail::AllTag All ()
 Specify all elements in the axis for slicing. More...
 
template<typename I >
constexpr detail::RangeTag< I > Range (I beg, I end)
 Specify a range of elements in the axis for slicing. More...
 
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)
 Constructor for automatic type deduction. More...
 
template<typename T , typename... S>
LINALG_HD auto MakeTensorView (std::int32_t device, common::Span< T > data, S &&...shape)
 
template<typename T , typename... S>
auto MakeTensorView (Context const *ctx, common::Span< T > 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)
 Turns linear index into multi-dimension index. Similar to numpy unravel. More...
 
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, int32_t device=-1)
 Create a vector view from contigious memory. More...
 
template<typename T >
auto MakeVec (HostDeviceVector< T > *data)
 
template<typename T >
auto MakeVec (HostDeviceVector< T > const *data)
 
template<typename T , int32_t D>
Json ArrayInterface (TensorView< T const, D > const &t)
 Array Interface defined by numpy. More...
 
template<typename T , int32_t D>
Json ArrayInterface (TensorView< T, D > const &t)
 Same as const version, but returns non-readonly data pointer. More...
 
template<typename T , int32_t D>
auto ArrayInterfaceStr (TensorView< T const, D > const &t)
 Return string representation of array interface. More...
 
template<typename T , int32_t D>
auto ArrayInterfaceStr (TensorView< T, D > const &t)
 
template<typename T , typename... Index>
auto Empty (Context const *ctx, Index &&...index)
 Create an array without initialization. More...
 
template<typename T , typename... Index>
auto Constant (Context const *ctx, T v, Index &&...index)
 Create an array with value v. More...
 
template<typename T , typename... Index>
auto Zeros (Context const *ctx, Index &&...index)
 Like np.zeros, return a new array of given shape and type, filled with zeros. More...
 
template<typename T , int32_t D>
void Stack (Tensor< T, D > *l, Tensor< T, D > const &r)
 

Typedef Documentation

◆ Matrix

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

◆ MatrixView

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

A view over a matrix, specialization of Tensor.

Template Parameters
Tdata type of matrix

◆ Vector

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

◆ VectorView

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

A view over a vector, specialization of Tensor.

Template Parameters
Tdata type of vector

Enumeration Type Documentation

◆ Order

enum xgboost::linalg::Order : std::uint8_t
Enumerator
kC 
kF 

Function Documentation

◆ All()

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

Specify all elements in the axis for slicing.

◆ ArrayInterface() [1/2]

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

Array Interface defined by numpy.

stream is optionally included when data is on CUDA device.

◆ ArrayInterface() [2/2]

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

Same as const version, but returns non-readonly data pointer.

◆ ArrayInterfaceStr() [1/2]

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

Return string representation of array interface.

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

Create an array with value v.

◆ Empty()

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

Create an array without initialization.

◆ MakeTensorView() [1/5]

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

◆ MakeTensorView() [2/5]

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 
)

Constructor for automatic type deduction.

◆ MakeTensorView() [3/5]

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

◆ MakeTensorView() [4/5]

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

◆ MakeTensorView() [5/5]

template<typename T , typename... S>
LINALG_HD auto xgboost::linalg::MakeTensorView ( std::int32_t  device,
common::Span< T >  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,
int32_t  device = -1 
)

Create a vector view from contigious memory.

Parameters
ptrPointer to the contigious memory.
sSize of the vector.
device(optional) Device ordinal, default to be host.

◆ Range()

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

Specify a range of elements in the axis for slicing.

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

Turns linear index into multi-dimension index. Similar to 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 
)

Like np.zeros, return a new array of given shape and type, filled with zeros.