RTensor is a container with contiguous memory and shape information.
T | Data-type of the tensor |
An RTensor is a vector-like container, which has additional shape information. The elements of the multi-dimensional container can be accessed by their indices in a coherent way without taking care about the one-dimensional memory layout of the contiguous storage. This also allows to manipulate the shape of the container without moving the actual elements in memory. Another feature is that an RTensor can own the underlying contiguous memory but can also represent only a view on existing data without owning it.
Definition at line 162 of file RTensor.hxx.
Classes | |
class | Iterator |
Public Types | |
using | Container_t = C |
using | Index_t = Shape_t |
using | Shape_t = std::vector< std::size_t > |
using | Slice_t = std::vector< Shape_t > |
using | Value_t = V |
Public Member Functions | |
RTensor (Shape_t shape, MemoryLayout layout=MemoryLayout::RowMajor) | |
Construct a tensor owning data initialized with new container. More... | |
RTensor (std::shared_ptr< Container_t > container, Shape_t shape, MemoryLayout layout=MemoryLayout::RowMajor) | |
Construct a tensor owning externally provided data. More... | |
RTensor (Value_t *data, Shape_t shape, MemoryLayout layout=MemoryLayout::RowMajor) | |
Construct a tensor as view on data. More... | |
RTensor (Value_t *data, Shape_t shape, Shape_t strides, MemoryLayout layout=MemoryLayout::RowMajor) | |
Construct a tensor as view on data. More... | |
Iterator | begin () noexcept |
RTensor< Value_t, Container_t > | Copy (MemoryLayout layout=MemoryLayout::RowMajor) |
Copy RTensor to new object. More... | |
Iterator | end () noexcept |
RTensor< Value_t, Container_t > | ExpandDims (int idx) |
Expand dimensions. More... | |
std::shared_ptr< Container_t > | GetContainer () |
const std::shared_ptr< Container_t > | GetContainer () const |
Value_t * | GetData () |
const Value_t * | GetData () const |
MemoryLayout | GetMemoryLayout () const |
const Shape_t & | GetShape () const |
std::size_t | GetSize () const |
const Shape_t & | GetStrides () const |
bool | IsOwner () const |
bool | IsView () const |
Value_t & | operator() (const Index_t &idx) |
Access elements. More... | |
const Value_t & | operator() (const Index_t &idx) const |
Access elements. More... | |
template<typename... Idx> | |
Value_t & | operator() (Idx... idx) |
Access elements. More... | |
template<typename... Idx> | |
const Value_t & | operator() (Idx... idx) const |
Access elements. More... | |
RTensor< Value_t, Container_t > | Reshape (const Shape_t &shape) |
Reshape tensor. More... | |
RTensor< Value_t, Container_t > | Slice (const Slice_t &slice) |
Create a slice of the tensor. More... | |
RTensor< Value_t, Container_t > | Squeeze () |
Squeeze dimensions. More... | |
RTensor< Value_t, Container_t > | Transpose () |
Transpose. More... | |
Protected Member Functions | |
void | ReshapeInplace (const Shape_t &shape) |
Reshape tensor in place. More... | |
Private Attributes | |
std::shared_ptr< Container_t > | fContainer |
Value_t * | fData |
MemoryLayout | fLayout |
Shape_t | fShape |
std::size_t | fSize |
Shape_t | fStrides |
#include <TMVA/RTensor.hxx>
using TMVA::Experimental::RTensor< V, C >::Container_t = C |
Definition at line 169 of file RTensor.hxx.
using TMVA::Experimental::RTensor< V, C >::Index_t = Shape_t |
Definition at line 167 of file RTensor.hxx.
using TMVA::Experimental::RTensor< V, C >::Shape_t = std::vector<std::size_t> |
Definition at line 166 of file RTensor.hxx.
using TMVA::Experimental::RTensor< V, C >::Slice_t = std::vector<Shape_t> |
Definition at line 168 of file RTensor.hxx.
using TMVA::Experimental::RTensor< V, C >::Value_t = V |
Definition at line 165 of file RTensor.hxx.
|
inline |
Construct a tensor as view on data.
[in] | data | Pointer to data contiguous in memory |
[in] | shape | Shape vector |
[in] | layout | Memory layout |
Definition at line 189 of file RTensor.hxx.
|
inline |
Construct a tensor as view on data.
[in] | data | Pointer to data contiguous in memory |
[in] | shape | Shape vector |
[in] | strides | Strides vector |
[in] | layout | Memory layout |
Definition at line 201 of file RTensor.hxx.
|
inline |
Construct a tensor owning externally provided data.
[in] | container | Shared pointer to data container |
[in] | shape | Shape vector |
[in] | layout | Memory layout |
Definition at line 211 of file RTensor.hxx.
|
inline |
Construct a tensor owning data initialized with new container.
[in] | shape | Shape vector |
[in] | layout | Memory layout |
Definition at line 223 of file RTensor.hxx.
|
inlinenoexcept |
Definition at line 300 of file RTensor.hxx.
|
inline |
Copy RTensor to new object.
[in] | layout | Memory layout of the new RTensor |
Definition at line 542 of file RTensor.hxx.
|
inlinenoexcept |
Definition at line 303 of file RTensor.hxx.
|
inline |
Expand dimensions.
[in] | idx | Index in shape vector where dimension is added |
Definition at line 444 of file RTensor.hxx.
|
inline |
Definition at line 246 of file RTensor.hxx.
|
inline |
Definition at line 247 of file RTensor.hxx.
|
inline |
Definition at line 244 of file RTensor.hxx.
|
inline |
Definition at line 245 of file RTensor.hxx.
|
inline |
Definition at line 248 of file RTensor.hxx.
|
inline |
Definition at line 242 of file RTensor.hxx.
|
inline |
Definition at line 241 of file RTensor.hxx.
|
inline |
Definition at line 243 of file RTensor.hxx.
|
inline |
Definition at line 250 of file RTensor.hxx.
|
inline |
Definition at line 249 of file RTensor.hxx.
|
inline |
Access elements.
[in] | idx | Index vector |
Definition at line 339 of file RTensor.hxx.
|
inline |
Access elements.
[in] | idx | Index vector |
Definition at line 349 of file RTensor.hxx.
Value_t & TMVA::Experimental::RTensor< Value_t, Container_t >::operator() | ( | Idx... | idx | ) |
Access elements.
[in] | idx | Indices |
Definition at line 360 of file RTensor.hxx.
const Value_t & TMVA::Experimental::RTensor< Value_t, Container_t >::operator() | ( | Idx... | idx | ) | const |
Access elements.
[in] | idx | Indices |
Definition at line 372 of file RTensor.hxx.
|
inline |
Reshape tensor.
[in] | shape | Shape vector |
Definition at line 476 of file RTensor.hxx.
|
inlineprotected |
Reshape tensor in place.
[in] | shape | Shape vector Reshape tensor without changing the overall size |
Definition at line 312 of file RTensor.hxx.
|
inline |
Create a slice of the tensor.
[in] | slice | Slice vector |
Definition at line 489 of file RTensor.hxx.
|
inline |
Squeeze dimensions.
Definition at line 412 of file RTensor.hxx.
|
inline |
Transpose.
Definition at line 385 of file RTensor.hxx.
|
private |
Definition at line 177 of file RTensor.hxx.
|
private |
Definition at line 176 of file RTensor.hxx.
|
private |
Definition at line 175 of file RTensor.hxx.
|
private |
Definition at line 172 of file RTensor.hxx.
|
private |
Definition at line 174 of file RTensor.hxx.
|
private |
Definition at line 173 of file RTensor.hxx.