Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TMVA::DNN::TCpuTensor< AFloat > Class Template Reference

template<typename AFloat>
class TMVA::DNN::TCpuTensor< AFloat >

Definition at line 40 of file CpuTensor.h.

Public Types

using Container_t
using Index_t
using Matrix_t = TCpuMatrix<AFloat>
using MemoryLayout = TMVA::Experimental::MemoryLayout
using Scalar_t = AFloat
using Shape_t = typename TMVA::Experimental::RTensor<AFloat>::Shape_t
using Slice_t
using Value_t

Public Member Functions

 TCpuTensor ()
 TCpuTensor (AFloat *data, const Shape_t &shape, MemoryLayout memlayout=MemoryLayout::ColumnMajor)
 TCpuTensor (const TCpuBuffer< AFloat > &buffer, Shape_t shape, MemoryLayout memlayout=MemoryLayout::ColumnMajor)
 constructors from a TCpuBuffer and a shape
 TCpuTensor (const TCpuMatrix< AFloat > &matrix, size_t dim=3, MemoryLayout memlayout=MemoryLayout::ColumnMajor)
 constructors from a TCpuMatrix.
 TCpuTensor (Shape_t shape, MemoryLayout memlayout=MemoryLayout::ColumnMajor)
 constructors from a shape.
 TCpuTensor (size_t bsize, size_t depth, size_t height, size_t width, MemoryLayout memlayout=MemoryLayout::ColumnMajor)
 constructors from batch size, depth, height, width
 TCpuTensor (size_t bsize, size_t depth, size_t hw, MemoryLayout memlayout=MemoryLayout::ColumnMajor)
 constructors from batch size, depth, height*width
 TCpuTensor (size_t n, size_t m, MemoryLayout memlayout=MemoryLayout::ColumnMajor)
 constructors from n m
TCpuTensor< AFloat > At (size_t i)
TCpuTensor< AFloat > At (size_t i) const
Iterator begin () noexcept
RTensor< Value_t, Container_tCopy (MemoryLayout layout=MemoryLayout::RowMajor) const
 Copy RTensor to new object.
Iterator end () noexcept
RTensor< Value_t, Container_tExpandDims (int idx) const
 Expand dimensions.
size_t GetBufferUseCount () const
std::shared_ptr< Container_tGetContainer ()
const std::shared_ptr< Container_tGetContainer () const
size_t GetCSize () const
Value_tGetData ()
const Value_tGetData () const
TCpuBuffer< AFloat > & GetDeviceBuffer ()
const TCpuBuffer< AFloat > & GetDeviceBuffer () const
size_t GetFirstSize () const
size_t GetHSize () const
MemoryLayout GetLayout () const
TCpuMatrix< AFloat > GetMatrix () const
MemoryLayout GetMemoryLayout () const
size_t GetNcols () const
size_t GetNoElements () const
size_t GetNrows () const
AFloat * GetRawDataPointer ()
 Return raw pointer to the elements stored contiguously in column-major order.
const AFloat * GetRawDataPointer () const
const Shape_tGetShape () const
std::size_t GetSize () const
const Shape_tGetStrides () const
size_t GetWSize () const
bool IsOwner () const
bool IsView () const
template<typename Function_t>
void Map (Function_t &f)
 Map the given function over the matrix elements.
template<typename Function_t>
void MapFrom (Function_t &f, const TCpuTensor< AFloat > &A)
 Same as maps but takes the input values from the tensor A and writes the results in this tensor.
 operator TMatrixT< AFloat > () const
 Convert to a TMatrixT<AFloat_t> object.
AFloat & operator() (size_t i, size_t j)
AFloat operator() (size_t i, size_t j) const
AFloat & operator() (size_t i, size_t j, size_t k)
AFloat operator() (size_t i, size_t j, size_t k) const
Value_toperator() (const Index_t &idx)
 Access elements.
const Value_toperator() (const Index_t &idx) const
 Access elements.
Value_toperator() (Idx... idx)
 Access elements.
const Value_toperator() (Idx... idx) const
 Access elements.
TCpuMatrix< AFloat > operator[] (size_t i) const
void Print (const char *name="Tensor") const
void PrintShape (const char *name="Tensor") const
TCpuTensor< AFloat > Reshape (Shape_t shape) const
RTensor< Value_t, Container_tReshape (const Shape_t &shape) const
 Reshape tensor.
RTensor< Value_t, Container_tResize (const Shape_t &shape)
 Resize tensor.
RTensor< Value_t, Container_tSlice (const Slice_t &slice)
 Create a slice of the tensor.
