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

Function func

tests/layers/test_roi_align.py:122–143  ·  view source on GitHub ↗
(N, C, H, W, nboxes_per_img)

Source from the content-addressed store, hash-verified

120 return ret
121
122 def func(N, C, H, W, nboxes_per_img):
123 input = torch.rand(N, C, H, W)
124 boxes = []
125 batch_idx = []
126 for k in range(N):
127 b = random_boxes([80, 80, 130, 130], 24, nboxes_per_img, H)
128 # try smaller boxes:
129 # b = random_boxes([100, 100, 110, 110], 4, nboxes_per_img, H)
130 boxes.append(b)
131 batch_idx.append(torch.zeros(nboxes_per_img, 1, dtype=torch.float32) + k)
132 boxes = torch.cat(boxes, axis=0)
133 batch_idx = torch.cat(batch_idx, axis=0)
134 boxes = torch.cat([batch_idx, boxes], axis=1)
135
136 input = input.cuda()
137 boxes = boxes.cuda()
138
139 def bench():
140 _C.roi_align_forward(input, boxes, 1.0, 7, 7, 0, True)
141 torch.cuda.synchronize()
142
143 return bench
144
145 args = [dict(N=2, C=512, H=256, W=256, nboxes_per_img=500)]
146 benchmark(func, "cuda_roialign", args, num_iters=20, warmup_iters=1)

Callers

nothing calls this directly

Calls 2

random_boxesFunction · 0.70
catMethod · 0.45

Tested by

no test coverage detected