Commit 0d6cd30b authored by Da Zheng's avatar Da Zheng Committed by Minjie Wang
Browse files

[CI] Enable mxnet CI. (#105)

* fix tests.

* enable mxnet CI.

* add mxnet tests.

* update jenkins.

* update mxnet docker image.
parent ff928126
...@@ -21,7 +21,7 @@ def build_dgl() { ...@@ -21,7 +21,7 @@ def build_dgl() {
} }
} }
def unit_test() { def pytorch_unit_test() {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build"]) { withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build"]) {
sh 'nosetests tests -v --with-xunit' sh 'nosetests tests -v --with-xunit'
sh 'nosetests tests/pytorch -v --with-xunit' sh 'nosetests tests/pytorch -v --with-xunit'
...@@ -29,6 +29,12 @@ def unit_test() { ...@@ -29,6 +29,12 @@ def unit_test() {
} }
} }
def mxnet_unit_test() {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build"]) {
sh 'nosetests tests/mxnet -v --with-xunit'
}
}
def example_test(dev) { def example_test(dev) {
dir ('tests/scripts') { dir ('tests/scripts') {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build"]) { withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build"]) {
...@@ -55,7 +61,7 @@ pipeline { ...@@ -55,7 +61,7 @@ pipeline {
} }
} }
} }
stage('Build and Test') { stage('Build and Test on Pytorch') {
parallel { parallel {
stage('CPU') { stage('CPU') {
agent { agent {
...@@ -76,7 +82,7 @@ pipeline { ...@@ -76,7 +82,7 @@ pipeline {
} }
stage('UNIT TEST') { stage('UNIT TEST') {
steps { steps {
unit_test() pytorch_unit_test()
} }
} }
stage('EXAMPLE TEST') { stage('EXAMPLE TEST') {
...@@ -111,7 +117,7 @@ pipeline { ...@@ -111,7 +117,7 @@ pipeline {
} }
stage('UNIT TEST') { stage('UNIT TEST') {
steps { steps {
unit_test() pytorch_unit_test()
} }
} }
stage('EXAMPLE TEST') { stage('EXAMPLE TEST') {
...@@ -128,5 +134,43 @@ pipeline { ...@@ -128,5 +134,43 @@ pipeline {
} }
} }
} }
stage('Build and Test on MXNet') {
parallel {
stage('CPU') {
agent {
docker {
image 'zhengda1936/dgl-mxnet-cpu:v2'
}
}
stages {
stage('SETUP') {
steps {
setup()
}
}
stage('BUILD') {
steps {
build_dgl()
}
}
stage('UNIT TEST') {
steps {
mxnet_unit_test()
}
}
stage('EXAMPLE TEST') {
steps {
example_test('CPU')
}
}
}
post {
always {
junit '*.xml'
}
}
}
}
}
} }
} }
...@@ -209,14 +209,13 @@ def test_reduce_0deg(): ...@@ -209,14 +209,13 @@ def test_reduce_0deg():
g.add_edge(3, 0) g.add_edge(3, 0)
g.add_edge(4, 0) g.add_edge(4, 0)
def _message(src, edge): def _message(src, edge):
return src return {'m' : src['h']}
def _reduce(node, msgs): def _reduce(node, msgs):
assert msgs is not None return {'h' : node['h'] + msgs['m'].sum(1)}
return node + msgs.sum(1)
old_repr = mx.nd.random.normal(shape=(5, 5)) old_repr = mx.nd.random.normal(shape=(5, 5))
g.set_n_repr(old_repr) g.set_n_repr({'h': old_repr})
g.update_all(_message, _reduce) g.update_all(_message, _reduce)
new_repr = g.get_n_repr() new_repr = g.get_n_repr()['h']
assert np.allclose(new_repr[1:].asnumpy(), old_repr[1:].asnumpy()) assert np.allclose(new_repr[1:].asnumpy(), old_repr[1:].asnumpy())
assert np.allclose(new_repr[0].asnumpy(), old_repr.sum(0).asnumpy()) assert np.allclose(new_repr[0].asnumpy(), old_repr.sum(0).asnumpy())
...@@ -226,25 +225,24 @@ def test_pull_0deg(): ...@@ -226,25 +225,24 @@ def test_pull_0deg():
g.add_nodes(2) g.add_nodes(2)
g.add_edge(0, 1) g.add_edge(0, 1)
def _message(src, edge): def _message(src, edge):
return src return {'m' : src['h']}
def _reduce(node, msgs): def _reduce(node, msgs):
assert msgs is not None return {'h' : msgs['m'].sum(1)}
return msgs.sum(1)
old_repr = mx.nd.random.normal(shape=(2, 5)) old_repr = mx.nd.random.normal(shape=(2, 5))
g.set_n_repr(old_repr) g.set_n_repr({'h' : old_repr})
g.pull(0, _message, _reduce) g.pull(0, _message, _reduce)
new_repr = g.get_n_repr() new_repr = g.get_n_repr()['h']
assert np.allclose(new_repr[0].asnumpy(), old_repr[0].asnumpy()) assert np.allclose(new_repr[0].asnumpy(), old_repr[0].asnumpy())
assert np.allclose(new_repr[1].asnumpy(), old_repr[1].asnumpy()) assert np.allclose(new_repr[1].asnumpy(), old_repr[1].asnumpy())
g.pull(1, _message, _reduce) g.pull(1, _message, _reduce)
new_repr = g.get_n_repr() new_repr = g.get_n_repr()['h']
assert np.allclose(new_repr[1].asnumpy(), old_repr[0].asnumpy()) assert np.allclose(new_repr[1].asnumpy(), old_repr[0].asnumpy())
old_repr = mx.nd.random.normal(shape=(2, 5)) old_repr = mx.nd.random.normal(shape=(2, 5))
g.set_n_repr(old_repr) g.set_n_repr({'h' : old_repr})
g.pull([0, 1], _message, _reduce) g.pull([0, 1], _message, _reduce)
new_repr = g.get_n_repr() new_repr = g.get_n_repr()['h']
assert np.allclose(new_repr[0].asnumpy(), old_repr[0].asnumpy()) assert np.allclose(new_repr[0].asnumpy(), old_repr[0].asnumpy())
assert np.allclose(new_repr[1].asnumpy(), old_repr[0].asnumpy()) assert np.allclose(new_repr[1].asnumpy(), old_repr[0].asnumpy())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment