const typename GraphT::SubgraphType& sg,
const std::vector<typename GraphT::SubgraphType*>& subgraphs) const {
std::ostringstream output;
- output << "digraph G {\n\
- ";
+ output << "digraph G {\nrankdir=LR\n";
for (const auto& node : sg.getNodes()) {
generateNode(node, sg, output);
}
// Convert a subgraph to dot.
std::string convert(const typename GraphT::SubgraphType& sg) const {
std::ostringstream output;
- output << "digraph G {\n\
- ";
+ output << "digraph G {\nrankdir=LR\n";
for (const auto& node : sg.getNodes()) {
generateNode(node, sg, output);
}
*/
std::string convertStruct(const typename GraphT::SubgraphType& sg) const {
std::ostringstream output;
- output << "digraph G {\n";
+ output << "digraph G {\nrankdir=LR\n";
// Get input nodes (nodes w/o parents)
std::unordered_map<typename GraphT::NodeRef, int>
return shape_info.shape.dims(0);
}
-// Generates AdjustBatchOps for external inputs / outputs with type BATCH or
+// Generates AdjustBatchOps for external inputs/outputs with type BATCH or
// SEQ and adds them to input_ops and output_ops.
-// Meanwhile, modifies inputs / outputs of corresponding operators in the
-// onnxifi_net to use the new inputs / outputs of AdjustBatchOps.
+// Meanwhile, modifies inputs/outputs of corresponding operators in the
+// onnxifi_net to use the new inputs/outputs of AdjustBatchOps.
std::unordered_map<std::string, std::string> AddAdjustBatchOps(
const ShapeInfoMap& shape_hints,
NetDef* onnxifi_net,
net, weights, ws, &exporter2, shape_hints, &shape_hints_onnx);
};
- return opt::OptimizeForBackend(*pred_net, onnx_supports, onnx_converter);
+ return opt::OptimizeForBackend(
+ *pred_net, onnx_supports, onnx_converter, opts_.debug);
}
// Cutting off the runnable part and replace with ONNXIFI ops. Asssume the nets
return ReallyGetOpNode
+def GetBlobNodeProducer(**kwargs):
+ def ReallyGetBlobNode(node_name, label):
+ return pydot.Node(node_name, label=label, **kwargs)
+ return ReallyGetBlobNode
+
def GetPydotGraph(
operators_or_net,
name=None,
rankdir='LR',
- node_producer=None
+ op_node_producer=None,
+ blob_node_producer=None
):
- if node_producer is None:
- node_producer = GetOpNodeProducer(False, **OP_STYLE)
+ if op_node_producer is None:
+ op_node_producer = GetOpNodeProducer(False, **OP_STYLE)
+ if blob_node_producer is None:
+ blob_node_producer = GetBlobNodeProducer(**BLOB_STYLE)
operators, name = _rectify_operator_and_name(operators_or_net, name)
graph = pydot.Dot(name, rankdir=rankdir)
pydot_nodes = {}
pydot_node_counts = defaultdict(int)
for op_id, op in enumerate(operators):
- op_node = node_producer(op, op_id)
+ op_node = op_node_producer(op, op_id)
graph.add_node(op_node)
# print 'Op: %s' % op.name
# print 'inputs: %s' % str(op.input)
# print 'outputs: %s' % str(op.output)
for input_name in op.input:
if input_name not in pydot_nodes:
- input_node = pydot.Node(
+ input_node = blob_node_producer(
_escape_label(
input_name + str(pydot_node_counts[input_name])),
label=_escape_label(input_name),
- **BLOB_STYLE
)
pydot_nodes[input_name] = input_node
else:
if output_name in pydot_nodes:
# we are overwriting an existing blob. need to updat the count.
pydot_node_counts[output_name] += 1
- output_node = pydot.Node(
+ output_node = blob_node_producer(
_escape_label(
output_name + str(pydot_node_counts[output_name])),
label=_escape_label(output_name),
- **BLOB_STYLE
)
pydot_nodes[output_name] = output_node
graph.add_node(output_node)
name=None,
rankdir='LR',
minimal_dependency=False,
- node_producer=None,
+ op_node_producer=None,
):
"""Different from GetPydotGraph, hide all blob nodes and only show op nodes.
op a and b, and op b depends on a, then only the edge b->c will be drawn
because a->c will be implied.
"""
- if node_producer is None:
- node_producer = GetOpNodeProducer(False, **OP_STYLE)
+ if op_node_producer is None:
+ op_node_producer = GetOpNodeProducer(False, **OP_STYLE)
operators, name = _rectify_operator_and_name(operators_or_net, name)
graph = pydot.Dot(name, rankdir=rankdir)
# blob_parents maps each blob name to its generating op.
# op_ancestry records the ancestors of each op.
op_ancestry = defaultdict(set)
for op_id, op in enumerate(operators):
- op_node = node_producer(op, op_id)
+ op_node = op_node_producer(op, op_id)
graph.add_node(op_node)
# Get parents, and set up op ancestry.
parents = [