outputs = []
for mode in [mode_with_gpu, mode_without_gpu]:
// test the optimization local_gpua_elemwise
f = theano.function(
symb_args, op_to_test(*symb_args))
outputs.append(f(*args))
// assert that the test was done on the gpu.
if mode is mode_with_gpu:
After Change
// extremely large numbers of arguments on gpu.
rng = np.random.RandomState([1, 2, 3])
nb_of_inputs_overflows = []
for num_args in [64]:
for op_to_test in [theano.tensor.add, theano.tensor.mul]:
for nb_dim in [2, 8]:
shapes = [rng.randint(1, int(32 / nb_dim)) for i in range(nb_dim)]
args = [np.cast["float32"](rng.randn(*shapes))
for arg in range(0, num_args)]
symb_args = [theano.tensor.TensorType("float32",
(False,) * nb_dim)()
for arg in range(0, num_args)]
outputs = []
for mode in [mode_with_gpu, mode_without_gpu]:
// test the optimization local_gpua_elemwise
output = op_to_test(*symb_args)
f = theano.function(symb_args, output)
outputs.append(f(*args))
// assert that the test was done on the gpu.
if mode is mode_with_gpu:
nb_of_inputs_overflows.append(
max_inputs_to_GpuElemwise(output.owner) - num_args)
nodelst = [node for node in f.maker.fgraph.apply_nodes]
assert any(isinstance(node.op, GpuElemwise)
for node in nodelst)
assert not any(isinstance(node.op, Elemwise)