ONE - On-device Neural Engine
Loading...
Searching...
No Matches
moco::TensorName Struct Referencefinal

#include <Names.h>

Public Member Functions

 TensorName (const std::string &tensor_name)
 Constructor.
 
 TensorName (const std::string &node_name, const int tensor_index)
 
const std::string & name () const
 
const std::string nodeName () const
 Returns node name from tensor name by removing, e.g., ":0".
 

Detailed Description

Definition at line 26 of file Names.h.

Constructor & Destructor Documentation

◆ TensorName() [1/2]

moco::TensorName::TensorName ( const std::string &  tensor_name)
inlineexplicit

Constructor.

Note
If tensor_name does not have ":index", this constructor adds ":0" by default

Definition at line 34 of file Names.h.

35 {
36 if (tensor_name.find(":") != std::string::npos) // tensor_name is a form of letter:0
37 {
38 _name.assign(tensor_name);
39 }
40 else
41 {
42 _name.assign(tensor_name + ":0"); // if it does not have ":index", adds ":0" by default
43 }
44 }
const char * tensor_name(const circle::Tensor *tensor)

◆ TensorName() [2/2]

moco::TensorName::TensorName ( const std::string &  node_name,
const int  tensor_index 
)
inlineexplicit

Definition at line 46 of file Names.h.

47 {
48 if (node_name.find(":") != std::string::npos) // tensor_name is already a form of name:0
49 {
50 // TODO including oops will make oops dependent to modules that include this
51 // postpone decision to this or not
52 throw std::runtime_error("Error: Node name has already tensor index:" + node_name);
53 }
54 else
55 {
56 _name.assign(node_name + ":" + std::to_string(tensor_index));
57 }
58 }

Member Function Documentation

◆ name()

const std::string & moco::TensorName::name ( ) const
inline

Definition at line 60 of file Names.h.

60{ return _name; }

Referenced by main(), and moco::TensorNameCompare::operator()().

◆ nodeName()

const std::string moco::TensorName::nodeName ( ) const
inline

Returns node name from tensor name by removing, e.g., ":0".

Definition at line 65 of file Names.h.

66 {
67 auto index = _name.find(":");
68
69 if (index != std::string::npos)
70 return _name.substr(0, index);
71 else
72 {
73 // TODO including oops will make oops dependent to modules that include this
74 // postpone decision to this or not
75 throw std::runtime_error{"Error: Tensor name should be a 'name:number' format: " + _name};
76 }
77 };
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

References moco::index().


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