Skip to content

Commit

Permalink
REGION op removed from topi and added in darkent frontend (#2275)
Browse files Browse the repository at this point in the history
  • Loading branch information
siju-samuel authored and tqchen committed Feb 27, 2019
1 parent 2a89818 commit 0edb332
Show file tree
Hide file tree
Showing 21 changed files with 25 additions and 779 deletions.
36 changes: 24 additions & 12 deletions nnvm/python/nnvm/frontend/darknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,29 @@ def _darknet_reorg(inputs, attrs):

def _darknet_region(inputs, attrs):
"""Process the region operation."""
op_name, new_attrs = 'yolo_region', {}
if 'n' in attrs:
new_attrs['n'] = attrs.get('n', 1)
if 'classes' in attrs:
new_attrs['classes'] = attrs.get('classes', 1)
if 'coords' in attrs:
new_attrs['coords'] = attrs.get('coords', 0)
if 'background' in attrs:
new_attrs['background'] = attrs.get('background', 0)
if 'softmax' in attrs:
new_attrs['softmax'] = attrs.get('softmax', 0)
return _darknet_get_nnvm_op(op_name)(*inputs, **new_attrs), None
num = attrs.get('n', 1)
classes = attrs.get('classes', 1)
coords = attrs.get('coords', 0)
background = attrs.get('background', 0)
softmax = attrs.get('softmax', True)
input_shape = attrs.get('shape')

split_size = classes + coords + 1
intermediate_shape = (input_shape[0], num, split_size, input_shape[2], input_shape[3])
data_block = _sym.reshape(inputs[0], shape=intermediate_shape)
split_indices = (2, 4, 5)
split_res = _sym.split(data_block, indices_or_sections=split_indices, axis=2)
split_res0 = _sym.sigmoid(split_res[0])
if not background:
split_res2 = _sym.sigmoid(split_res[2])
else:
split_res2 = split_res[2]
if softmax:
split_res3 = _sym.softmax(split_res[3], axis=2)
concat_list = [split_res0, split_res[1], split_res2, split_res3]
out = _sym.concatenate(*concat_list, axis=2)
return _sym.reshape(out, shape=input_shape), None


def _darknet_yolo(inputs, attrs):
"""Process the yolo operation."""
Expand Down Expand Up @@ -638,6 +649,7 @@ def _get_darknet_attrs(self, layer, layer_num):
attr.update({'coords' : layer.coords})
attr.update({'background' : layer.background})
attr.update({'softmax' : layer.softmax})
attr.update({'shape' : (1, layer.c, layer.h, layer.w)})

elif LAYERTYPE.YOLO == layer.type:
attr.update({'n' : layer.n})
Expand Down
18 changes: 0 additions & 18 deletions nnvm/python/nnvm/top/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,6 @@ def schedule_reorg(attrs, outs, target):

reg.register_pattern("yolo_reorg", OpPattern.INJECTIVE)

@reg.register_compute("yolo_region")
def compute_region(attrs, inputs, _):
"""Compute definition of region"""
n = attrs.get_int("n")
classes = attrs.get_int("classes")
coords = attrs.get_int("coords")
background = attrs.get_int("background")
softmax = attrs.get_int("softmax")
return topi.vision.yolo.region(inputs[0], n, classes, coords, background, softmax)

@reg.register_schedule("yolo_region")
def schedule_region(attrs, outs, target):
"""Schedule definition of region"""
with tvm.target.create(target):
return topi.generic.vision.schedule_region(outs)

reg.register_pattern("yolo_region", OpPattern.OPAQUE)

# multibox_prior
@reg.register_schedule("multibox_prior")
def schedule_multibox_prior(_, outs, target):
Expand Down
35 changes: 0 additions & 35 deletions nnvm/src/top/vision/yolo/region.cc

This file was deleted.

101 changes: 0 additions & 101 deletions nnvm/src/top/vision/yolo/region.h

This file was deleted.

95 changes: 0 additions & 95 deletions topi/include/topi/cuda/vision.h

This file was deleted.

33 changes: 0 additions & 33 deletions topi/include/topi/rocm/vision.h

This file was deleted.

Loading

0 comments on commit 0edb332

Please sign in to comment.