From: youluexx Date: Wed, 4 Sep 2019 05:46:29 +0000 (+0800) Subject: [Relay][Frontend][darknet] Solve tvm parsing darknet resnext failure bug (#3778) X-Git-Tag: upstream/0.7.0~1964 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=360d26ddc1b65240b23bd715fb9c3c16eadbcbfd;p=platform%2Fupstream%2Ftvm.git [Relay][Frontend][darknet] Solve tvm parsing darknet resnext failure bug (#3778) * test_darkent_bug * test_darkent * add resnext tests --- diff --git a/.gitignore b/.gitignore index f044577..2f124d9 100644 --- a/.gitignore +++ b/.gitignore @@ -231,4 +231,4 @@ conda/pkg # antlr files *.tokens -*.interp \ No newline at end of file +*.interp diff --git a/python/tvm/relay/frontend/darknet.py b/python/tvm/relay/frontend/darknet.py index f452146..982bcea 100644 --- a/python/tvm/relay/frontend/darknet.py +++ b/python/tvm/relay/frontend/darknet.py @@ -458,11 +458,11 @@ class GraphProto(object): if layer.nweights == 0: return None - if (layer.n * layer.c * layer.size * layer.size) != layer.nweights: + if (layer.n * layer.c // layer.groups * layer.size * layer.size) != layer.nweights: raise RuntimeError("layer weights size not matching with n c h w") params = {} - shape = (layer.n, layer.c, layer.size, layer.size) + shape = (layer.n, layer.c // layer.groups, layer.size, layer.size) weights = self._read_memory_buffer(shape, layer.weights) biases = self._read_memory_buffer((layer.n, ), layer.biases) diff --git a/tests/python/frontend/darknet/test_forward.py b/tests/python/frontend/darknet/test_forward.py index ebfbbd3..51f05d7 100644 --- a/tests/python/frontend/darknet/test_forward.py +++ b/tests/python/frontend/darknet/test_forward.py @@ -189,6 +189,18 @@ def test_forward_resnet50(): verify_darknet_frontend(net) LIB.free_network(net) +def test_forward_resnext50(): + '''test resnet50 model''' + model_name = 'resnext50' + cfg_name = model_name + '.cfg' + weights_name = model_name + '.weights' + cfg_url = 'https://github.com/pjreddie/darknet/blob/master/cfg/' + cfg_name + '?raw=true' + weights_url = 'http://pjreddie.com/media/files/' + weights_name + '?raw=true' + net = _load_net(cfg_url, cfg_name, weights_url, weights_name) + verify_darknet_frontend(net) + LIB.free_network(net) + + def test_forward_yolov2(): '''test yolov2 model''' model_name = 'yolov2' @@ -441,6 +453,7 @@ def test_forward_rnn(): if __name__ == '__main__': test_forward_resnet50() + test_forward_resnext50() test_forward_alexnet() test_forward_extraction() test_forward_yolov2()