Skip to content

Commit

Permalink
[YOLO]yolo op added in frontend and removed from topi (apache#1974)
Browse files Browse the repository at this point in the history
  • Loading branch information
siju-samuel authored and Wei Chen committed Feb 19, 2019
1 parent dabf5c6 commit 19cd01b
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 243 deletions.
20 changes: 14 additions & 6 deletions nnvm/python/nnvm/frontend/darknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,19 @@ def _darknet_region(inputs, attrs):

def _darknet_yolo(inputs, attrs):
"""Process the yolo operation."""
op_name, new_attrs = 'yolov3_yolo', {}
if 'n' in attrs:
new_attrs['n'] = attrs.get('n', 1)
if 'classes' in attrs:
new_attrs['classes'] = attrs.get('classes', 1)
return _darknet_get_nnvm_op(op_name)(*inputs, **new_attrs), None
num = attrs.get('n', 1)
classes = attrs.get('classes', 1)
input_shape = attrs.get('shape')
split_size = classes + 5
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)
split_res = _sym.split(data_block, indices_or_sections=split_indices, axis=2)
split_res0 = _sym.sigmoid(split_res[0])
split_res2 = _sym.sigmoid(split_res[2])
concat_list = [split_res0, split_res[1], split_res2]
out = _sym.concatenate(*concat_list, axis=2)
return _sym.reshape(out, shape=input_shape), None

def _darknet_activations(inputs, attrs):
"""Process the activation function."""
Expand Down Expand Up @@ -635,6 +642,7 @@ def _get_darknet_attrs(self, layer, layer_num):
elif LAYERTYPE.YOLO == layer.type:
attr.update({'n' : layer.n})
attr.update({'classes' : layer.classes})
attr.update({'shape' : (1, layer.c, layer.h, layer.w)})

elif LAYERTYPE.UPSAMPLE == layer.type:
attr.update({'scale' : layer.stride})
Expand Down
16 changes: 0 additions & 16 deletions nnvm/python/nnvm/top/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,6 @@ def schedule_region(attrs, outs, target):

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

@reg.register_compute("yolov3_yolo")
def compute_yolo(attrs, inputs, _):
"""Compute definition of yolo"""
n = attrs.get_int("n")
classes = attrs.get_int("classes")
with tvm.target.create(attrs.get_string("target")):
return topi.vision.yolo.yolo(inputs[0], n, classes)

@reg.register_schedule("yolov3_yolo")
def schedule_yolo(attrs, outs, target):
"""Schedule definition of yolo"""
with tvm.target.create(target):
return topi.generic.schedule_injective(outs)

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

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

This file was deleted.

58 changes: 0 additions & 58 deletions topi/include/topi/vision/yolo/yolo.h

This file was deleted.

1 change: 0 additions & 1 deletion topi/python/topi/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from .bilinear_resize_python import bilinear_resize_python
from .reorg_python import reorg_python
from .region_python import region_python
from .yolo_python import yolo_python
from .shortcut_python import shortcut_python
from .lrn_python import lrn_python
from .l2_normalize_python import l2_normalize_python
43 changes: 0 additions & 43 deletions topi/python/topi/testing/yolo_python.py

This file was deleted.

1 change: 0 additions & 1 deletion topi/python/topi/vision/yolo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
from __future__ import absolute_import as _abs

from .region import *
from .yolo import *
30 changes: 0 additions & 30 deletions topi/python/topi/vision/yolo/yolo.py

This file was deleted.

6 changes: 0 additions & 6 deletions topi/src/topi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <topi/vision/reorg.h>
#include <topi/image/resize.h>
#include <topi/vision/yolo/region.h>
#include <topi/vision/yolo/yolo.h>
#include <topi/generic/default.h>
#include <topi/generic/extern.h>
#include <topi/generic/injective.h>
Expand Down Expand Up @@ -413,11 +412,6 @@ TVM_REGISTER_GLOBAL("topi.vision.yolo.region")
*rv = vision::yolo::region(args[0], args[1], args[2], args[3], args[4], args[5]);
});

TVM_REGISTER_GLOBAL("topi.vision.yolo.yolo")
.set_body([](TVMArgs args, TVMRetValue *rv) {
*rv = vision::yolo::yolo(args[0], args[1], args[2]);
});

/* Ops from image/resize.h */
TVM_REGISTER_GLOBAL("topi.image.resize")
.set_body([](TVMArgs args, TVMRetValue *rv) {
Expand Down
49 changes: 0 additions & 49 deletions topi/tests/python_cpp/test_topi_yolo.py

This file was deleted.

0 comments on commit 19cd01b

Please sign in to comment.