ONE - On-device Neural Engine
Loading...
Searching...
No Matches
mpqsolver::bisection Namespace Reference

Data Structures

class  BisectionSolver
 
class  VISQErrorApproximator
 

Typedefs

using NodeDepthType = std::map< luci::CircleNode *, float >
 

Enumerations

enum class  ParameterizerResult : int32_t { SUCCESS = 0 , FAILURE = 1 }
 status of parameterization More...
 

Functions

ParameterizerResult compute_depth (const luci::Module *module, NodeDepthType &nodes_depth, float &min_depth, float &max_depth)
 compute maximal distance from graph inputs to graph nodes along with min/max values of distance and return status of computation (Assumes graph has no cycles)
 

Typedef Documentation

◆ NodeDepthType

using mpqsolver::bisection::NodeDepthType = typedef std::map<luci::CircleNode *, float>

Definition at line 28 of file DepthParameterizer.h.

Enumeration Type Documentation

◆ ParameterizerResult

enum class mpqsolver::bisection::ParameterizerResult : int32_t
strong

status of parameterization

Enumerator
SUCCESS 
FAILURE 

Definition at line 33 of file DepthParameterizer.h.

Function Documentation

◆ compute_depth()

ParameterizerResult mpqsolver::bisection::compute_depth ( const luci::Module module,
NodeDepthType nodes_depth,
float &  min_depth,
float &  max_depth 
)

compute maximal distance from graph inputs to graph nodes along with min/max values of distance and return status of computation (Assumes graph has no cycles)

compute maximal distance from graph inputs to graph nodes along with min/max values of distance and return status of compuation (success/failure)

Definition at line 28 of file DepthParameterizer.cpp.

30{
31 if (module == nullptr)
32 return ParameterizerResult::FAILURE;
33
34 if (module->size() != 1)
35 return ParameterizerResult::FAILURE;
36
37 auto graph = module->graph(0);
38 if (!graph)
39 return ParameterizerResult::FAILURE;
40
41 // initializing
42 std::vector<luci::CircleNode *> to_process;
43 std::map<std::string, float> named_depth;
44 {
45 auto inputs = loco::input_nodes(graph);
46 for (auto &node : inputs)
47 {
48 auto cnode = loco::must_cast<luci::CircleNode *>(node);
49 to_process.emplace_back(cnode);
50 nodes_depth[cnode] = 0.f;
51 named_depth[cnode->name()] = 0.f;
52 }
53 }
54
55 // enumerating
56 while (!to_process.empty())
57 {
58 auto cur_node = to_process.back();
59 to_process.pop_back();
60 auto iter = nodes_depth.find(cur_node);
61 if (iter == nodes_depth.end())
62 {
63 return ParameterizerResult::FAILURE; // unexpected
64 }
65 float cur_depth = iter->second + 1;
66 // processing children
67 auto children = loco::succs(cur_node);
68 for (auto &child : children)
69 {
70 auto cichild = loco::must_cast<luci::CircleNode *>(child);
71 auto node_depth = nodes_depth.find(cichild);
72 if (node_depth == nodes_depth.end() || node_depth->second < cur_depth)
73 {
74 // initialize depth
75 nodes_depth[cichild] = cur_depth;
76 to_process.push_back(cichild);
77 named_depth[cichild->name()] = cur_depth;
78 }
79 }
80 }
81
82 // compute min/max of depth parameter
83 auto minmax = std::minmax_element(
84 nodes_depth.begin(), nodes_depth.end(),
85 [=](const std::pair<luci::CircleNode *, float> &el1,
86 const std::pair<luci::CircleNode *, float> &el2) { return el1.second < el2.second; });
87
88 min_depth = minmax.first->second;
89 max_depth = minmax.second->second;
90
91 return ParameterizerResult::SUCCESS;
92}
std::set< Node * > succs(const Node *node)
Enumerate all the successors of a given node.
Definition Node.cpp:46
std::vector< Node * > input_nodes(const Graph *)
Definition Graph.cpp:71

References FAILURE, loco::input_nodes(), SUCCESS, and loco::succs().

Referenced by mpqsolver::bisection::BisectionSolver::run().