(self, command: GraphCommand)
| 16 | class 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: |
nothing calls this directly
no test coverage detected