提交 126b7b6c authored 作者: Ian Goodfellow's avatar Ian Goodfellow

merged

...@@ -132,14 +132,3 @@ def unimplemented_grad(op, x_pos, x): ...@@ -132,14 +132,3 @@ def unimplemented_grad(op, x_pos, x):
""" """
msg = '%s.grad not implemented for input %i'%(op, x_pos) msg = '%s.grad not implemented for input %i'%(op, x_pos)
return Raise(msg=msg)(x) return Raise(msg=msg)(x)
class GradientUndefined(Exception): pass
def undefined_grad(op, x_pos, x):
msg = "Undefined gradient - do not use in computations"
exc = RuntimeError
return Raise(msg=msg, exc=exc)(x)
def grad(self, inputs, out_storage):
return [g_x0, undefined_grad(self, 1, inputs[1])]
...@@ -374,7 +374,7 @@ class GpuDimShuffle(Op): ...@@ -374,7 +374,7 @@ class GpuDimShuffle(Op):
return sio.getvalue() return sio.getvalue()
def c_code_cache_version(self): def c_code_cache_version(self):
return (3,0) return (1,0)
class GpuSum(Op): class GpuSum(Op):
"""GpuSum is a Reduction along some dimensions by summation. """GpuSum is a Reduction along some dimensions by summation.
......
...@@ -334,13 +334,17 @@ int CudaNdarray_set_nd(CudaNdarray * self, const int nd) ...@@ -334,13 +334,17 @@ int CudaNdarray_set_nd(CudaNdarray * self, const int nd)
if (nd == -1) return 0; if (nd == -1) return 0;
self->host_structure = (int*)malloc(cnda_structure_size(nd)*sizeof(int)); self->host_structure = (int*)malloc(cnda_structure_size(nd)*sizeof(int));
//initialize all dimensions and strides to 0
for (int i = 0; i < cnda_structure_size(nd); ++i) self->host_structure[i] = 0;
if (NULL == self->host_structure) if (NULL == self->host_structure)
{ {
PyErr_SetString(PyExc_MemoryError, "Failed to allocate dim or str"); PyErr_SetString(PyExc_MemoryError, "Failed to allocate dim or str");
return -1; return -1;
} }
//initialize all dimensions and strides to 0
for (int i = 0; i < cnda_structure_size(nd); ++i)
{
self->host_structure[i] = 0;
}
int struct_size = cnda_structure_size(nd); int struct_size = cnda_structure_size(nd);
if (struct_size) if (struct_size)
{ {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论