cutlass::HostTensor< Element_, Layout_ > Class Template Reference

Host tensor.

`#include <host_tensor.h>`

## Public Types

using | Element = Element_
| Data type of individual access. More...
using | Layout = Layout_
| Mapping function from logical coordinate to linear memory. More...
using | Index = typename Layout::Index
| Index type. More...
using | LongIndex = typename Layout::LongIndex
| Long index used for pointer offsets. More...
using | TensorCoord = typename Layout::TensorCoord
| Coordinate in logical tensor space. More...
using | Stride = typename Layout::Stride
| Layout's stride vector. More...
using | TensorRef = TensorRef< Element, Layout >
| Tensor reference to device memory. More...
using | ConstTensorRef = typename TensorRef::ConstTensorRef
| Tensor reference to constant device memory. More...
using | TensorView = TensorView< Element, Layout >
| Tensor reference to device memory. More...
using | ConstTensorView = typename TensorView::ConstTensorView
| Tensor reference to constant device memory. More...
using | Reference = typename TensorRef::Reference
| Reference to element in tensor. More...
using | ConstReference = typename ConstTensorRef::Reference
| Constant reference to element in tensor. More...

## Public Member Functions

| HostTensor ()
| Default constructor. More...
| HostTensor (TensorCoord const &extent, bool device_backed=true)
| Constructs a tensor given an extent. Assumes a packed layout. More...
| HostTensor (TensorCoord const &extent, Layout const &layout, bool device_backed=true)
| Constructs a tensor given an extent and layout. More...
| ~HostTensor ()
void | reset ()
| Clears the HostTensor allocation to size/capacity = 0. More...
void | reserve (size_t count, bool device_backed_=true)
| Resizes internal memory allocations without affecting layout or extent. More...
void | reset (TensorCoord const &extent, Layout const &layout, bool device_backed_=true)
void | reset (TensorCoord const &extent, bool device_backed_=true)
void | resize (TensorCoord const &extent, Layout const &layout, bool device_backed_=true)
void | resize (TensorCoord const &extent, bool device_backed_=true)
size_t | size () const
| Returns the number of elements stored in the host tensor. More...
LongIndex | capacity () const
| Returns the logical capacity based on extent and layout. May differ from size(). More...
Element * | host_data ()
| Gets pointer to host data. More...
Element * | host_data_ptr_offset (LongIndex ptr_element_offset)
| Gets pointer to host data with a pointer offset. More...
Reference | host_data (LongIndex idx)
| Gets a reference to an element in host memory. More...
Element const * | host_data () const
| Gets pointer to host data. More...
ConstReference | host_data (LongIndex idx) const
| Gets a constant reference to an element in host memory. More...
Element * | device_data ()
| Gets pointer to device data. More...
Element * | device_data_ptr_offset (LongIndex ptr_element_offset)
| Gets pointer to device data with a pointer offset. More...
Element const * | device_data () const
| Gets pointer to device data. More...
TensorRef | host_ref (LongIndex ptr_element_offset=0)
| Accesses the tensor reference pointing to data. More...
ConstTensorRef | host_ref (LongIndex ptr_element_offset=0) const
| Accesses the tensor reference pointing to data. More...
TensorRef | device_ref (LongIndex ptr_element_offset=0)
| Accesses the tensor reference pointing to data. More...
ConstTensorRef | device_ref (LongIndex ptr_element_offset=0) const
| Accesses the tensor reference pointing to data. More...
TensorView | host_view (LongIndex ptr_element_offset=0)
| Accesses the tensor reference pointing to data. More...
ConstTensorView | host_view (LongIndex ptr_element_offset=0) const
| Accesses the tensor reference pointing to data. More...
TensorView | device_view (LongIndex ptr_element_offset=0)
| Accesses the tensor reference pointing to data. More...
ConstTensorView | device_view (LongIndex ptr_element_offset=0) const
| Accesses the tensor reference pointing to data. More...
bool | device_backed () const
| Returns true if device memory is allocated. More...
Layout & | layout ()
| Returns the layout object. More...
Layout | layout () const
| Returns the layout object. More...
Stride | stride () const
| Returns the layout object's stride vector. More...
Stride & | stride ()
| Returns the layout object's stride vector. More...
Index | stride (int dim) const
| Returns the layout object's stride in a given physical dimension. More...
Index & | stride (int dim)
| Returns the layout object's stride in a given physical dimension. More...
LongIndex | offset (TensorCoord const &coord) const
| Computes the offset of an index from the origin of the tensor. More...
Reference | at (TensorCoord const &coord)
| Returns a reference to the element at the logical Coord in host memory. More...
ConstReference | at (TensorCoord const &coord) const
| Returns a const reference to the element at the logical Coord in host memory. More...
TensorCoord | extent () const
| Returns the extent of the tensor. More...
TensorCoord & | extent ()
| Returns the extent of the tensor. More...
void | sync_host ()
| Copies data from device to host. More...
void | sync_device ()
| Copies data from host to device. More...
void | copy_in_device_to_host (Element const *ptr_device, LongIndex count=-1)
| Copy data from a caller-supplied device pointer into host memory. More...
void | copy_in_device_to_device (Element const *ptr_device, LongIndex count=-1)
| Copy data from a caller-supplied device pointer into host memory. More...
void | copy_in_host_to_device (Element const *ptr_host, LongIndex count=-1)
| Copy data from a caller-supplied device pointer into host memory. More...
void | copy_in_host_to_host (Element const *ptr_host, LongIndex count=-1)
| Copy data from a caller-supplied device pointer into host memory. More...
void | copy_out_device_to_host (Element *ptr_host, LongIndex count=-1) const
| Copy data from a caller-supplied device pointer into host memory. More...
void | copy_out_device_to_device (Element *ptr_device, LongIndex count=-1) const
| Copy data from a caller-supplied device pointer into host memory. More...
void | copy_out_host_to_device (Element *ptr_device, LongIndex count=-1) const
| Copy data from a caller-supplied device pointer into host memory. More...
void | copy_out_host_to_host (Element *ptr_host, LongIndex count=-1) const
| Copy data from a caller-supplied device pointer into host memory. More...

