提交 5fe90b3d authored 作者: Ian Goodfellow's avatar Ian Goodfellow

renamed xview to zview since it is a view of z, not x

上级 cf8fd44e
...@@ -2457,7 +2457,7 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp): ...@@ -2457,7 +2457,7 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
This doesn't need to actually set up the view with the This doesn't need to actually set up the view with the
right indexing; we'll do that manually later. right indexing; we'll do that manually later.
""" """
return """CudaNdarray* xview = (CudaNdarray*) return """CudaNdarray* zview = (CudaNdarray*)
CudaNdarray_New(%(view_ndim)s)""" % locals() CudaNdarray_New(%(view_ndim)s)""" % locals()
def get_helper_c_code_args(self): def get_helper_c_code_args(self):
...@@ -2487,41 +2487,41 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp): ...@@ -2487,41 +2487,41 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
def link_view_array(self, x, fail): def link_view_array(self, x, fail):
return """ return """
if (CudaNdarray_set_device_data(xview, CudaNdarray_DEV_DATA(%(x)s), if (CudaNdarray_set_device_data(zview, CudaNdarray_DEV_DATA(%(x)s),
(PyObject*) NULL)) (PyObject*) NULL))
{ {
PyErr_Format(PyExc_RuntimeError, PyErr_Format(PyExc_RuntimeError,
"GpuSubtensor is not able to set the" "GpuSubtensor is not able to set the"
" devdata field of the view"); " devdata field of the view");
Py_XDECREF(xview); Py_XDECREF(zview);
%(fail)s; %(fail)s;
} }
cnda_mark_dev_structure_dirty(xview); cnda_mark_dev_structure_dirty(zview);
""" % locals() """ % locals()
def set_view_base(self, x, fail): def set_view_base(self, x, fail):
return """ return """
//Set the base only now //Set the base only now
if(CudaNdarray_set_device_data(xview, CudaNdarray_DEV_DATA(xview), if(CudaNdarray_set_device_data(zview, CudaNdarray_DEV_DATA(zview),
%(x)s)){ %(x)s)){
PyErr_Format(PyExc_RuntimeError, PyErr_Format(PyExc_RuntimeError,
"GpuSubtensor is not able to set" "GpuSubtensor is not able to set"
" the base of the view array"); " the base of the view array");
Py_XDECREF(xview); Py_XDECREF(zview);
%(fail)s; %(fail)s;
}""" % locals() }""" % locals()
def add_to_xview(self, x, fail): def add_to_zview(self, x, fail):
return """ return """
PyObject * add_result = CudaNdarray_inplace_add((PyObject *) xview, PyObject * add_result = CudaNdarray_inplace_add((PyObject *) zview,
(PyObject *) py_%(x)s); (PyObject *) py_%(x)s);
if (! add_result ) if (! add_result )
{ {
Py_DECREF(xview); Py_DECREF(zview);
%(fail)s; %(fail)s;
} }
else else
......
...@@ -101,16 +101,24 @@ int device_free(void *ptr) ...@@ -101,16 +101,24 @@ int device_free(void *ptr)
// it returns something else I still don't see why we should ignore // it returns something else I still don't see why we should ignore
// it. All we want to do here is reset the flag. // it. All we want to do here is reset the flag.
cudaGetLastError(); cudaGetLastError();
#if COMPUTE_GPU_MEM_USED #if COMPUTE_GPU_MEM_USED
fprintf(stderr, "Error freeing device pointer %p (%s).%d byte already allocated\n", ptr, cudaGetErrorString(err), _allocated_size); fprintf(stderr,
#else "Error freeing device pointer %p (%s).%d byte already allocated\n",
fprintf(stderr, "Error freeing device pointer %p (%s).\n", ptr, cudaGetErrorString(err)); ptr, cudaGetErrorString(err), _allocated_size);
#endif #else
PyErr_Format(PyExc_MemoryError, "error freeing device pointer %p (%s)", ptr, cudaGetErrorString(err)); fprintf(stderr,
"Error freeing device pointer %p (%s).\n",
ptr,
cudaGetErrorString(err));
#endif
PyErr_Format(PyExc_MemoryError,
"error freeing device pointer %p (%s)",
ptr,
cudaGetErrorString(err));
return -1; return -1;
} }
_outstanding_mallocs[0] -= (ptr != NULL); _outstanding_mallocs[0] -= (ptr != NULL);
#if COMPUTE_GPU_MEM_USED #if COMPUTE_GPU_MEM_USED
int i=0; int i=0;
size_t total_freed = 0; size_t total_freed = 0;
for(;i<TABLE_SIZE;i++) for(;i<TABLE_SIZE;i++)
...@@ -125,9 +133,10 @@ int device_free(void *ptr) ...@@ -125,9 +133,10 @@ int device_free(void *ptr)
//if(i==TABLE_SIZE) //if(i==TABLE_SIZE)
// printf("Unallocated unknow size!\n"); // printf("Unallocated unknow size!\n");
//fprintf(stderr, "freed %li bytes of device memory (%s). %d already allocated, ptr=%p\n", (long)total_freed, cudaGetErrorString(err),_allocated_size,ptr); //fprintf(stderr, "freed %li bytes of device memory (%s). %d already allocated, ptr=%p\n", (long)total_freed, cudaGetErrorString(err),_allocated_size,ptr);
#endif #endif
return 0; return 0;
} }
static PyObject * static PyObject *
outstanding_mallocs(PyObject* self, PyObject * args) outstanding_mallocs(PyObject* self, PyObject * args)
{ {
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论