MCPcopy
hub / github.com/OpenPPL/ppq / process

Method process

ppq/IR/morph.py:18–30  ·  view source on GitHub ↗
(self, command: GraphCommand)

Source from the content-addressed store, hash-verified

16class GraphReplacer(GraphCommandProcessor):
17 """ Graph Replacer offers a bunch of graph editing functions that helps replacing operation or variable in your graph. """
18 def process(self, command: GraphCommand) -> Any:
19 if command.command_type == GraphCommandType.REPLACE_OP:
20 assert isinstance(command, ReplaceOperationCommand), \
21 'Use ReplaceOperationCommand instead of GraphCommand'
22 return self.replace_op(command.op_name, command.replace_to)
23 if command.command_type == GraphCommandType.REPLACE_VAR:
24 assert isinstance(command, ReplaceVariableCommand), \
25 'Use ReplaceOperationCommand instead of GraphCommand'
26 return self.replace_var(command.op_name, command.replace_to)
27 if command.command_type == GraphCommandType.REPLACE_BATCHNORM_TO_CONV:
28 return self.replace_batchnorm_to_conv()
29 if command.command_type == GraphCommandType.REPLACE_BATCHNORM_TO_SCALE:
30 return self.replace_batchnorm_to_scale()
31
32 def replace_op(self, op_name: str, replace_to: Operation):
33 if op_name not in self._graph.operations:

Callers

nothing calls this directly

Calls 4

replace_opMethod · 0.95
replace_varMethod · 0.95

Tested by

no test coverage detected