xgboost

Public Types | Public Member Functions | List of all members
xgboost::linalg::Tensor< T, kDim > Class Template Reference

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

`#include <linalg.h>`

Collaboration diagram for xgboost::linalg::Tensor< T, kDim >:

## Public Types
using | ShapeT = size_t[kDim]
using | StrideT = ShapeT

## Public Member Functions
| Tensor ()=default
template<typename I , int32_t D>
| Tensor (I const (&shape)[D], int32_t device)
| Create a tensor with shape and device ordinal. The storage is initialized automatically. More...
template<typename It , typename I , int32_t D>
| Tensor (It begin, It end, I const (&shape)[D], int32_t device)
template<typename I , int32_t D>
| Tensor (std::initializer_list< T > data, I const (&shape)[D], int32_t device)
TensorView< T, kDim > | View (int32_t device)
| Get a TensorView for this tensor. More...
TensorView< T const, kDim > | View (int32_t device) const
auto | HostView () const
auto | HostView ()
size_t | Size () const
auto | Shape () const
auto | Shape (size_t i) const
HostDeviceVector< T > * | Data ()
const HostDeviceVector< T > * | Data () const
template<typename Fn >
void | ModifyInplace (Fn &&fn)
| Visitor function for modification that changes shape and data. More...
template<typename... S>
void | Reshape (S &&...s)
| Reshape the tensor. More...
template<int32_t D>
void | Reshape (size_t(&shape)[D])
| Reshape the tensor. More...
void | SetDevice (int32_t device) const
| Set device ordinal for this tensor. More...
int32_t | DeviceIdx () const

## Detailed Description

### template<typename T, int32_t kDim = 5>
class xgboost::linalg::Tensor< T, kDim >

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.

## Member Typedef Documentation

## ◆ ShapeT

template<typename T , int32_t kDim = 5>

using xgboost::linalg::Tensor< T, kDim >::ShapeT = size_t[kDim]

## ◆ StrideT

template<typename T , int32_t kDim = 5>

using xgboost::linalg::Tensor< T, kDim >::StrideT = ShapeT

## Constructor & Destructor Documentation

## ◆ Tensor() [1/4]

template<typename T , int32_t kDim = 5>

xgboost::linalg::Tensor< T, kDim >::Tensor | ( |  | ) |
| default

## ◆ Tensor() [2/4]

template<typename T , int32_t kDim = 5>
template<typename I , int32_t D>

xgboost::linalg::Tensor< T, kDim >::Tensor | ( | I const (&) | shape[D],
|  | int32_t | device
| ) |  |
| inline explicit

Create a tensor with shape and device ordinal. The storage is initialized automatically.

See TensorView for parameters of this constructor.

## ◆ Tensor() [3/4]

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],
|  | int32_t | device
| ) |  |
| inline explicit

Initialize from 2 host iterators.

## ◆ Tensor() [4/4]

template<typename T , int32_t kDim = 5>
template<typename I , int32_t D>

xgboost::linalg::Tensor< T, kDim >::Tensor | ( | std::initializer_list< T > | data,
|  | I const (&) | shape[D],
|  | int32_t | device
| ) |  |
| inline explicit

## Member Function Documentation

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

const HostDeviceVector<T>* xgboost::linalg::Tensor< T, kDim >::Data | ( |  | ) | const
| inline

## ◆ DeviceIdx()

template<typename T , int32_t kDim = 5>

int32_t xgboost::linalg::Tensor< T, kDim >::DeviceIdx | ( |  | ) | 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

Visitor function for modification that changes shape and data.

Template Parameters

  Fn | function that takes a pointer to `HostDeviceVector` and a static sized span as parameters.

## ◆ Reshape() [1/2]

template<typename T , int32_t kDim = 5>
template<typename... S>

void xgboost::linalg::Tensor< T, kDim >::Reshape | ( | S &&... | s | ) |
| inline

Reshape the tensor.

If the total size is changed, then data in this tensor is no longer valid.

## ◆ Reshape() [2/2]

template<typename T , int32_t kDim = 5>
template<int32_t D>

void xgboost::linalg::Tensor< T, kDim >::Reshape | ( | size_t(&) | shape[D] | ) |
| inline

Reshape the tensor.

If the total size is changed, then data in this tensor is no longer valid.

## ◆ SetDevice()

template<typename T , int32_t kDim = 5>

void xgboost::linalg::Tensor< T, kDim >::SetDevice | ( | int32_t | device | ) | const
| inline

Set device ordinal for this tensor.

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

size_t xgboost::linalg::Tensor< T, kDim >::Size | ( |  | ) | const
| inline

## ◆ View() [1/2]

template<typename T , int32_t kDim = 5>

TensorView<T, kDim> xgboost::linalg::Tensor< T, kDim >::View | ( | int32_t | device | ) |
| inline

Get a TensorView for this tensor.

## ◆ View() [2/2]

template<typename T , int32_t kDim = 5>

TensorView<T const, kDim> xgboost::linalg::Tensor< T, kDim >::View | ( | int32_t | device | ) | const
| inline

The documentation for this class was generated from the following file:

- /home/runner/work/xgboost/xgboost/include/xgboost/linalg.h