Skip to content

Commit

Permalink
REGION op removed
Browse files Browse the repository at this point in the history
  • Loading branch information
siju-samuel committed Dec 12, 2018
1 parent cb70da1 commit 36497d4
Show file tree
Hide file tree
Showing 22 changed files with 30 additions and 831 deletions.
41 changes: 29 additions & 12 deletions nnvm/python/nnvm/frontend/darknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,34 @@ 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_res = _sym.split(data_block, indices_or_sections=split_size, axis=2)
splits = []
for i in split_res:
splits.append(i)

splits[0] = _sym.sigmoid(splits[0])
splits[1] = _sym.sigmoid(splits[1])
if not background:
splits[coords] = _sym.sigmoid(splits[coords])

if softmax:
offset = coords + int(not background)
softmax_input = _sym.concatenate(*splits[offset:], axis=2)
softmax_output = _sym.softmax(softmax_input, axis=2)
data_block_1 = splits[:offset]
splits = data_block_1 + [softmax_output]
concat_out = _sym.concatenate(*splits, axis=2)
return _sym.reshape(concat_out, shape=input_shape), None

def _darknet_yolo(inputs, attrs):
"""Process the yolo operation."""
Expand Down Expand Up @@ -638,6 +654,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 36497d4

Please sign in to comment.