RTensor< Value_t, Container_tSqueeze () const
 Squeeze dimensions.
RTensor< Value_t, Container_tTranspose () const
 Transpose.
void Zero ()

Protected Member Functions

void ReshapeInplace (const Shape_t &shape)
 Reshape tensor in place.

Private Attributes

std::shared_ptr< Container_tfContainer
Value_tfData
MemoryLayout fLayout
Shape_t fShape
std::size_t fSize
Shape_t fStrides

Friends

class TCpuMatrix< AFloat >

#include <TMVA/DNN/Architectures/Cpu/CpuTensor.h>

Inheritance diagram for TMVA::DNN::TCpuTensor< AFloat >:
TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >

Member Typedef Documentation

◆ Container_t

using TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::Container_t
inherited

Definition at line 170 of file RTensor.hxx.

◆ Index_t

using TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::Index_t
inherited

Definition at line 168 of file RTensor.hxx.

◆ Matrix_t

template<typename AFloat>
using TMVA::DNN::TCpuTensor< AFloat >::Matrix_t = TCpuMatrix<AFloat>

Definition at line 49 of file CpuTensor.h.

◆ MemoryLayout

template<typename AFloat>
using TMVA::DNN::TCpuTensor< AFloat >::MemoryLayout = TMVA::Experimental::MemoryLayout

Definition at line 48 of file CpuTensor.h.

◆ Scalar_t

template<typename AFloat>
using TMVA::DNN::TCpuTensor< AFloat >::Scalar_t = AFloat

Definition at line 50 of file CpuTensor.h.

◆ Shape_t

template<typename AFloat>
using TMVA::DNN::TCpuTensor< AFloat >::Shape_t = typename TMVA::Experimental::RTensor<AFloat>::Shape_t

Definition at line 47 of file CpuTensor.h.

◆ Slice_t

using TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::Slice_t
inherited

Definition at line 169 of file RTensor.hxx.

◆ Value_t

using TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::Value_t
inherited

Definition at line 166 of file RTensor.hxx.

Constructor & Destructor Documentation

◆ TCpuTensor() [1/8]

template<typename AFloat>
TMVA::DNN::TCpuTensor< AFloat >::TCpuTensor ( )
inline

Definition at line 53 of file CpuTensor.h.

◆ TCpuTensor() [2/8]

template<typename AFloat>
TMVA::DNN::TCpuTensor< AFloat >::TCpuTensor ( size_t n,
size_t m,
MemoryLayout memlayout = MemoryLayout::ColumnMajor )
inline

constructors from n m

Definition at line 57 of file CpuTensor.h.

◆ TCpuTensor() [3/8]

template<typename AFloat>
TMVA::DNN::TCpuTensor< AFloat >::TCpuTensor ( size_t bsize,
size_t depth,
size_t hw,
MemoryLayout memlayout = MemoryLayout::ColumnMajor )
inline

constructors from batch size, depth, height*width

Definition at line 62 of file CpuTensor.h.

◆ TCpuTensor() [4/8]

template<typename AFloat>
TMVA::DNN::TCpuTensor< AFloat >::TCpuTensor ( size_t bsize,
size_t depth,
size_t height,
size_t width,
MemoryLayout memlayout = MemoryLayout::ColumnMajor )
inline

constructors from batch size, depth, height, width

Definition at line 70 of file CpuTensor.h.

◆ TCpuTensor() [5/8]

template<typename AFloat>
TMVA::DNN::TCpuTensor< AFloat >::TCpuTensor ( Shape_t shape,
MemoryLayout memlayout = MemoryLayout::ColumnMajor )
inline

constructors from a shape.

Definition at line 80 of file CpuTensor.h.

◆ TCpuTensor() [6/8]

template<typename AFloat>
TMVA::DNN::TCpuTensor< AFloat >::TCpuTensor ( AFloat * data,
const Shape_t & shape,
MemoryLayout memlayout = MemoryLayout::ColumnMajor )
inline

Definition at line 87 of file CpuTensor.h.

◆ TCpuTensor() [7/8]

template<typename AFloat>
TMVA::DNN::TCpuTensor< AFloat >::TCpuTensor ( const TCpuBuffer< AFloat > & buffer,
Shape_t shape,
MemoryLayout memlayout = MemoryLayout::ColumnMajor )
inline

constructors from a TCpuBuffer and a shape

Definition at line 99 of file CpuTensor.h.

◆ TCpuTensor() [8/8]

template<typename AFloat>
TMVA::DNN::TCpuTensor< AFloat >::TCpuTensor ( const TCpuMatrix< AFloat > & matrix,
size_t dim = 3,
MemoryLayout memlayout = MemoryLayout::ColumnMajor )
inline

