Skip to content

Commit

Permalink
[CRASH] cudnn softmax r1
Browse files Browse the repository at this point in the history
  • Loading branch information
nouiz committed Dec 19, 2014
1 parent e34f6e5 commit 5036835
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions theano/sandbox/cuda/dnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,13 +1029,13 @@ def __init__(self, tensor_format, algo, mode):

def _define_tensor4d_desc(self, name, id):
return """
cudnnTensor4dDescriptor_t %(name)s_%(id)s;
cudnnTensor4dDescriptor_t %(id)s_%(name)s;
""" % dict(name=name, id=id)

def _init_tensor4d_desc(self, name, id, fail):
return """
%(name)s_%(id)s = NULL;
if ((err%(name)s = cudnnCreateTensor4dDescriptor(&%(name)s_%(id)s)) != CUDNN_STATUS_SUCCESS) {
%(id)s_%(name)s = NULL;
if ((err%(name)s = cudnnCreateTensor4dDescriptor(&%(id)s_%(name)s)) != CUDNN_STATUS_SUCCESS) {
PyErr_Format(PyExc_MemoryError, "could not allocate tensor4d descriptor "
": %%s", cudnnGetErrorString(err%(name)s));
%(fail)s
Expand All @@ -1044,29 +1044,29 @@ def _init_tensor4d_desc(self, name, id, fail):

def _clean_tensor4d_desc(self, name, id):
return """
if(%(name)s_%(name)s!= NULL)
cudnnDestroyTensor4dDescriptor(%(name)s_%(id)s);
if(%(id)s_%(name)s!= NULL)
cudnnDestroyTensor4dDescriptor(%(id)s_%(name)s);
""" % dict(name=name, id=id)

def c_support_code_struct(self, node, name):
result = ''
for name in self.tensor_4d_descs:
result += self._define_tensor4d_desc(name, name)
for id in self.tensor_4d_descs:
result += self._define_tensor4d_desc(name, id)
return result

def c_init_code_struct(self, node, name, sub):
result = """
cudnnStatus_t err%(name)s;
""" % dict(name=name)

for name in self.tensor_4d_descs:
result += self._init_tensor4d_desc(name, name, sub['fail'])
for id in self.tensor_4d_descs:
result += self._init_tensor4d_desc(name, id, sub['fail'])
return result

def c_cleanup_code_struct(self, node, name):
result = ''
for name in self.tensor_4d_descs:
result += self._clean_tensor4d_desc(name, name)
for id in self.tensor_4d_descs:
result += self._clean_tensor4d_desc(name, id)
return result

def c_code(self, node, name, inputs, outputs, sub):
Expand Down

0 comments on commit 5036835

Please sign in to comment.