Medial Code Documentation
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
xgboost::linalg Namespace Reference

Copyright 2021-2023 by XGBoost Contributors. More...

Data Structures

class  Tensor
 A tensor storage. More...
 
class  TensorView
 A tensor view with static type and dimension. More...
 

Typedefs

template<typename T >
using VectorView = TensorView< T, 1 >
 A view over a vector, specialization of Tensor.
 
template<typename T >
using MatrixView = TensorView< T, 2 >
 A view over a matrix, specialization of Tensor.
 
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.
 
template<typename I >
constexpr detail::RangeTag< I > Range (I beg, I end)
 Specify a range of elements in the axis for slicing.
 
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.
 
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.
 
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.
 
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.
 
template<typename T , int32_t D>
Json ArrayInterface (TensorView< T, D > const &t)
 Same as const version, but returns non-readonly data pointer.
 
template<typename T , int32_t D>
auto ArrayInterfaceStr (TensorView< T const, D > const &t)
 Return string representation of array interface.
 
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.
 
template<typename T , typename... Index>
auto Constant (Context const *ctx, T v, Index &&...index)
 Create an array with value v.
 
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.
 
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 >, Fn &&, void *=nullptr)
 
template<typename T , int32_t D, typename Fn >
void ElementWiseTransformDevice (linalg::TensorView< T, D >, Fn &&, void *=nullptr)
 
template<typename T , int32_t D, typename Fn >
void ElementWiseKernel (Context const *ctx, linalg::TensorView< T, D > t, Fn &&fn)
 
template<typename T , std::int32_t kDim>
auto cbegin (TensorView< T, kDim > const &v)
 
template<typename T , std::int32_t kDim>
auto cend (TensorView< T, kDim > const &v)
 
template<typename T , std::int32_t kDim>
auto begin (TensorView< T, kDim > &v)
 
template<typename T , std::int32_t kDim>
auto end (TensorView< T, kDim > &v)
 
auto MakeMatrixFromTest (HostDeviceVector< float > *storage, std::size_t n_rows, std::size_t n_cols)
 
 TEST (Linalg, MatrixView)
 
 TEST (Linalg, VectorView)
 
 TEST (Linalg, TensorView)
 
 TEST (Linalg, Tensor)
 
 TEST (Linalg, Empty)
 
 TEST (Linalg, ArrayInterface)
 
 TEST (Linalg, Popc)
 
 TEST (Linalg, Stack)
 
 TEST (Linalg, FOrder)
 

Detailed Description

Copyright 2021-2023 by XGBoost Contributors.

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

◆ ArrayInterface()

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.

◆ MakeVec()

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.

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