constructors from a TCpuMatrix.

Memory layout is forced to be same as matrix (i.e. columnlayout)

Definition at line 108 of file CpuTensor.h.

Member Function Documentation

◆ At() [1/2]

template<typename AFloat>
TCpuTensor< AFloat > TMVA::DNN::TCpuTensor< AFloat >::At ( size_t i)
inline

Definition at line 221 of file CpuTensor.h.

◆ At() [2/2]

template<typename AFloat>
TCpuTensor< AFloat > TMVA::DNN::TCpuTensor< AFloat >::At ( size_t i) const
inline

Definition at line 234 of file CpuTensor.h.

◆ begin()

Iterator TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::begin ( )
inlinenoexceptinherited

Definition at line 306 of file RTensor.hxx.

◆ Copy()

RTensor< Value_t, Container_t > TMVA::Experimental::RTensor< Value_t, Container_t >::Copy ( MemoryLayout layout = MemoryLayout::RowMajor) const
inlineinherited

Copy RTensor to new object.

Parameters
[in]layoutMemory layout of the new RTensor
Returns
New RTensor The operation copies all elements of the current RTensor to a new RTensor with the given layout contiguous in memory. Note that this copies by default to a row major memory layout.

Definition at line 254 of file RTensor.hxx.

◆ end()

Iterator TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::end ( )
inlinenoexceptinherited

Definition at line 309 of file RTensor.hxx.

◆ ExpandDims()

RTensor< Value_t, Container_t > TMVA::Experimental::RTensor< Value_t, Container_t >::ExpandDims ( int idx) const
inlineinherited

Expand dimensions.

Parameters
[in]idxIndex in shape vector where dimension is added
Returns
New RTensor Inserts a dimension of one into the shape.

Definition at line 259 of file RTensor.hxx.

◆ GetBufferUseCount()

template<typename AFloat>
size_t TMVA::DNN::TCpuTensor< AFloat >::GetBufferUseCount ( ) const
inline

Definition at line 300 of file CpuTensor.h.

◆ GetContainer() [1/2]

std::shared_ptr< Container_t > TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::GetContainer ( )
inlineinherited

Definition at line 247 of file RTensor.hxx.

◆ GetContainer() [2/2]

const std::shared_ptr< Container_t > TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::GetContainer ( ) const
inlineinherited

Definition at line 248 of file RTensor.hxx.

◆ GetCSize()

template<typename AFloat>
size_t TMVA::DNN::TCpuTensor< AFloat >::GetCSize ( ) const
inline

Definition at line 161 of file CpuTensor.h.

◆ GetData() [1/2]

Value_t * TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::GetData ( )
inlineinherited

Definition at line 245 of file RTensor.hxx.

◆ GetData() [2/2]

const Value_t * TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::GetData ( ) const
inlineinherited

Definition at line 246 of file RTensor.hxx.

◆ GetDeviceBuffer() [1/2]

template<typename AFloat>
TCpuBuffer< AFloat > & TMVA::DNN::TCpuTensor< AFloat >::GetDeviceBuffer ( )
inline

Definition at line 146 of file CpuTensor.h.

◆ GetDeviceBuffer() [2/2]

template<typename AFloat>
const TCpuBuffer< AFloat > & TMVA::DNN::TCpuTensor< AFloat >::GetDeviceBuffer ( ) const
inline

Definition at line 145 of file CpuTensor.h.

◆ GetFirstSize()

template<typename AFloat>
size_t TMVA::DNN::TCpuTensor< AFloat >::GetFirstSize ( ) const
inline

Definition at line 155 of file CpuTensor.h.

◆ GetHSize()

template<typename AFloat>
size_t TMVA::DNN::TCpuTensor< AFloat >::GetHSize ( ) const
inline

Definition at line 168 of file CpuTensor.h.

◆ GetLayout()

template<typename AFloat>
MemoryLayout TMVA::DNN::TCpuTensor< AFloat >::GetLayout ( ) const
inline

Definition at line 194 of file CpuTensor.h.

◆ GetMatrix()

template<typename AFloat>
TCpuMatrix< AFloat > TMVA::DNN::TCpuTensor< AFloat >::GetMatrix ( ) const
inline

Definition at line 197 of file CpuTensor.h.

◆ GetMemoryLayout()

MemoryLayout TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::GetMemoryLayout ( ) const
inlineinherited

Definition at line 249 of file RTensor.hxx.

◆ GetNcols()

