提交 4bcf7de7 authored 作者: nouiz's avatar nouiz

Merge pull request #713 from abergeron/cvm_gc

Update the GC in CVM to match what is done for VM.
......@@ -771,6 +771,7 @@ int lazy_rec_eval(CLazyLinker * self, Py_ssize_t var_idx, PyObject*one, PyObject
Py_INCREF(Py_None);
err = PyList_SetItem(self->var_value_cells[i_idx], 0, Py_None);
self->var_computed[i_idx] = 0;
if (err) goto fail;
}
}
......@@ -863,6 +864,33 @@ CLazyLinker_call(PyObject *_self, PyObject *args, PyObject *kwds)
}
}
}
/*
Clear everything that is left and not an output. This is needed
for lazy evaluation since the current GC algo is too conservative
with lazy graphs.
*/
if (self->allow_gc && !err)
{
for (Py_ssize_t i = 0; i < self->n_vars; ++i)
{
int do_cleanup = 1;
if (!self->var_has_owner[i] || !self->var_computed[i])
continue;
for (int j = 0; j < self->n_output_vars; ++j)
{
if (i == self->output_vars[j])
{
do_cleanup = 0;
break;
}
}
if (!do_cleanup)
continue;
Py_INCREF(Py_None);
PyList_SetItem(self->var_value_cells[i], 0, Py_None);
}
}
Py_DECREF(one);
Py_DECREF(zero);
if (err)
......@@ -944,7 +972,7 @@ static PyTypeObject lazylinker_ext_CLazyLinkerType = {
static PyObject * get_version(PyObject *dummy, PyObject *args)
{
PyObject *result = PyFloat_FromDouble(0.15);
PyObject *result = PyFloat_FromDouble(0.17);
return result;
}
......
......@@ -13,7 +13,7 @@ if config.compiledir not in sys.path:
sys.path.append(config.compiledir)
force_compile = False
version = 0.15 # must match constant returned in function get_version()
version = 0.17 # must match constant returned in function get_version()
try:
......
......@@ -408,9 +408,8 @@ class Stack(VM):
# lazy evaluation. See discussion on theano-dev June 19 2012.
if self.allow_gc:
for v in storage_map:
if v.owner and 'output' not in zip(*v.clients)[0]:
if v.owner and not v in self.outputs:
storage_map[v][0] = None
compute_map[v][0] = 0
try:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论