Skip to content
This repository was archived by the owner on Nov 21, 2023. It is now read-only.

add convert op BatchPermutation to Gather #698

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions detectron/utils/model_convert_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ def compare_model(model1_func, model2_func, test_image, check_blobs):
n1, n2 = cb1[idx], cb2[idx]
r1 = res1[n1] if n1 in res1 else None
r2 = res2[n2] if n2 in res2 else None
assert r1 is not None or r2 is None, \
assert r1 is not None, \
"Blob {} in model1 is None".format(n1)
assert r2 is not None or r1 is None, \
assert r2 is not None, \
"Blob {} in model2 is None".format(n2)
assert r1.shape == r2.shape, \
"Blob {} and {} shape mismatched: {} vs {}".format(
Expand Down
9 changes: 9 additions & 0 deletions tools/convert_pkl_to_pb.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ def convert_upsample_nearest(op):
height_scale=float(scale))
return resize_nearest_op

@op_filter(type='BatchPermutation')
def convert_batch_permutation(op):
gather_op = core.CreateOperator('Gather',
list(op.input),
list(op.output),
name=op.name)
return gather_op

@op_filter()
def convert_rpn_rois(op):
for j in range(len(op.input)):
Expand All @@ -291,6 +299,7 @@ def convert_remove_op(op):
# so run separately
convert_op_in_proto(net, convert_remove_op)
convert_op_in_proto(net, convert_upsample_nearest)
convert_op_in_proto(net, convert_batch_permutation)
convert_op_in_proto(net, convert_python)
convert_op_in_proto(net, convert_op_name)
convert_op_in_proto(net, convert_rpn_rois)
Expand Down