Skip to content

Commit

Permalink
[MXNet] Patch mxnet unittest (dmlc#1395)
Browse files Browse the repository at this point in the history
* patch

* turn off tf test

* skip test

* fix
  • Loading branch information
VoVAllen authored Mar 25, 2020
1 parent 08fcda3 commit 1e27e90
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 54 deletions.
82 changes: 41 additions & 41 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -203,47 +203,47 @@ pipeline {
}
}
}
stage("Tensorflow CPU") {
agent {
docker {
label "linux-cpu-node"
image "dgllib/dgl-ci-cpu:conda"
}
}
stages {
stage("Unit test") {
steps {
unit_test_linux("tensorflow", "cpu")
}
}
}
post {
always {
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
stage("Tensorflow GPU") {
agent {
docker {
label "linux-gpu-node"
image "dgllib/dgl-ci-gpu:conda"
args "--runtime nvidia"
}
}
stages {
stage("Unit test") {
steps {
unit_test_linux("tensorflow", "gpu")
}
}
}
post {
always {
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
// stage("Tensorflow CPU") {
// agent {
// docker {
// label "linux-cpu-node"
// image "dgllib/dgl-ci-cpu:conda"
// }
// }
// stages {
// stage("Unit test") {
// steps {
// unit_test_linux("tensorflow", "cpu")
// }
// }
// }
// post {
// always {
// cleanWs disableDeferredWipeout: true, deleteDirs: true
// }
// }
// }
// stage("Tensorflow GPU") {
// agent {
// docker {
// label "linux-gpu-node"
// image "dgllib/dgl-ci-gpu:conda"
// args "--runtime nvidia"
// }
// }
// stages {
// stage("Unit test") {
// steps {
// unit_test_linux("tensorflow", "gpu")
// }
// }
// }
// post {
// always {
// cleanWs disableDeferredWipeout: true, deleteDirs: true
// }
// }
// }
stage("Torch CPU") {
agent {
docker {
Expand Down
12 changes: 6 additions & 6 deletions tests/compute/test_batched_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def test_batch_send_then_recv():
bg.recv([1, 9]) # assuming recv takes in unique nodes

t1, t2 = dgl.unbatch(bg)
assert t1.ndata['h'][1] == 7
assert t2.ndata['h'][4] == 2
assert F.asnumpy(t1.ndata['h'][1]) == 7
assert F.asnumpy(t2.ndata['h'][4]) == 2

def test_batch_send_and_recv():
t1 = tree1()
Expand All @@ -146,8 +146,8 @@ def test_batch_send_and_recv():
bg.send_and_recv((u, v))

t1, t2 = dgl.unbatch(bg)
assert t1.ndata['h'][1] == 7
assert t2.ndata['h'][4] == 2
assert F.asnumpy(t1.ndata['h'][1]) == 7
assert F.asnumpy(t2.ndata['h'][4]) == 2

def test_batch_propagate():
t1 = tree1()
Expand All @@ -173,8 +173,8 @@ def test_batch_propagate():
bg.prop_edges(order)
t1, t2 = dgl.unbatch(bg)

assert t1.ndata['h'][0] == 9
assert t2.ndata['h'][1] == 5
assert F.asnumpy(t1.ndata['h'][0]) == 9
assert F.asnumpy(t2.ndata['h'][1]) == 5

def test_batched_edge_ordering():
g1 = dgl.DGLGraph()
Expand Down
8 changes: 4 additions & 4 deletions tests/compute/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ def test_find_edges():
g.add_nodes(10)
g.add_edges(range(9), range(1, 10))
e = g.find_edges([1, 3, 2, 4])
assert e[0][0] == 1 and e[0][1] == 3 and e[0][2] == 2 and e[0][3] == 4
assert e[1][0] == 2 and e[1][1] == 4 and e[1][2] == 3 and e[1][3] == 5
assert F.asnumpy(e[0][0]) == 1 and F.asnumpy(e[0][1]) == 3 and F.asnumpy(e[0][2]) == 2 and F.asnumpy(e[0][3]) == 4
assert F.asnumpy(e[1][0]) == 2 and F.asnumpy(e[1][1]) == 4 and F.asnumpy(e[1][2]) == 3 and F.asnumpy(e[1][3]) == 5

try:
g.find_edges([10])
Expand All @@ -371,8 +371,8 @@ def test_find_edges():

g.readonly()
e = g.find_edges([1, 3, 2, 4])
assert e[0][0] == 1 and e[0][1] == 3 and e[0][2] == 2 and e[0][3] == 4
assert e[1][0] == 2 and e[1][1] == 4 and e[1][2] == 3 and e[1][3] == 5
assert F.asnumpy(e[0][0]) == 1 and F.asnumpy(e[0][1]) == 3 and F.asnumpy(e[0][2]) == 2 and F.asnumpy(e[0][3]) == 4
assert F.asnumpy(e[1][0]) == 2 and F.asnumpy(e[1][1]) == 4 and F.asnumpy(e[1][2]) == 3 and F.asnumpy(e[1][3]) == 5

try:
g.find_edges([10])
Expand Down
1 change: 1 addition & 0 deletions tests/compute/test_heterograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ def check_mapping(g, fg):
assert fg.etypes == ['follows+knows']
check_mapping(g, fg)

@unittest.skipIf(F._default_context_str == 'cpu', reason="Need gpu for this test")
def test_to_device():
hg = create_test_heterograph()
if F.is_cuda_available():
Expand Down
6 changes: 3 additions & 3 deletions tests/compute/test_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def test_random_choice():
x = dgl.random.choice(a, 10, replace=True, prob=None)
assert len(x) == 10
for i in range(len(x)):
assert x[i] >= 0 and x[i] < 100
assert F.asnumpy(x[i]) >= 0 and F.asnumpy(x[i]) < 100
# test 2, replace=False, small num
a = F.arange(0, 100)
x = dgl.random.choice(a, 10, replace=False, prob=None)
assert len(x) == 10
for i in range(len(x)):
assert x[i] >= 0 and x[i] < 100
assert F.asnumpy(x[i]) >= 0 and F.asnumpy(x[i]) < 100
# test 3, replace=False, large num
a = F.arange(0, 100)
x = dgl.random.choice(a, 100, replace=False, prob=None)
Expand All @@ -35,7 +35,7 @@ def test_random_choice():
x = dgl.random.choice(100, 97, replace=False, prob=prob)
assert len(x) == 97
for i in range(len(x)):
assert x[i] < 37 or x[i] >= 40
assert F.asnumpy(x[i]) < 37 or F.asnumpy(x[i]) >= 40

if __name__ == '__main__':
test_random_choice()
3 changes: 3 additions & 0 deletions tests/compute/test_to_device.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import dgl
import backend as F
import unittest


@unittest.skipIf(F._default_context_str == 'cpu', reason="Need gpu for this test")
def test_to_device():
g = dgl.DGLGraph()
g.add_nodes(5, {'h' : F.ones((5, 2))})
Expand Down

0 comments on commit 1e27e90

Please sign in to comment.