ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
ActsPlugins::Tensor< T > Class Template Reference

This is a very small, limited class that models a 2D tensor of arbitrary type. More...

#include <ActsPlugins/Gnn/Tensor.hpp>

Inheritance diagram for ActsPlugins::Tensor< T >:
[legend]

Public Types

using Shape = std::array<std::size_t, 2>
 Type alias for tensor shape as 2D dimensions array.

Public Member Functions

Tensor clone (const ExecutionContext &to) const
 Clone the tensor, copying the data to the new device.
T * data ()
 Get the non-const data pointer.
const T * data () const
 Get the const data pointer.
Device device () const
 Get the device of the tensor.
std::size_t nbytes () const
 Get the number of bytes of the tensor.
Shape shape () const
 Get the shape of the tensor.
std::size_t size () const
 Get the number of elements in the tensor.

Static Public Member Functions

static Tensor Create (Shape shape, const ExecutionContext &execContext)
 Create a new tensor with specified shape and execution context.

Detailed Description

template<Acts::Concepts::arithmetic T>
class ActsPlugins::Tensor< T >

This is a very small, limited class that models a 2D tensor of arbitrary type.

It is move-only, and only possible to create via static factory functions to ensure lifetime management. This on purpose does not implement operations such as clone/to-host/to-cuda

Member Typedef Documentation

◆ Shape

using ActsPlugins::Tensor< T >::Shape = std::array<std::size_t, 2>

Type alias for tensor shape as 2D dimensions array.

Member Function Documentation

◆ clone()

Tensor ActsPlugins::Tensor< T >::clone ( const ExecutionContext & to) const

Clone the tensor, copying the data to the new device.

Parameters
toThe {device, stream} to clone to
Note
This is a always a deep copy, even if the source and destination are the same device
Returns
New tensor on target device with copied data

◆ Create()

Tensor ActsPlugins::Tensor< T >::Create ( Shape shape,
const ExecutionContext & execContext )
static

Create a new tensor with specified shape and execution context.

Parameters
shape2D tensor dimensions [rows, columns]
execContextExecution context specifying device and optional CUDA stream
Returns
Newly created tensor with allocated memory on specified device

◆ data() [1/2]

T * ActsPlugins::Tensor< T >::data ( )

Get the non-const data pointer.

Returns
Mutable pointer to tensor data

◆ data() [2/2]

const T * ActsPlugins::Tensor< T >::data ( ) const

Get the const data pointer.

Returns
Const pointer to tensor data

◆ device()

Device ActsPlugins::Tensor< T >::device ( ) const

Get the device of the tensor.

◆ nbytes()

std::size_t ActsPlugins::Tensor< T >::nbytes ( ) const

Get the number of bytes of the tensor.

Returns
Total memory size of tensor data in bytes

◆ shape()

Shape ActsPlugins::Tensor< T >::shape ( ) const

Get the shape of the tensor.

Returns
Array containing tensor dimensions [rows, columns]

◆ size()

std::size_t ActsPlugins::Tensor< T >::size ( ) const

Get the number of elements in the tensor.

Returns
Total number of elements in the tensor