提交 6ad2afec authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Multiple compilation fixes, wrong working branch was submitted.

上级 66e2fcef
......@@ -634,6 +634,10 @@ class CLinker(link.Linker):
sub['struct_id'] = id + 1
sub['fail'] = failure_code(sub)
sub_struct = dict(failure_var=failure_var)
sub_struct['id'] = id + 1
sub_struct['fail'] = failure_code(sub_struct)
struct_support = ""
struct_init = ""
struct_cleanup = ""
......@@ -661,7 +665,7 @@ class CLinker(link.Linker):
" didn't return a string for c_init_code_apply")
try:
struct_init = op.c_init_code_struct(node, id + 1)
struct_init = op.c_init_code_struct(node, id + 1, sub_struct)
assert isinstance(struct_init, basestring), (
str(node.op) +
" didn't return a string for c_init_code_struct")
......
......@@ -319,7 +319,7 @@ class CLinkerOp(CLinkerObject):
raise utils.MethodNotDefined("c_init_code_apply", type(self),
self.__class__.__name__)
def c_init_code_struct(self, node, struct_id):
def c_init_code_struct(self, node, struct_id, sub):
"""
Optional: return a code string specific to the apply
to be inserted in the struct initialization code.
......@@ -331,6 +331,11 @@ class CLinkerOp(CLinkerObject):
sub parameter named struct_id that will
contain this name.
:param sub: a dictionary of values to substitute in the code.
Most notably it contains a 'fail' entry that you
should place in your code after setting a python
exception to indicate an error.
:Exceptions:
- `MethodNotDefined`: the subclass does not override this method
"""
......
......@@ -89,7 +89,7 @@ class StructOp(Op):
def c_support_code_struct(self, node, struct_id):
return "npy_uint64 counter%d;" % (struct_id,)
def c_init_code_struct(self, node, struct_id):
def c_init_code_struct(self, node, struct_id, sub):
return "counter%d = 0;" % (struct_id,)
def c_code(self, node, name, input_names, outputs_names, sub):
......
......@@ -31,10 +31,10 @@ class GpuDnnConv(GpuOp):
def c_support_code_struct(self, node, struct_id):
return """
cudnnTensor4dDescriptior_t input%(id)d = NULL;
cudnnTensor4dDescriptior_t output%(id)d = NULL;
cudnnFilterDescriptor_t kerns%(id)d = NULL;
cudnnConvolutionDescriptor_t op%(id)d = NULL;
cudnnTensor4dDescriptor_t input%(id)d;
cudnnTensor4dDescriptor_t output%(id)d;
cudnnFilterDescriptor_t kerns%(id)d;
cudnnConvolutionDescriptor_t op%(id)d;
""" % dict(id=struct_id)
def c_init_code_struct(self, node, struct_id, sub):
......@@ -146,7 +146,7 @@ if (CudaNdarray_prep_output(&%(out)s, 4, out_dims) != 0) {
%(fail)s
}
}
err%(name)s = cudnnSetTensor4DescriptorEx(
err%(name)s = cudnnSetTensor4dDescriptorEx(
output%(id)d, CUDNN_DATA_FLOAT,
CudaNdarray_HOST_DIMS(%(out)s)[0],
CudaNdarray_HOST_DIMS(%(out)s)[1],
......@@ -166,14 +166,14 @@ dnn_handle,
input%(id)d, CudaNdarray_DEV_DATA(%(img)s),
kerns%(id)d, CudaNdarray_DEV_DATA(%(kerns)s),
op%(id)d,
out%(id)d, CudaNdarray_DEV_DATA(%(out)s),
output%(id)d, CudaNdarray_DEV_DATA(%(out)s),
CUDNN_RESULT_NO_ACCUMULATE
);
if (err%(name)s != CUDNN_STATUS_SUCCESS) {
PyErr_SetString(PyExc_RuntimeError, "error doing operation");
%(fail)s
}
""" % dict(img=img, kerns=kerns, out=out, bmode=bmode,
""" % dict(img=img, kerns=kern, out=out, bmode=bmode,
fail=sub['fail'], id=sub['struct_id'], name=name)
from theano.sandbox.cuda.opt import local_optimizer, gpu_contiguous, register_opt
......@@ -181,9 +181,9 @@ from theano.sandbox.cuda.opt import local_optimizer, gpu_contiguous, register_op
@register_opt()
@local_optimizer([GpuConv])
def local_conv_dnn(node):
if (isinstance(node.op, GpuConv) and
node.op.border_mode in ['full', 'valid']):
if node.op.subsample != (1, 1):
if isinstance(node.op, GpuConv):
if (node.op.subsample != (1, 1) or
node.op.border_mode not in ['full', 'valid']):
return
img, kern = node.inputs
border_mode = node.op.border_mode
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论