forked from PaddlePaddle/VisualDL
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add travis test for graph edges (PaddlePaddle#49)
* Add test for graph edges * add new line * add google protobuf * add onnx to travis * install protoc and move installs to tests.sh * tune protoc * try to install onnx * onnx always fails on travis, try script from onnx github * install protobuf 3.1.0 but not onnx * in the right dir * tune path * should work * put onnx_pb2 there and it should work * what if remove onnx_pb2.py * cp compiled onnx_pb2 to the right place * debug * protoc * install protoc * chown * test * added protc, should work * typo * does it exist? * hmmmm * try dropbox * test 1 * now it should work * done * make tests more thorough
- Loading branch information
Showing
7 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,3 +106,7 @@ ENV/ | |
node_modules | ||
/.vscode | ||
package-lock.json | ||
|
||
# PyCharm IDE | ||
.idea/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
#!/bin/bash | ||
|
||
script=$(readlink -f "$0") | ||
script_path=$(dirname "$script") | ||
|
||
pushd $script_path | ||
protoc visualdl/onnx/onnx.proto --python_out . | ||
protoc3/bin/protoc visualdl/onnx/onnx.proto --python_out . | ||
python setup.py bdist_wheel | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import unittest | ||
import graph | ||
import json | ||
|
||
|
||
class GraphTest(unittest.TestCase): | ||
def setUp(self): | ||
self.mock_dir = "./mock" | ||
|
||
def test_graph_edges_squeezenet(self): | ||
json_str = graph.load_model(self.mock_dir + '/squeezenet_model.pb') | ||
json_obj = json.loads(json_str) | ||
|
||
# 126 edges + 66 nodes (out-edge of each node is counted twice) | ||
self.assertEqual(len(json_obj['edges']), 126 + 66) | ||
|
||
# label_0: (in-edge) | ||
# {u'source': u'data_0', u'target': u'node_0', u'label': u'label_0'} | ||
self.assertEqual(json_obj['edges'][0]['source'], 'data_0') | ||
self.assertEqual(json_obj['edges'][0]['target'], 'node_0') | ||
self.assertEqual(json_obj['edges'][0]['label'], 'label_0') | ||
|
||
# label_50: (in-edge) | ||
# {u'source': u'fire3/concat_1', u'target': u'node_17', u'label': u'label_50'} | ||
self.assertEqual(json_obj['edges'][50]['source'], 'fire3/concat_1') | ||
self.assertEqual(json_obj['edges'][50]['target'], 'node_17') | ||
self.assertEqual(json_obj['edges'][50]['label'], 'label_50') | ||
|
||
# label_100: (in-edge) | ||
# {u'source': u'fire6/squeeze1x1_1', u'target': u'node_34', u'label': u'label_100'} | ||
self.assertEqual(json_obj['edges'][100]['source'], 'fire6/squeeze1x1_1') | ||
self.assertEqual(json_obj['edges'][100]['target'], 'node_34') | ||
self.assertEqual(json_obj['edges'][100]['label'], 'label_100') | ||
|
||
# label_111: (out-edge) | ||
# {u'source': u'node_37', u'target': u'fire6/expand3x3_1', u'label': u'label_111'} | ||
self.assertEqual(json_obj['edges'][111]['source'], 'node_37') | ||
self.assertEqual(json_obj['edges'][111]['target'], 'fire6/expand3x3_1') | ||
self.assertEqual(json_obj['edges'][111]['label'], 'label_111') | ||
|
||
def test_graph_edges_inception_v1(self): | ||
json_str = graph.load_model(self.mock_dir + '/inception_v1_model.pb') | ||
json_obj = json.loads(json_str) | ||
|
||
# 286 edges + 143 nodes (out-edge of each node is counted twice) | ||
self.assertEqual(len(json_obj['edges']), 286 + 143) | ||
|
||
# label_0: (in-edge) | ||
# {u'source': u'data_0', u'target': u'node_0', u'label': u'label_0'} | ||
self.assertEqual(json_obj['edges'][0]['source'], 'data_0') | ||
self.assertEqual(json_obj['edges'][0]['target'], 'node_0') | ||
self.assertEqual(json_obj['edges'][0]['label'], 'label_0') | ||
|
||
# label_50: (in-edge) | ||
# {u'source': u'inception_3a/5x5_reduce_2', u'target': u'node_18', u'label': u'label_50'} | ||
self.assertEqual(json_obj['edges'][50]['source'], 'inception_3a/5x5_reduce_2') | ||
self.assertEqual(json_obj['edges'][50]['target'], 'node_18') | ||
self.assertEqual(json_obj['edges'][50]['label'], 'label_50') | ||
|
||
# label_100: (out-edge) | ||
# {u'source': u'node_34', u'target': u'inception_3b/pool_1', u'label': u'label_100'} | ||
self.assertEqual(json_obj['edges'][100]['source'], 'node_34') | ||
self.assertEqual(json_obj['edges'][100]['target'], 'inception_3b/pool_1') | ||
self.assertEqual(json_obj['edges'][100]['label'], 'label_100') | ||
|
||
# label_420: (out-edge) | ||
# {u'source': u'node_139', u'target': u'pool5/7x7_s1_2', u'label': u'label_420'} | ||
self.assertEqual(json_obj['edges'][420]['source'], 'node_139') | ||
self.assertEqual(json_obj['edges'][420]['target'], 'pool5/7x7_s1_2') | ||
self.assertEqual(json_obj['edges'][420]['label'], 'label_420') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
cd mock | ||
bash download_mock_models.sh | ||
|
||
cd .. | ||
|
||
python graph_test.py | ||
|
||
rm ./mock/*.pb | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters