提交 e574a994 authored 作者: Hengjean's avatar Hengjean

Added check_input flag

上级 17f1b0fa
......@@ -489,3 +489,10 @@ AddConfigVar('openmp_elemwise_minsize',
IntParam(200000),
in_c_key=False,
)
AddConfigVar('check_input',
"Specify if types should check their input in their C code. "
"It can be used to speed up compilation, reduce overhead"
"(particularly for scalars) and reduce the number of generated C"
"files.",
BoolParam(True))
......@@ -294,7 +294,7 @@ class CudaNdarrayType(Type):
%(name)s = (CudaNdarray*)py_%(name)s;
//std::cerr << "c_extract " << %(name)s << '\\n';
""" % locals()
if(check_input):
if(check_input and theano.config.check_input):
print >> sio, """
if (%(name)s->nd != %(nd)s)
{
......
......@@ -273,7 +273,7 @@ class Scalar(Type):
def c_extract(self, name, sub, check_input=True):
specs = self.dtype_specs()
if(check_input):
if(check_input and theano.config.check_input):
pre = """
if (!PyObject_TypeCheck(py_%(name)s, &%(pyarr_type)s))
{
......
......@@ -438,7 +438,7 @@ class TensorType(Type):
def c_extract(self, name, sub, check_input=True):
"""Override `CLinkerType.c_extract` """
if(check_input):
if(check_input and theano.config.check_input):
check = """
%(name)s = NULL;
if (py_%(name)s == Py_None) {
......
......@@ -246,7 +246,7 @@ class T_extending(unittest.TestCase):
double.c_init = c_init
def c_extract(name, sub, check_input=True):
if(check_input):
if(check_input and theano.config.check_input):
pre = """
if (!PyFloat_Check(py_%(name)s)) {
PyErr_SetString(PyExc_TypeError, "expected a float");
......@@ -310,7 +310,7 @@ class T_extending(unittest.TestCase):
""" % dict(name = name)
def c_extract(self, name, sub, check_input=True):
if(check_input):
if(check_input and theano.config.check_input):
pre = """
if (!PyFloat_Check(py_%(name)s)) {
PyErr_SetString(PyExc_TypeError, "expected a float");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论