提交 5cfd421a authored 作者: Frederic's avatar Frederic

Fix c code in example and add c_code_cache_version.

上级 4662adeb
...@@ -65,13 +65,19 @@ you should check the strides and alignment. ...@@ -65,13 +65,19 @@ you should check the strides and alignment.
Py_XDECREF(%(y)s); Py_XDECREF(%(y)s);
%(y)s = (PyArrayObject*)PyArray_FromArray( %(y)s = (PyArrayObject*)PyArray_FromArray(
%(x)s, 0, NPY_ARRAY_ENSURECOPY); %(x)s, 0, NPY_ARRAY_ENSURECOPY);
if (!(%y)s) %(fail)s; if (!%(y)s)
dtype_%(y)s * y = (dtype_%(y)s*)%(y)s->data; %(fail)s;
dtype_%(x)s * x = (dtype_%(x)s*)%(x)s->data; {//New scope needed to make compilation work
for (int i = 2; i < %(x)s->dimensions[0]; ++i) dtype_%(y)s * y = (dtype_%(y)s*)%(y)s->data;
y[i] = y[i-1]*y[i-2] + x[i]; dtype_%(x)s * x = (dtype_%(x)s*)%(x)s->data;
for (int i = 2; i < %(x)s->dimensions[0]; ++i)
y[i] = y[i-1]*y[i-2] + x[i];
}
""" % locals() """ % locals()
def c_code_cache_version(self):
return (1,)
fibby = Fibby() fibby = Fibby()
At a high level, the code fragment declares a class (``Fibby``) and then At a high level, the code fragment declares a class (``Fibby``) and then
......
...@@ -920,13 +920,19 @@ class T_fibby(unittest.TestCase): ...@@ -920,13 +920,19 @@ class T_fibby(unittest.TestCase):
Py_XDECREF(%(y)s); Py_XDECREF(%(y)s);
%(y)s = (PyArrayObject*)PyArray_FromArray( %(y)s = (PyArrayObject*)PyArray_FromArray(
%(x)s, 0, NPY_ARRAY_ENSURECOPY); %(x)s, 0, NPY_ARRAY_ENSURECOPY);
if (!(%y)s) %(fail)s; if (!%(y)s)
dtype_%(y)s * y = (dtype_%(y)s*)%(y)s->data; %(fail)s;
dtype_%(x)s * x = (dtype_%(x)s*)%(x)s->data; {//New scope needed to make compilation work
for (int i = 2; i < %(x)s->dimensions[0]; ++i) dtype_%(y)s * y = (dtype_%(y)s*)%(y)s->data;
y[i] = y[i-1]*y[i-2] + x[i]; dtype_%(x)s * x = (dtype_%(x)s*)%(x)s->data;
for (int i = 2; i < %(x)s->dimensions[0]; ++i)
y[i] = y[i-1]*y[i-2] + x[i];
}
""" % locals() """ % locals()
def c_code_cache_version(self):
return (1,)
fibby = Fibby() fibby = Fibby()
from theano.tensor.opt import (get_scalar_constant_value, from theano.tensor.opt import (get_scalar_constant_value,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论