提交 acab2948 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Better error messages

上级 f784c7b5
...@@ -143,7 +143,7 @@ class SoftmaxWithBias(gof.Op): ...@@ -143,7 +143,7 @@ class SoftmaxWithBias(gof.Op):
@staticmethod @staticmethod
def c_code_cache_version(): def c_code_cache_version():
return (3,) return (4,)
@staticmethod @staticmethod
def c_code_template(): def c_code_template():
# this implementation was lifted from # this implementation was lifted from
...@@ -180,7 +180,8 @@ class SoftmaxWithBias(gof.Op): ...@@ -180,7 +180,8 @@ class SoftmaxWithBias(gof.Op):
} }
if ((%(x)s->dimensions[1] != %(b)s->dimensions[0])) if ((%(x)s->dimensions[1] != %(b)s->dimensions[0]))
{ {
PyErr_SetString(PyExc_ValueError, "dimension mismatch in arguments"); PyErr_Format(PyExc_ValueError, "number of columns in x (%%i) does not match length of b (%%i)",
%(x)s->dimensions[1], %(b)s->dimensions[0]);
%(fail)s; %(fail)s;
} }
...@@ -594,7 +595,8 @@ class CrossentropySoftmaxArgmax1HotWithBias(gof.Op): ...@@ -594,7 +595,8 @@ class CrossentropySoftmaxArgmax1HotWithBias(gof.Op):
} }
if (%(x)s->dimensions[0] != %(y_idx)s->dimensions[0]) if (%(x)s->dimensions[0] != %(y_idx)s->dimensions[0])
{ {
PyErr_SetString(PyExc_ValueError, "dimension mismatch in arguments"); PyErr_Format(PyExc_ValueError, "number of rows in x (%%i) does not match length of y (%%i)",
%(x)s->dimensions[0], %(y_idx)s->dimensions[0]);
%(fail)s; %(fail)s;
} }
...@@ -644,7 +646,7 @@ class CrossentropySoftmaxArgmax1HotWithBias(gof.Op): ...@@ -644,7 +646,7 @@ class CrossentropySoftmaxArgmax1HotWithBias(gof.Op):
def c_code_cache_version(self): def c_code_cache_version(self):
return (3,) + SoftmaxWithBias.c_code_cache_version() return (4,) + SoftmaxWithBias.c_code_cache_version()
def c_code(self, node, name, (x, b, y_idx), (nll, sm, am), sub): def c_code(self, node, name, (x, b, y_idx), (nll, sm, am), sub):
y_idx_type = node.inputs[2].type.dtype_specs()[1] y_idx_type = node.inputs[2].type.dtype_specs()[1]
am_type = y_idx_type am_type = y_idx_type
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论