MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / fuse_alias_placeholder

Function fuse_alias_placeholder

detectron2/export/shared.py:599–621  ·  view source on GitHub ↗

Remove AliasWithName placeholder and rename the input/output of it

(predict_net, init_net)

Source from the content-addressed store, hash-verified

597
598
599def fuse_alias_placeholder(predict_net, init_net):
600 """ Remove AliasWithName placeholder and rename the input/output of it """
601 # First we finish all the re-naming
602 for i, op in enumerate(predict_net.op):
603 if op.type == "AliasWithName":
604 assert len(op.input) == 1
605 assert len(op.output) == 1
606 name = get_pb_arg_vals(op, "name", None).decode()
607 is_backward = bool(get_pb_arg_vali(op, "is_backward", 0))
608 rename_op_input(predict_net, init_net, i, 0, name, from_producer=is_backward)
609 rename_op_output(predict_net, i, 0, name)
610
611 # Remove AliasWithName, should be very safe since it's a non-op
612 new_ops = []
613 for op in predict_net.op:
614 if op.type != "AliasWithName":
615 new_ops.append(op)
616 else:
617 # safety check
618 assert op.input == op.output
619 assert op.input[0] == op.arg[0].s.decode()
620 del predict_net.op[:]
621 predict_net.op.extend(new_ops)
622
623
624# ==== torch/utils_caffe2/graph_transform.py ===================================

Callers 1

Calls 4

get_pb_arg_valsFunction · 0.85
get_pb_arg_valiFunction · 0.85
rename_op_inputFunction · 0.85
rename_op_outputFunction · 0.85

Tested by

no test coverage detected