ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnkit::support::tftestinfo::ParsedTensor Class Referencefinal

Class to store tensor information parsed from test.info file under moco/test/tf. More...

#include <ParsedTensor.h>

Public Types

enum class  Kind { Input , Output }
 

Public Member Functions

 ParsedTensor ()=delete
 
 ParsedTensor (const Kind kind, const std::string &name, const DataType &dtype, const std::vector< int32_t > &shape)
 
 ~ParsedTensor ()
 
Kind kind () const
 
const std::string & name ()
 
const nncc::core::ADT::tensor::Shapeshape () const
 
nncc::core::ADT::tensor::Shapemutable_shape ()
 
const DataTypedtype () const
 
std::string nodeName () const
 Get the name of node that has this tensor. E.g., if the name of this tensor is "MyOp:0", this method returns "MyOp".
 
int tensorIndex () const
 Get the index from the tensor name. E.g., if the name of this tensor is "MyOp:12", this method returns 12.
 
bool isFloatTensor () const
 
bool hasShape () const
 

Detailed Description

Class to store tensor information parsed from test.info file under moco/test/tf.

Definition at line 47 of file ParsedTensor.h.

Member Enumeration Documentation

◆ Kind

Constructor & Destructor Documentation

◆ ParsedTensor() [1/2]

nnkit::support::tftestinfo::ParsedTensor::ParsedTensor ( )
delete

◆ ParsedTensor() [2/2]

nnkit::support::tftestinfo::ParsedTensor::ParsedTensor ( const Kind  kind,
const std::string &  name,
const DataType dtype,
const std::vector< int32_t > &  shape 
)
inline

Definition at line 58 of file ParsedTensor.h.

60 : _kind(kind), _dtype(dtype)
61 {
62 _tensor_name.assign(name);
63
64 _shape.resize(shape.size());
65 for (int rank = 0; rank < shape.size(); rank++)
66 _shape.dim(rank) = shape.at(rank);
67 }
uint32_t & dim(uint32_t axis)
Definition Shape.cpp:42
Shape & resize(uint32_t size)
Definition Shape.cpp:36
const nncc::core::ADT::tensor::Shape & shape() const

References nncc::core::ADT::tensor::Shape::dim(), name(), nncc::core::ADT::tensor::Shape::resize(), and shape().

◆ ~ParsedTensor()

nnkit::support::tftestinfo::ParsedTensor::~ParsedTensor ( )
inline

Definition at line 69 of file ParsedTensor.h.

70 { /* empty */
71 }

Member Function Documentation

◆ dtype()

const DataType & nnkit::support::tftestinfo::ParsedTensor::dtype ( ) const
inline

Definition at line 83 of file ParsedTensor.h.

83{ return _dtype; }

◆ hasShape()

bool nnkit::support::tftestinfo::ParsedTensor::hasShape ( ) const
inline

Definition at line 108 of file ParsedTensor.h.

108{ return _has_shape; }

◆ isFloatTensor()

bool nnkit::support::tftestinfo::ParsedTensor::isFloatTensor ( ) const
inline

Definition at line 107 of file ParsedTensor.h.

107{ return _dtype == DataType::FLOAT32; }

Referenced by nnkit::support::tf::TensorDataMap::allocate().

◆ kind()

Kind nnkit::support::tftestinfo::ParsedTensor::kind ( ) const
inline

Definition at line 74 of file ParsedTensor.h.

74{ return _kind; }

◆ mutable_shape()

nncc::core::ADT::tensor::Shape & nnkit::support::tftestinfo::ParsedTensor::mutable_shape ( )
inline

Definition at line 81 of file ParsedTensor.h.

81{ return _shape; }

◆ name()

const std::string & nnkit::support::tftestinfo::ParsedTensor::name ( )
inline

Definition at line 76 of file ParsedTensor.h.

76{ return _tensor_name; }

Referenced by ParsedTensor().

◆ nodeName()

std::string nnkit::support::tftestinfo::ParsedTensor::nodeName ( ) const
inline

Get the name of node that has this tensor. E.g., if the name of this tensor is "MyOp:0", this method returns "MyOp".

Definition at line 89 of file ParsedTensor.h.

89{ return _tensor_name.substr(0, _tensor_name.find(":")); }

◆ shape()

◆ tensorIndex()

int nnkit::support::tftestinfo::ParsedTensor::tensorIndex ( ) const
inline

Get the index from the tensor name. E.g., if the name of this tensor is "MyOp:12", this method returns 12.

Definition at line 95 of file ParsedTensor.h.

96 {
97 int separator = _tensor_name.find(":");
98
99 // sanity check
100 if (separator == std::string::npos)
101 throw oops::UserExn("Tensor name in wrong format", "name", _tensor_name);
102
103 return std::stoi(_tensor_name.substr(separator + 1, _tensor_name.length() - separator - 1));
104 }
Exception to user.
Definition UserExn.h:42
const std::string separator()

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