提交 ea826fc5 authored 作者: Frederic's avatar Frederic

Add shape check in all version of CrossentropySoftmax1HotWithBiasDx

上级 c69c3037
......@@ -247,7 +247,7 @@ class GpuCrossentropySoftmax1HotWithBiasDx(GpuOp):
def c_code_cache_version(self):
# return ()
return (7,)
return (8,)
def c_code(self, node, nodename, inp, out, sub):
dnll, sm, y_idx = inp
......@@ -288,6 +288,13 @@ class GpuCrossentropySoftmax1HotWithBiasDx(GpuOp):
"dnll.shape[0] != y_idx.shape[0]");
%(fail)s;
}
if (CudaNdarray_HOST_DIMS(%(sm)s)[0] !=
CudaNdarray_HOST_DIMS(%(y_idx)s)[0])
{
PyErr_SetString(PyExc_ValueError,
"sm.shape[0] != y_idx.shape[0]");
%(fail)s;
}
if ((NULL == %(dx)s)
|| (CudaNdarray_HOST_DIMS(%(dx)s)[0] !=
CudaNdarray_HOST_DIMS(%(sm)s)[0])
......
......@@ -295,7 +295,7 @@ class GpuCrossentropySoftmax1HotWithBiasDx(Op):
def c_code_cache_version(self):
# return ()
return (7,)
return (8,)
def c_headers(self):
return ['cuda.h', '<gpuarray/extension.h>', '<numpy_compat.h>']
......@@ -351,6 +351,13 @@ class GpuCrossentropySoftmax1HotWithBiasDx(Op):
"dnll.shape[0] != y_idx.shape[0]");
%(fail)s;
}
if (PyGpuArray_DIMS(%(sm)s)[0] !=
PyGpuArray__DIMS(%(y_idx)s)[0])
{
PyErr_SetString(PyExc_ValueError,
"sm.shape[0] != y_idx.shape[0]");
%(fail)s;
}
if ((NULL == %(dx)s)
|| (PyGpuArray_DIMS(%(dx)s)[0] !=
PyGpuArray_DIMS(%(sm)s)[0])
......
......@@ -1108,7 +1108,7 @@ class CrossentropySoftmax1HotWithBiasDx(gof.Op):
return [g_dy, g_sm, g_y_idx]
def c_code_cache_version(self):
return (4,)
return (5,)
def c_code(self, node, name, inp, out, sub):
dnll, sm, y_idx = inp
......@@ -1167,6 +1167,13 @@ class CrossentropySoftmax1HotWithBiasDx(gof.Op):
(long int)PyArray_DIMS(%(y_idx)s)[0]);
%(fail)s;
}
if (PyArray_DIMS(%(sm)s)[0] !=
PyArray_DIMS(%(y_idx)s)[0])
{
PyErr_SetString(PyExc_ValueError,
"sm.shape[0] != y_idx.shape[0]");
%(fail)s;
}
if ((NULL == %(dx)s)
|| (PyArray_DIMS(%(dx)s)[0] != PyArray_DIMS(%(sm)s)[0])
|| (PyArray_DIMS(%(dx)s)[1] != PyArray_DIMS(%(sm)s)[1]))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论