tensor Class Reference

Ratpac-two: cppflow::tensor Class Reference
Ratpac-two
cppflow::tensor Class Reference

A TensorFlow eager tensor wrapper. More...

#include <tensor.h>

Public Member Functions

template<typename T >
 tensor (const std::vector< T > &values, const std::vector< int64_t > &shape)
 
template<typename T >
 tensor (const std::initializer_list< T > &values)
 
template<typename T >
 tensor (const T &value)
 
 tensor (const tensor &tensor)=default
 
 tensor (tensor &&tensor)=default
 
 tensor (TFE_TensorHandle *handle)
 
 tensor (TF_Tensor *t)
 
tensoroperator= (const tensor &other)=default
 
tensoroperator= (tensor &&other)=default
 
tensor shape () const
 
std::string device (bool on_memory=false) const
 
datatype dtype () const
 
template<typename T >
std::vector< T > get_data () const
 
std::shared_ptr< TFE_TensorHandle > get_eager_handle () const
 
std::shared_ptr< TF_Tensor > get_tensor () const
 
template<>
 tensor (const std::string &value)
 

Public Attributes

std::shared_ptr< TFE_TensorHandle > tfe_handle
 

Detailed Description

A TensorFlow eager tensor wrapper.

Constructor & Destructor Documentation

◆ tensor() [1/3]

template<typename T >
cppflow::tensor::tensor ( const std::vector< T > &  values,
const std::vector< int64_t > &  shape 
)

Creates a tensor with the given values and specified shape

Template Parameters
TA type that can be convertible into a tensor
Parameters
valuesThe values to be converted (in a flattened version)
shapeThe shape of the converted tensor

◆ tensor() [2/3]

template<typename T >
cppflow::tensor::tensor ( const std::initializer_list< T > &  values)

Creates a flat tensor with the given values

Template Parameters
TA type that can be convertible into a tensor
Parameters
valuesThe values to be converted

◆ tensor() [3/3]

template<typename T >
cppflow::tensor::tensor ( const T &  value)

Creates a tensor with the given value

Template Parameters
TA type that can be convertible into a tensor
Parameters
valueThe value to be converted

Member Function Documentation

◆ device()

std::string cppflow::tensor::device ( bool  on_memory = false) const
inline
Parameters
on_memoryIf false, the function will return the name of the device that produced the tensor. If true, the function will return the name of the device in whose memory the tensor resides
Returns
Returns the name of the device of the tensor

◆ dtype()

datatype cppflow::tensor::dtype ( ) const
inline
Returns
The tensor datatype

◆ get_data()

template<typename T >
std::vector< T > cppflow::tensor::get_data

Converts the tensor into a C++ vector

Template Parameters
TThe c++ type (must be equivalent to the tensor type)
Returns
A vector representing the flat tensor

◆ shape()

tensor cppflow::tensor::shape ( ) const
inline
Returns
Shape of the tensor

The documentation for this class was generated from the following file:
  • /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/external/cppflow/include/cppflow/tensor.h