## Static Public Attributes

static int const | kRank = Layout::kRank
| Logical rank of tensor index space. More...
static int const | kElementsPerStoredItem = (sizeof_bits<Element>::value < 8 ? sizeof(Element) * 8 / sizeof_bits<Element>::value : 1)
| Used to handle packing of subbyte elements. More...

## Member Typedef Documentation

template<typename Element_ , typename Layout_ >

using cutlass::HostTensor< Element_, Layout_ >::ConstReference = typename ConstTensorRef::Reference

template<typename Element_ , typename Layout_ >

using cutlass::HostTensor< Element_, Layout_ >::ConstTensorRef = typename TensorRef::ConstTensorRef

template<typename Element_ , typename Layout_ >

using cutlass::HostTensor< Element_, Layout_ >::ConstTensorView = typename TensorView::ConstTensorView

template<typename Element_ , typename Layout_ >

using cutlass::HostTensor< Element_, Layout_ >::Element = Element_

template<typename Element_ , typename Layout_ >

using cutlass::HostTensor< Element_, Layout_ >::Index = typename Layout::Index

template<typename Element_ , typename Layout_ >

using cutlass::HostTensor< Element_, Layout_ >::Layout = Layout_

template<typename Element_ , typename Layout_ >

using cutlass::HostTensor< Element_, Layout_ >::LongIndex = typename Layout::LongIndex

template<typename Element_ , typename Layout_ >

using cutlass::HostTensor< Element_, Layout_ >::Reference = typename TensorRef::Reference

template<typename Element_ , typename Layout_ >

using cutlass::HostTensor< Element_, Layout_ >::Stride = typename Layout::Stride

template<typename Element_ , typename Layout_ >

using cutlass::HostTensor< Element_, Layout_ >::TensorCoord = typename Layout::TensorCoord

template<typename Element_ , typename Layout_ >

using cutlass::HostTensor< Element_, Layout_ >::TensorRef = TensorRef<Element, Layout>

template<typename Element_ , typename Layout_ >

using cutlass::HostTensor< Element_, Layout_ >::TensorView = TensorView<Element, Layout>

## Constructor & Destructor Documentation

template<typename Element_ , typename Layout_ >

cutlass::HostTensor< Element_, Layout_ >::HostTensor | ( |  | ) |

inline

template<typename Element_ , typename Layout_ >

cutlass::HostTensor< Element_, Layout_ >::HostTensor | ( | TensorCoord const & | extent,
|  | bool | device_backed = `true`
| ) |  |

inline

template<typename Element_ , typename Layout_ >

cutlass::HostTensor< Element_, Layout_ >::HostTensor | ( | TensorCoord const & | extent,
|  | Layout const & | layout,
|  | bool | device_backed = `true`
| ) |  |

inline

template<typename Element_ , typename Layout_ >

cutlass::HostTensor< Element_, Layout_ >::~HostTensor | ( |  | ) |

inline

## Member Function Documentation

template<typename Element_ , typename Layout_ >

Reference cutlass::HostTensor< Element_, Layout_ >::at | ( | TensorCoord const & | coord | ) |

