Skip to content

Commit

Permalink
[CI] Enable mxnet CI. (dmlc#105)
Browse files Browse the repository at this point in the history
* fix tests.

* enable mxnet CI.

* add mxnet tests.

* update jenkins.

* update mxnet docker image.
  • Loading branch information
zheng-da authored and jermainewang committed Oct 26, 2018
1 parent ff92812 commit 0d6cd30
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 17 deletions.
52 changes: 48 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ def build_dgl() {
}
}

def unit_test() {
def pytorch_unit_test() {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build"]) {
sh 'nosetests tests -v --with-xunit'
sh 'nosetests tests/pytorch -v --with-xunit'
sh 'nosetests tests/graph_index -v --with-xunit'
}
}

def mxnet_unit_test() {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build"]) {
sh 'nosetests tests/mxnet -v --with-xunit'
}
}

def example_test(dev) {
dir ('tests/scripts') {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build"]) {
Expand All @@ -55,7 +61,7 @@ pipeline {
}
}
}
stage('Build and Test') {
stage('Build and Test on Pytorch') {
parallel {
stage('CPU') {
agent {
Expand All @@ -76,7 +82,7 @@ pipeline {
}
stage('UNIT TEST') {
steps {
unit_test()
pytorch_unit_test()
}
}
stage('EXAMPLE TEST') {
Expand Down Expand Up @@ -111,7 +117,7 @@ pipeline {
}
stage('UNIT TEST') {
steps {
unit_test()
pytorch_unit_test()
}
}
stage('EXAMPLE TEST') {
Expand All @@ -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'
}
}
}
}
}
}
}
24 changes: 11 additions & 13 deletions tests/mxnet/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,13 @@ def test_reduce_0deg():
g.add_edge(3, 0)
g.add_edge(4, 0)
def _message(src, edge):
return src
return {'m' : src['h']}
def _reduce(node, msgs):
assert msgs is not None
return node + msgs.sum(1)
return {'h' : node['h'] + msgs['m'].sum(1)}
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)
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[0].asnumpy(), old_repr.sum(0).asnumpy())
Expand All @@ -226,25 +225,24 @@ def test_pull_0deg():
g.add_nodes(2)
g.add_edge(0, 1)
def _message(src, edge):
return src
return {'m' : src['h']}
def _reduce(node, msgs):
assert msgs is not None
return msgs.sum(1)
return {'h' : msgs['m'].sum(1)}

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)
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[1].asnumpy(), old_repr[1].asnumpy())
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())

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)
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[1].asnumpy(), old_repr[0].asnumpy())

Expand Down

0 comments on commit 0d6cd30

Please sign in to comment.