template<typename AFloat>
size_t TMVA::DNN::TCpuTensor< AFloat >::GetNcols ( ) const
inline

Definition at line 191 of file CpuTensor.h.

◆ GetNoElements()

template<typename AFloat>
size_t TMVA::DNN::TCpuTensor< AFloat >::GetNoElements ( ) const
inline

Definition at line 149 of file CpuTensor.h.

◆ GetNrows()

template<typename AFloat>
size_t TMVA::DNN::TCpuTensor< AFloat >::GetNrows ( ) const
inline

Definition at line 190 of file CpuTensor.h.

◆ GetRawDataPointer() [1/2]

template<typename AFloat>
AFloat * TMVA::DNN::TCpuTensor< AFloat >::GetRawDataPointer ( )
inline

Return raw pointer to the elements stored contiguously in column-major order.

Definition at line 141 of file CpuTensor.h.

◆ GetRawDataPointer() [2/2]

template<typename AFloat>
const AFloat * TMVA::DNN::TCpuTensor< AFloat >::GetRawDataPointer ( ) const
inline

Definition at line 142 of file CpuTensor.h.

◆ GetShape()

const Shape_t & TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::GetShape ( ) const
inlineinherited

Definition at line 243 of file RTensor.hxx.

◆ GetSize()

std::size_t TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::GetSize ( ) const
inlineinherited

Definition at line 242 of file RTensor.hxx.

◆ GetStrides()

const Shape_t & TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::GetStrides ( ) const
inlineinherited

Definition at line 244 of file RTensor.hxx.

◆ GetWSize()

template<typename AFloat>
size_t TMVA::DNN::TCpuTensor< AFloat >::GetWSize ( ) const
inline

Definition at line 177 of file CpuTensor.h.

◆ IsOwner()

bool TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::IsOwner ( ) const
inlineinherited

Definition at line 251 of file RTensor.hxx.

◆ IsView()

bool TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::IsView ( ) const
inlineinherited

Definition at line 250 of file RTensor.hxx.

◆ Map()

template<typename AFloat>
template<typename Function_t>
void TMVA::DNN::TCpuTensor< AFloat >::Map ( Function_t & f)
inline

Map the given function over the matrix elements.

Executed in parallel using TThreadExecutor.

Definition at line 325 of file CpuTensor.h.

◆ MapFrom()

template<typename AFloat>
template<typename Function_t>
void TMVA::DNN::TCpuTensor< AFloat >::MapFrom ( Function_t & f,
const TCpuTensor< AFloat > & A )
inline

Same as maps but takes the input values from the tensor A and writes the results in this tensor.

Definition at line 354 of file CpuTensor.h.

◆ operator TMatrixT< AFloat >()

template<typename AFloat>
TMVA::DNN::TCpuTensor< AFloat >::operator TMatrixT< AFloat > ( ) const
inline

Convert to a TMatrixT<AFloat_t> object.

Performs a deep copy of the matrix elements.

Definition at line 128 of file CpuTensor.h.

◆ operator()() [1/8]

template<typename AFloat>
AFloat & TMVA::DNN::TCpuTensor< AFloat >::operator() ( size_t i,
size_t j )
inline

Definition at line 251 of file CpuTensor.h.

◆ operator()() [2/8]

template<typename AFloat>
AFloat TMVA::DNN::TCpuTensor< AFloat >::operator() ( size_t i,
size_t j ) const
inline

Definition at line 272 of file CpuTensor.h.

◆ operator()() [3/8]

template<typename AFloat>
AFloat & TMVA::DNN::TCpuTensor< AFloat >::operator() ( size_t i,
size_t j,
size_t k )
inline

Definition at line 261 of file CpuTensor.h.

◆ operator()() [4/8]

template<typename AFloat>
AFloat TMVA::DNN::TCpuTensor< AFloat >::operator() ( size_t i,
size_t j,
size_t k ) const
inline

Definition at line 280 of file CpuTensor.h.

◆ operator()() [5/8]

Value_t & TMVA::Experimental::RTensor< Value_t, Container_t >::operator() ( const Index_t & idx)
inlineinherited

Access elements.

Parameters
[in]idxIndex vector
Returns
Reference to element

Definition at line 236 of file RTensor.hxx.

◆ operator()() [6/8]

const Value_t & TMVA::Experimental::RTensor< Value_t, Container_t >::operator() ( const Index_t & idx) const
inlineinherited

Access elements.

Parameters
[in]idxIndex vector
Returns
Reference to element

Definition at line 237 of file RTensor.hxx.

◆ operator()() [7/8]

Value_t & TMVA::Experimental::RTensor< Value_t, Container_t >::operator() ( Idx... idx)
inherited

Access elements.

Parameters
[in]idxIndices
Returns
Reference to element

Definition at line 238 of file RTensor.hxx.

◆ operator()() [8/8]

const Value_t & TMVA::Experimental::RTensor< Value_t, Container_t >::operator() ( Idx... idx) const
inherited

Access elements.

Parameters
[in]idxIndices
Returns
Reference to element

Definition at line 239 of file RTensor.hxx.

◆ operator[]()

template<typename AFloat>
TCpuMatrix< AFloat > TMVA::DNN::TCpuTensor< AFloat >::operator[] ( size_t i) const
inline

Definition at line 237 of file CpuTensor.h.

◆ Print()

template<typename AFloat>
void TMVA::DNN::TCpuTensor< AFloat >::Print ( const char * name = "Tensor") const
inline

Definition at line 302 of file CpuTensor.h.

◆ PrintShape()

template<typename AFloat>
void TMVA::DNN::TCpuTensor< AFloat >::PrintShape ( const char * name = "Tensor") const
inline

Definition at line 310 of file CpuTensor.h.

◆ Reshape() [1/2]

template<typename AFloat>
TCpuTensor< AFloat > TMVA::DNN::TCpuTensor< AFloat >::Reshape ( Shape_t shape) const
inline

Definition at line 212 of file CpuTensor.h.

◆ Reshape() [2/2]

Reshape tensor.

Parameters
[in]shapeShape vector
Returns
New RTensor Reshape tensor without changing the overall size

Definition at line 260 of file RTensor.hxx.

◆ ReshapeInplace()

void TMVA::Experimental::RTensor< Value_t, Container_t >::ReshapeInplace ( const Shape_t & shape)
inlineprotectedinherited

Reshape tensor in place.

Parameters
[in]shapeShape vector Reshape tensor without changing the overall size

Definition at line 181 of file RTensor.hxx.

◆ Resize()

RTensor< Value_t, Container_t > TMVA::Experimental::RTensor< Value_t, Container_t >::Resize ( const Shape_t & shape)
inlineinherited

Resize tensor.

Parameters
[in]shapeShape vector
Returns
New RTensor Resize tensor into new shape

Definition at line 261 of file RTensor.hxx.

◆ Slice()

RTensor< Value_t, Container_t > TMVA::Experimental::RTensor< Value_t, Container_t >::Slice ( const Slice_t & slice)
inlineinherited

Create a slice of the tensor.

Parameters
[in]sliceSlice vector
Returns
New RTensor A slice is a subset of the tensor defined by a vector of pairs of indices.

Definition at line 262 of file RTensor.hxx.

◆ Squeeze()

RTensor< Value_t, Container_t > TMVA::Experimental::RTensor< Value_t, Container_t >::Squeeze ( ) const
inlineinherited

Squeeze dimensions.

Returns
New RTensor Squeeze removes the dimensions of size one from the shape.

Definition at line 258 of file RTensor.hxx.

◆ Transpose()

RTensor< Value_t, Container_t > TMVA::Experimental::RTensor< Value_t, Container_t >::Transpose ( ) const
inlineinherited

Transpose.

Returns
New RTensor The tensor is transposed by inverting the associated memory layout from row- major to column-major and vice versa. Therefore, the underlying data is not touched.

Definition at line 257 of file RTensor.hxx.

◆ Zero()

template<typename AFloat>
void TMVA::DNN::TCpuTensor< AFloat >::Zero ( )
inline

Definition at line 243 of file CpuTensor.h.

◆ TCpuMatrix< AFloat >

template<typename AFloat>
friend class TCpuMatrix< AFloat >
friend

Definition at line 354 of file CpuTensor.h.

Member Data Documentation

◆ fContainer

std::shared_ptr<Container_t> TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::fContainer
privateinherited

Definition at line 178 of file RTensor.hxx.

◆ fData

Value_t* TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::fData
privateinherited

Definition at line 177 of file RTensor.hxx.

◆ fLayout

MemoryLayout TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::fLayout
privateinherited

Definition at line 176 of file RTensor.hxx.

◆ fShape

Shape_t TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::fShape
privateinherited

Definition at line 173 of file RTensor.hxx.

◆ fSize

std::size_t TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::fSize
privateinherited

Definition at line 175 of file RTensor.hxx.

◆ fStrides

Shape_t TMVA::Experimental::RTensor< AFloat, TCpuBuffer< AFloat > >::fStrides
privateinherited

Definition at line 174 of file RTensor.hxx.


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