inline

template<typename Element_ , typename Layout_ >

ConstReference cutlass::HostTensor< Element_, Layout_ >::at | ( | TensorCoord const & | coord | ) | const

inline

template<typename Element_ , typename Layout_ >

LongIndex cutlass::HostTensor< Element_, Layout_ >::capacity | ( |  | ) | const

inline

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::copy_in_device_to_device | ( | Element const * | ptr_device,
|  | LongIndex | count = `-1`
| ) |  |

inline

< number of elements to transfer; if negative, entire tensor is overwritten.

Parameters

  ptr_device | source device memory

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::copy_in_device_to_host | ( | Element const * | ptr_device,
|  | LongIndex | count = `-1`
| ) |  |

inline

< number of elements to transfer; if negative, entire tensor is overwritten.

Parameters

  ptr_device | source device memory

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::copy_in_host_to_device | ( | Element const * | ptr_host,
|  | LongIndex | count = `-1`
| ) |  |

inline

< number of elements to transfer; if negative, entire tensor is overwritten.

Parameters

  ptr_host | source host memory

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::copy_in_host_to_host | ( | Element const * | ptr_host,
|  | LongIndex | count = `-1`
| ) |  |

inline

< number of elements to transfer; if negative, entire tensor is overwritten.

Parameters

  ptr_host | source host memory

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::copy_out_device_to_device | ( | Element * | ptr_device,
|  | LongIndex | count = `-1`
| ) |  | const

inline

< number of elements to transfer; if negative, entire tensor is overwritten.

Parameters

  ptr_device | source device memory

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::copy_out_device_to_host | ( | Element * | ptr_host,
|  | LongIndex | count = `-1`
| ) |  | const

inline

< number of elements to transfer; if negative, entire tensor is overwritten.

Parameters

  ptr_host | source device memory

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::copy_out_host_to_device | ( | Element * | ptr_device,
|  | LongIndex | count = `-1`
| ) |  | const

inline

< number of elements to transfer; if negative, entire tensor is overwritten.

Parameters

  ptr_device | source host memory

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::copy_out_host_to_host | ( | Element * | ptr_host,
|  | LongIndex | count = `-1`
| ) |  | const

inline

< number of elements to transfer; if negative, entire tensor is overwritten.

Parameters

  ptr_host | source host memory

template<typename Element_ , typename Layout_ >

bool cutlass::HostTensor< Element_, Layout_ >::device_backed | ( |  | ) | const

inline

template<typename Element_ , typename Layout_ >

Element* cutlass::HostTensor< Element_, Layout_ >::device_data | ( |  | ) |

inline

template<typename Element_ , typename Layout_ >

Element const* cutlass::HostTensor< Element_, Layout_ >::device_data | ( |  | ) | const

inline

template<typename Element_ , typename Layout_ >

Element* cutlass::HostTensor< Element_, Layout_ >::device_data_ptr_offset | ( | LongIndex | ptr_element_offset | ) |

inline

template<typename Element_ , typename Layout_ >

TensorRef cutlass::HostTensor< Element_, Layout_ >::device_ref | ( | LongIndex | ptr_element_offset = `0` | ) |

inline

template<typename Element_ , typename Layout_ >

ConstTensorRef cutlass::HostTensor< Element_, Layout_ >::device_ref | ( | LongIndex | ptr_element_offset = `0` | ) | const

inline

template<typename Element_ , typename Layout_ >

TensorView cutlass::HostTensor< Element_, Layout_ >::device_view | ( | LongIndex | ptr_element_offset = `0` | ) |

inline

template<typename Element_ , typename Layout_ >

ConstTensorView cutlass::HostTensor< Element_, Layout_ >::device_view | ( | LongIndex | ptr_element_offset = `0` | ) | const

inline

template<typename Element_ , typename Layout_ >

TensorCoord cutlass::HostTensor< Element_, Layout_ >::extent | ( |  | ) | const

inline

template<typename Element_ , typename Layout_ >

TensorCoord& cutlass::HostTensor< Element_, Layout_ >::extent | ( |  | ) |

inline

template<typename Element_ , typename Layout_ >

Element* cutlass::HostTensor< Element_, Layout_ >::host_data | ( |  | ) |

inline

template<typename Element_ , typename Layout_ >

Reference cutlass::HostTensor< Element_, Layout_ >::host_data | ( | LongIndex | idx | ) |

inline

template<typename Element_ , typename Layout_ >

Element const* cutlass::HostTensor< Element_, Layout_ >::host_data | ( |  | ) | const

inline

template<typename Element_ , typename Layout_ >

