Rename the op_id-th operator in predict_net, change it's output_id-th input's name to the new_name. It also does automatic re-route and change external_output and if necessary. - It allows multiple consumers of its output. - This function modifies predict_net in-place, d
(predict_net: caffe2_pb2.NetDef, op_id: int, output_id: int, new_name: str)
| 727 | |
| 728 | |
| 729 | def rename_op_output(predict_net: caffe2_pb2.NetDef, op_id: int, output_id: int, new_name: str): |
| 730 | """ |
| 731 | Rename the op_id-th operator in predict_net, change it's output_id-th input's |
| 732 | name to the new_name. It also does automatic re-route and change |
| 733 | external_output and if necessary. |
| 734 | - It allows multiple consumers of its output. |
| 735 | - This function modifies predict_net in-place, doesn't need init_net. |
| 736 | """ |
| 737 | assert isinstance(predict_net, caffe2_pb2.NetDef) |
| 738 | |
| 739 | ssa, blob_versions = core.get_ssa(predict_net) |
| 740 | |
| 741 | versioned_inputs, versioned_outputs = ssa[op_id] |
| 742 | old_name, version = versioned_outputs[output_id] |
| 743 | |
| 744 | # update predict_net |
| 745 | _rename_versioned_blob_in_proto( |
| 746 | predict_net, old_name, new_name, version, ssa, {}, blob_versions |
| 747 | ) |
| 748 | |
| 749 | |
| 750 | def get_sub_graph_external_input_output( |
no test coverage detected