Tenncor
Public Member Functions | Public Attributes | Private Member Functions | List of all members
PrettyTensor< T > Struct Template Referencefinal

Draw data as a multi-dimension array (similar to python) according to shape. More...

#include <tensor.hpp>

Public Member Functions

 PrettyTensor (std::vector< uint16_t > datalimit)
 
void print (std::ostream &out, T *arr, std::vector< uint8_t > shape)
 

Public Attributes

std::vector< uint16_t > datalimit_
 Number of elements to show for each dimension. More...
 

Private Member Functions

void print_helper (std::ostream &out, const std::vector< uint8_t > &shape, T *arr, uint8_t rank)
 

Detailed Description

template<typename T>
struct PrettyTensor< T >

Draw data as a multi-dimension array (similar to python) according to shape.

tensor.hpp dbg

Purpose: Draw tensor data in python-array format

Constructor & Destructor Documentation

◆ PrettyTensor()

template<typename T >
PrettyTensor< T >::PrettyTensor ( std::vector< uint16_t >  datalimit)
inline

Datalimit represents the maximum number of elements to print for each dimension corresponding to datalimit's index For example: given datalimit={5, 4, 3, 2}, print will only display at most 5 elements of the first dimension, at most 4 of the second, etc. beyond the first four dimensions, printing will display as many elements as there are

Member Function Documentation

◆ print()

template<typename T >
void PrettyTensor< T >::print ( std::ostream &  out,
T *  arr,
std::vector< uint8_t >  shape 
)
inline

Given the output stream, flattened tensor data, and the shape, wrap square brackets around each dimension in the tensor and stream to out For example: given arr={1, 2, 3, 4}, shape={2, 2}, print will stream [[1, 2], [3, 4]] to out

◆ print_helper()

template<typename T >
void PrettyTensor< T >::print_helper ( std::ostream &  out,
const std::vector< uint8_t > &  shape,
T *  arr,
uint8_t  rank 
)
inlineprivate

Member Data Documentation

◆ datalimit_

template<typename T >
std::vector<uint16_t> PrettyTensor< T >::datalimit_

Number of elements to show for each dimension.


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