ConstReference cutlass::HostTensor< Element_, Layout_ >::host_data | ( | LongIndex | idx | ) | const

inline

template<typename Element_ , typename Layout_ >

Element* cutlass::HostTensor< Element_, Layout_ >::host_data_ptr_offset | ( | LongIndex | ptr_element_offset | ) |

inline

template<typename Element_ , typename Layout_ >

TensorRef cutlass::HostTensor< Element_, Layout_ >::host_ref | ( | LongIndex | ptr_element_offset = `0` | ) |

inline

template<typename Element_ , typename Layout_ >

ConstTensorRef cutlass::HostTensor< Element_, Layout_ >::host_ref | ( | LongIndex | ptr_element_offset = `0` | ) | const

inline

template<typename Element_ , typename Layout_ >

TensorView cutlass::HostTensor< Element_, Layout_ >::host_view | ( | LongIndex | ptr_element_offset = `0` | ) |

inline

template<typename Element_ , typename Layout_ >

ConstTensorView cutlass::HostTensor< Element_, Layout_ >::host_view | ( | LongIndex | ptr_element_offset = `0` | ) | const

inline

template<typename Element_ , typename Layout_ >

Layout& cutlass::HostTensor< Element_, Layout_ >::layout | ( |  | ) |

inline

template<typename Element_ , typename Layout_ >

Layout cutlass::HostTensor< Element_, Layout_ >::layout | ( |  | ) | const

inline

template<typename Element_ , typename Layout_ >

LongIndex cutlass::HostTensor< Element_, Layout_ >::offset | ( | TensorCoord const & | coord | ) | const

inline

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::reserve | ( | size_t | count,
|  | bool | device_backed_ = `true`
| ) |  |

inline

< if true, device memory is also allocated

Parameters

  count | size of tensor in elements

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::reset | ( |  | ) |

inline

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::reset | ( | TensorCoord const & | extent,
|  | Layout const & | layout,
|  | bool | device_backed_ = `true`
| ) |  |

inline

Updates the extent and layout of the HostTensor. Allocates memory according to the new extent and layout.

< if true, device memory is also allocated.

Parameters

  extent | extent of logical tensor
  layout | layout object of tensor

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::reset | ( | TensorCoord const & | extent,
|  | bool | device_backed_ = `true`
| ) |  |

inline

Updates the extent and layout of the HostTensor. Allocates memory according to the new extent and layout. Assumes a packed tensor configuration.

< if true, device memory is also allocated.

Parameters

  extent | extent of logical tensor

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::resize | ( | TensorCoord const & | extent,
|  | Layout const & | layout,
|  | bool | device_backed_ = `true`
| ) |  |

inline

Changes the size of the logical tensor. Only allocates memory if new capacity exceeds reserved capacity. To force allocation, call reset().

< if true, device memory is also allocated.

Parameters

  extent | extent of logical tensor
  layout | layout object of tensor

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::resize | ( | TensorCoord const & | extent,
|  | bool | device_backed_ = `true`
| ) |  |

inline

Changes the size of the logical tensor. Only allocates memory if new capacity exceeds reserved capacity. To force allocation, call reset(). Note, this form of resize() assumes a packed tensor configuration.

< if true, device memory is also allocated.

Parameters

  extent | extent of logical tensor

template<typename Element_ , typename Layout_ >

size_t cutlass::HostTensor< Element_, Layout_ >::size | ( |  | ) | const

inline

template<typename Element_ , typename Layout_ >

Stride cutlass::HostTensor< Element_, Layout_ >::stride | ( |  | ) | const

inline

template<typename Element_ , typename Layout_ >

Stride& cutlass::HostTensor< Element_, Layout_ >::stride | ( |  | ) |

inline

template<typename Element_ , typename Layout_ >

Index cutlass::HostTensor< Element_, Layout_ >::stride | ( | int | dim | ) | const

inline

template<typename Element_ , typename Layout_ >

Index& cutlass::HostTensor< Element_, Layout_ >::stride | ( | int | dim | ) |

inline

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::sync_device | ( |  | ) |

inline

template<typename Element_ , typename Layout_ >

void cutlass::HostTensor< Element_, Layout_ >::sync_host | ( |  | ) |

inline

## Member Data Documentation

template<typename Element_ , typename Layout_ >

int const cutlass::HostTensor< Element_, Layout_ >::kElementsPerStoredItem = (sizeof_bits<Element>::value < 8 ? sizeof(Element) * 8 / sizeof_bits<Element>::value : 1)

static

template<typename Element_ , typename Layout_ >

int const cutlass::HostTensor< Element_, Layout_ >::kRank = Layout::kRank

static

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

- host_tensor.h