提交 e0dbbdbe authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Disable compute_test_values for mpi_roundtrip.

上级 8aa7567a
...@@ -4,6 +4,7 @@ from __future__ import absolute_import, print_function, division ...@@ -4,6 +4,7 @@ from __future__ import absolute_import, print_function, division
from mpi4py import MPI from mpi4py import MPI
import theano import theano
from theano.configparser import change_flags
from theano.tensor.io import send, recv, mpi_cmps from theano.tensor.io import send, recv, mpi_cmps
from theano.gof.sched import sort_schedule_fn from theano.gof.sched import sort_schedule_fn
import numpy as np import numpy as np
...@@ -27,30 +28,31 @@ scheduler = sort_schedule_fn(*mpi_cmps) ...@@ -27,30 +28,31 @@ scheduler = sort_schedule_fn(*mpi_cmps)
mode = theano.Mode(optimizer=None, mode = theano.Mode(optimizer=None,
linker=theano.OpWiseCLinker(schedule=scheduler)) linker=theano.OpWiseCLinker(schedule=scheduler))
if rank == 0: with change_flags(compute_test_value='off'):
x = theano.tensor.matrix('x', dtype=dtype) if rank == 0:
y = x + 1 x = theano.tensor.matrix('x', dtype=dtype)
send_request = send(y, 1, 11) y = x + 1
send_request = send(y, 1, 11)
z = recv(shape, dtype, 1, 12) z = recv(shape, dtype, 1, 12)
f = theano.function([x], [send_request, z], mode=mode) f = theano.function([x], [send_request, z], mode=mode)
xx = np.random.rand(*shape).astype(dtype) xx = np.random.rand(*shape).astype(dtype)
expected = (xx + 1) * 2 expected = (xx + 1) * 2
_, zz = f(xx) _, zz = f(xx)
same = np.linalg.norm(zz - expected) < .001 same = np.linalg.norm(zz - expected) < .001
# The parent test will look for "True" in the output # The parent test will look for "True" in the output
stdout.write(str(same)) stdout.write(str(same))
if rank == 1: if rank == 1:
y = recv(shape, dtype, 0, 11) y = recv(shape, dtype, 0, 11)
z = y * 2 z = y * 2
send_request = send(z, 0, 12) send_request = send(z, 0, 12)
f = theano.function([], send_request, mode=mode) f = theano.function([], send_request, mode=mode)
f() f()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论