Skip to content

Commit

Permalink
[tools/mec] Fix to get correct opcode (#14434)
Browse files Browse the repository at this point in the history
It will use builtinCode only when deprecatedBuiltinCode is equal
to 127 (= PLACEHOLDER_FOR_GREATER_OP_CODES).

ONE-DCO-1.0-Signed-off-by: Jonghwa Lee <[email protected]>
  • Loading branch information
batcheu authored Dec 6, 2024
1 parent 2ab2045 commit 1aabefe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/model_explorer_circle/src/model_explorer_circle/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ def load_model(self, model_path: str) -> None:

self.model = circle_schema.ModelT.InitFromObj(model_)

def opcode_to_name(self, opcode: int) -> str:
def get_opcode_name(self, opcode_index: int) -> str:
"""Convert the opcode to its name."""
opcode = self.model.operatorCodes[opcode_index].deprecatedBuiltinCode
if opcode == circle_schema.BuiltinOperator.PLACEHOLDER_FOR_GREATER_OP_CODES:
opcode = self.model.operatorCodes[opcode_index].builtinCode
assert (opcode >= 127)
return self.dict_opcode_to_name[opcode]

def set_source_of(self, tensor_id: int, source_id: int, output_id: int) -> None:
Expand Down Expand Up @@ -203,8 +207,7 @@ def build_graph(self, me_graph: graph_builder.Graph) -> None:

# Create operator nodes
for idx, op in enumerate(sub_graph.operators):
name = self.opcode_to_name(
self.model.operatorCodes[op.opcodeIndex].builtinCode)
name = self.get_opcode_name(op.opcodeIndex)
# Construct namespace following output tensor's name
output_tensor_id = op.outputs[0]
output_tensor = sub_graph.tensors[output_tensor_id]
Expand Down

0 comments on commit 1aabefe

Please sign in to comment.