提交 3a0493c2 authored 作者: abergeron's avatar abergeron

Merge pull request #3875 from abergeron/fix_buildbot

Fix buildbot
......@@ -1784,8 +1784,7 @@ class _VariableEquivalenceTracker(object):
# List of default version of make thunk.
# This is needed to know if the user overrided it.
# The GpuOp will be added here when theano.sandbox.cuda is imported.
default_make_thunk = [get_unbound_function(theano.gof.Op.make_thunk),
get_unbound_function(theano.gof.OpenMPOp.make_thunk)]
default_make_thunk = [get_unbound_function(theano.gof.Op.make_thunk)]
# Debug mode cheats and initializes the linker in a different way in
......@@ -1879,6 +1878,10 @@ class _Linker(gof.link.LocalLinker):
thunk.inputs = [storage_map[v] for v in node.inputs]
thunk.outputs = [storage_map[v] for v in node.outputs]
thunk_other = thunk
else:
new_node = node.op.prepare_node(node)
if new_node is not None:
node = new_node
try:
if not self.maker.mode.check_c_code:
......
......@@ -817,6 +817,16 @@ class Op(utils.object2, PureOp, CLinkerOp):
else:
return NotImplemented
def prepare_node(self, node):
"""
Make any special modifications that the Op needs before doing
make_thunk().
This can either modify the node inplace or return a new one.
"""
pass
def make_c_thunk(self, node, storage_map, compute_map, no_recycling):
"""
Like make_thunk, but will only try to make a C thunk.
......@@ -926,6 +936,10 @@ class Op(utils.object2, PureOp, CLinkerOp):
"""
logger = logging.getLogger('theano.gof.op.Op')
new_node = self.prepare_node(node)
if new_node is not None:
node = new_node
if self._op_use_c_code:
try:
return self.make_c_thunk(node, storage_map, compute_map,
......@@ -1162,10 +1176,8 @@ int main( int argc, const char* argv[] )
self.openmp = False
theano.config.openmp = False
def make_thunk(self, node, storage_map, compute_map, no_recycling):
def prepare_node(self, node):
self.update_self_openmp()
return super(OpenMPOp, self).make_thunk(node, storage_map,
compute_map, no_recycling)
def simple_meth(tag):
......
......@@ -55,7 +55,7 @@ class MultinomialFromUniform(Op):
return [T.zeros_like(x) for x in ins]
def c_code_cache_version(self):
return (7,)
return (8,)
def c_code(self, node, name, ins, outs, sub):
# support old pickled graphs
......@@ -122,7 +122,7 @@ class MultinomialFromUniform(Op):
for (int n = 0; n < nb_multi; ++n)
{
int waiting = 1;
dtype_%(pvals)s cummul = 0.;
double cummul = 0.;
const dtype_%(unis)s* unis_n = (dtype_%(unis)s*)PyArray_GETPTR1(%(unis)s, c*nb_multi + n);
for (int m = 0; m < nb_outcomes; ++m)
{
......
......@@ -7,7 +7,6 @@ import numpy
import theano
from theano import gof
from theano.compat import izip
from theano.compat import get_unbound_function
from six import iteritems
from six.moves import xrange
from theano.gof import Apply, Op, OpenMPOp
......@@ -793,8 +792,7 @@ class Elemwise(OpenMPOp):
return ret
def make_thunk(self, node, storage_map, compute_map, no_recycling):
node_ = node
def prepare_node(self, node):
# Postpone the ufunc building to the last minutes
# NumPy ufunc support only up to 31 inputs.
# But our c code support more.
......@@ -830,8 +828,6 @@ class Elemwise(OpenMPOp):
char = numpy.sctype2char(out_dtype)
sig = char * node.nin + '->' + char * node.nout
node.tag.sig = sig
return super(Elemwise, node_.op).make_thunk(node_, storage_map,
compute_map, no_recycling)
def perform(self, node, inputs, output_storage):
if len(node.inputs) >= 32:
......@@ -1273,19 +1269,6 @@ class Elemwise(OpenMPOp):
"""
return node.outputs[0].ndim == 0
theano.compile.debugmode.default_make_thunk.append(
get_unbound_function(Elemwise.make_thunk))
# def elemwise_to_scal(fgraph):
# TODO: why is this commented out? should it be removed?
# it has needed maintenance despite being commented
# mapping = {}
# inputs = []
# outputs = []
# for node in fgraph.io_toposort():
# if not isinstance(node.op, Elemwise):
# raise TypeError('All ops in the graph must be Elemwise.')
################
# CAReduce #
......
......@@ -99,6 +99,8 @@ class TestConv2D(utt.InferShapeTester):
out_shape2d = numpy.array(N_image_shape[-2:]) +\
s * numpy.array(N_filter_shape[-2:]) - s
out_shape2d = numpy.ceil(out_shape2d / numpy.array(subsample))
# avoid numpy deprecation
out_shape2d = out_shape2d.astype('int32')
out_shape = (N_image_shape[0], N_filter_shape[0]) + tuple(out_shape2d)
ref_output = numpy.zeros(out_shape)
......
......@@ -97,6 +97,8 @@ class TestCorr2D(utt.InferShapeTester):
else:
raise NotImplementedError('Unsupported border_mode {}'.format(border_mode))
out_shape2d = numpy.floor((img_shape2d + 2 * (padHW) - fil_shape2d) / subsample2d) + 1
# avoid numpy deprecation
out_shape2d = out_shape2d.astype('int32')
out_shape = (N_image_shape[0], N_filter_shape[0]) + tuple(out_shape2d)
ref_output = numpy.zeros(out_shape)
......
......@@ -1493,6 +1493,12 @@ CosInplaceTester = makeBroadcastTester(
grad=_grad_broadcast_unary_wide,
inplace=True)
def test_py_c_match():
a = tensor.TensorType(dtype='int8', broadcastable=(False,))()
f = theano.function([a], tensor.arccos(a), mode='DebugMode')
# This can fail in DebugMode
f(numpy.asarray([1, 0, -1], dtype='int8'))
ArccosTester = makeBroadcastTester(op=tensor.arccos,
expected=upcast_float16_ufunc(numpy.arccos),
good=_good_broadcast_unary_arcsin,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论