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

Namespaces

 detail
 

Classes

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...
 
class  TensorView
 A tensor view with static type and dimension. It implements indexing and slicing. 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...
 

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 I , int32_t D, std::enable_if_t<!common::detail::IsSpan< Container >::value > * = nullptr>
auto MakeTensorView (Container &data, I const (&shape)[D], int32_t device)
 Constructor for automatic type deduction. More...
 
template<typename T , typename I , int32_t D>
LINALG_HD auto MakeTensorView (common::Span< T > data, I const (&shape)[D], int32_t device)
 
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<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 , int32_t D>
void Stack (Tensor< T, D > *l, Tensor< T, D > const &r)
 
template<typename T , int32_t D, typename Fn >
void ElementWiseTransformHost (linalg::TensorView< T, D > t, int32_t n_threads, Fn &&fn)
 
template<typename T , int32_t D, typename Fn >
void ElementWiseKernelHost (linalg::TensorView< T, D > t, int32_t n_threads, Fn &&fn)
 
template<typename T , int32_t D, typename Fn >
void ElementWiseKernelDevice (linalg::TensorView< T, D > t, Fn &&fn, void *s=nullptr)
 
template<typename T , int32_t D, typename Fn >
void ElementWiseTransformDevice (linalg::TensorView< T, D > t, Fn &&fn, void *s=nullptr)
 
template<typename T , int32_t D, typename Fn >
void ElementWiseKernel (GenericParameter const *ctx, linalg::TensorView< T, D > t, Fn &&fn)
 

Typedef Documentation

◆ 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

◆ 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

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)

◆ ElementWiseKernel()

template<typename T , int32_t D, typename Fn >
void xgboost::linalg::ElementWiseKernel ( GenericParameter const *  ctx,
linalg::TensorView< T, D >  t,
Fn &&  fn 
)

◆ ElementWiseKernelDevice()

template<typename T , int32_t D, typename Fn >
void xgboost::linalg::ElementWiseKernelDevice ( linalg::TensorView< T, D >  t,
Fn &&  fn,
void *  s = nullptr 
)

◆ ElementWiseKernelHost()

template<typename T , int32_t D, typename Fn >
void xgboost::linalg::ElementWiseKernelHost ( linalg::TensorView< T, D >  t,
int32_t  n_threads,
Fn &&  fn 
)

◆ ElementWiseTransformDevice()

template<typename T , int32_t D, typename Fn >
void xgboost::linalg::ElementWiseTransformDevice ( linalg::TensorView< T, D >  t,
Fn &&  fn,
void *  s = nullptr 
)

◆ ElementWiseTransformHost()

template<typename T , int32_t D, typename Fn >
void xgboost::linalg::ElementWiseTransformHost ( linalg::TensorView< T, D >  t,
int32_t  n_threads,
Fn &&  fn 
)

◆ MakeTensorView() [1/2]

template<typename T , typename I , int32_t D>
LINALG_HD auto xgboost::linalg::MakeTensorView ( common::Span< T >  data,
I const (&)  shape[D],
int32_t  device 
)

◆ MakeTensorView() [2/2]

template<typename Container , typename I , int32_t D, std::enable_if_t<!common::detail::IsSpan< Container >::value > * = nullptr>
auto xgboost::linalg::MakeTensorView ( Container &  data,
I const (&)  shape[D],
int32_t  device 
)

Constructor for automatic type deduction.

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

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.