mxnet
Public Member Functions | List of all members
mxnet::TensorInspector Class Reference

This class provides a unified interface to inspect the value of all data types including Tensor, TBlob, and NDArray. If the tensor resides on GPU, then it will be copied from GPU memory back to CPU memory to be operated on. Internally, all data types are stored as a TBlob object tb_. More...

#include <tensor_inspector.h>

Collaboration diagram for mxnet::TensorInspector:
Collaboration graph

Public Member Functions

template<typename Device , int dimension, typename DType >
 TensorInspector (const mshadow::Tensor< Device, dimension, DType > &ts, const RunContext &ctx)
 construct from Tensor object More...
 
 TensorInspector (const TBlob &tb, const RunContext &ctx)
 construct from TBlob object More...
 
 TensorInspector (const NDArray &arr, const RunContext &ctx)
 construct from NDArray object. Currently this only works with kDefaultStorage More...
 
void print_string ()
 print the tensor to std::cout More...
 
std::string to_string ()
 return a string which contains the values and other info of the tensor More...
 
void interactive_print (std::string tag="")
 interactively print the tensor value More...
 
template<typename ValueChecker >
std::vector< std::vector< index_t > > check_value (const ValueChecker &checker, bool interactive=false, std::string tag="")
 check/validate the values within the tensor, return the coordinates where the value checker evaluates to true More...
 
std::vector< std::vector< index_t > > check_value (CheckerType ct, bool interactive=false, std::string tag="")
 check/validate the values within the tensor, return the coordinates where the lambda evaluates to true More...
 
void dump_to_file (std::string tag)
 dump the value of the tensor to a file with name "tag_[visit count].npy" in npy format More...
 

Detailed Description

This class provides a unified interface to inspect the value of all data types including Tensor, TBlob, and NDArray. If the tensor resides on GPU, then it will be copied from GPU memory back to CPU memory to be operated on. Internally, all data types are stored as a TBlob object tb_.


|__ __| |_ _| | | | | ___ _ __ ___ ___ _ __| | _ __ ___ _ __ ___ ___| |_ ___ _ __ | |/ _ \ '_ \/ __|/ _ | '__| | | '_ \/ __| '_ \ / _ \/ __| __/ _ | '__| | | __/ | | __ \ (_) | | _| |_| | | __ \ |_) | __/ (__| || (_) | | |_|___|_| |_|___/___/|_||_____|_| |_|___/ .__/ ___|___|_____/|_| | | |_|

Constructor & Destructor Documentation

template<typename Device , int dimension, typename DType >
mxnet::TensorInspector::TensorInspector ( const mshadow::Tensor< Device, dimension, DType > &  ts,
const RunContext ctx 
)
inline

construct from Tensor object

Template Parameters
Devicethe device the tensor resides in
dimensionthe dimension of the tensor
DTypethe data type
Parameters
tsthe source tensor object
ctxthe run context of the tensor
mxnet::TensorInspector::TensorInspector ( const TBlob tb,
const RunContext ctx 
)
inline

construct from TBlob object

Parameters
tbthe source tblob object
ctxthe run context of the tensor
mxnet::TensorInspector::TensorInspector ( const NDArray arr,
const RunContext ctx 
)
inline

construct from NDArray object. Currently this only works with kDefaultStorage

Parameters
arrthe source ndarray object
ctxthe run context of the tensor

Member Function Documentation

template<typename ValueChecker >
std::vector<std::vector<index_t> > mxnet::TensorInspector::check_value ( const ValueChecker &  checker,
bool  interactive = false,
std::string  tag = "" 
)
inline

check/validate the values within the tensor, return the coordinates where the value checker evaluates to true

Template Parameters
ValueCheckerthe type of the lambda
Parameters
checkerthe lambda function to check each value of within the tensor
interactivewherether to allow the user to interactively check the coordinates
tagthe name given to this call
std::vector<std::vector<index_t> > mxnet::TensorInspector::check_value ( CheckerType  ct,
bool  interactive = false,
std::string  tag = "" 
)
inline

check/validate the values within the tensor, return the coordinates where the lambda evaluates to true

Parameters
ctthe type of the checker
interactivewherether to allow the user to interactively check the coordinates
tagthe name given to this call
void mxnet::TensorInspector::dump_to_file ( std::string  tag)
inline

dump the value of the tensor to a file with name "tag_[visit count].npy" in npy format

Parameters
tagthe name given to this call
void mxnet::TensorInspector::interactive_print ( std::string  tag = "")
inline

interactively print the tensor value

Parameters
tagthe name given to this call
void mxnet::TensorInspector::print_string ( )
inline

print the tensor to std::cout

std::string mxnet::TensorInspector::to_string ( )
inline

return a string which contains the values and other info of the tensor


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