Skip to content

Commit

Permalink
[tools/mec] Add pseudo const nodes for const tensors (#14351)
Browse files Browse the repository at this point in the history
The const tensor in circle model are orphan node that doesn't have
source node. So, it adds it as a separate node with special type
'pseudo_const' that is invisible in the the graph but is annotated
at the node which uses it.

ONE-DCO-1.0-Signed-off-by: Jonghwa Lee <[email protected]>
  • Loading branch information
batcheu authored Nov 22, 2024
1 parent f16f951 commit 827ae31
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/model_explorer_circle/src/circle_adapter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ def build_graph(self, me_graph: graph_builder.Graph) -> None:
for i, tensor_id in enumerate(op.outputs):
self.set_source_of(tensor_id=tensor_id, source_id=op_id, output_id=i)

# Create pseudo const node for orphan tensors (= const tensors)
for tensor_id, tensor in enumerate(sub_graph.tensors):
if (self.get_source_of(tensor_id)) is None:
me_node = graph_builder.GraphNode(id=f'{input_id + tensor_id}',
label='pseudo_const',
namespace=tensor.name.decode('utf-8'))
me_graph.nodes.append(me_node)
# Map source and output tensors of const tensor
self.set_source_of(tensor_id=tensor_id,
source_id=input_id + tensor_id,
output_id=0)

# Create operator nodes
for idx, op in enumerate(sub_graph.operators):
name = self.opcode_to_name(
Expand Down

0 comments on commit 827ae31

Please sign in to comment.