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

Method __delete_constant_input

ppq/IR/morph.py:458–474  ·  view source on GitHub ↗
(self, op: Operation, input_idx: int)

Source from the content-addressed store, hash-verified

456 self.graph.remove_variable(var)
457
458 def __delete_constant_input(self, op: Operation, input_idx: int):
459 op_name = op.name
460 if op_name not in self._graph.operations:
461 raise KeyError(f'Operation {op_name} not in current graph.')
462 operation = self._graph.operations[op_name]
463 assert input_idx < len(operation.inputs), 'Trying to delete an out-of-range input variable, '\
464 f'has graph been manually changed? Error at Operation {op_name}, input_idx: {input_idx}'
465 input_var = operation.inputs[input_idx]
466 if input_var.source_op.type != 'Constant':
467 raise ValueError(f'Trying to delete an non-const input, '\
468 f'Error at Operation {op_name}, inputs[{input_idx}]')
469 input_var.dest_ops.pop(input_var.dest_ops.index(operation))
470 operation.inputs.pop(input_idx)
471
472 if len(input_var.dest_ops) == 0:
473 self.graph.remove_operation(input_var.source_op)
474 self.graph.remove_variable(input_var)
475
476 def __add_constant_input(self, op: Operation, value: torch.Tensor):
477 op_name = op.name

Callers 1

format_gatherMethod · 0.95

Calls 3

remove_operationMethod · 0.80
remove_variableMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected