提交 3c755c69 authored 作者: Faruk Ahmed's avatar Faruk Ahmed 提交者: Frederic Bastien

ifelse - inherit from Op, rename make_thunk to make_py_thunk; scan - added make_py_thunk func

上级 7fa59095
......@@ -20,7 +20,7 @@ import numpy
import theano.tensor
from theano.tensor import TensorType
from theano import gof
from theano.gof import PureOp, Apply
from theano.gof import Op, Apply
from six import iteritems
from six.moves import xrange
......@@ -41,7 +41,7 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
_logger = logging.getLogger('theano.ifelse')
class IfElse(PureOp):
class IfElse(Op):
"""
Op that provides conditional graph evaluation if used with the CVM/VM
linkers. Note that there exist a helpful function `ifelse` that should
......@@ -235,7 +235,7 @@ class IfElse(PureOp):
if_true_op(*if_true, **dict(return_list=True)) +
if_false_op(*if_false, **dict(return_list=True)))
def make_thunk(self, node, storage_map, compute_map, no_recycling):
def make_py_thunk(self, node, storage_map, compute_map, no_recycling):
cond = node.inputs[0]
ts = node.inputs[1:][:self.n_outs]
fs = node.inputs[1:][self.n_outs:]
......
......@@ -697,7 +697,8 @@ class Scan(PureOp):
self._hash_inner_graph,
scan_utils.hash_listsDictsTuples(self.info)))
def make_thunk(self, node, storage_map, compute_map, no_recycling):
def make_thunk(self, node, storage_map, compute_map, no_recycling,
python_exec=False):
"""
Parameters
......@@ -715,7 +716,8 @@ class Scan(PureOp):
no_recycling
List of variables for which it is forbidden to reuse memory
allocated by a previous call.
python_exec
If we want python execution.
Notes
-----
If the thunk consults the storage_map on every call, it is safe
......@@ -864,6 +866,8 @@ class Scan(PureOp):
for out in self.fn.maker.fgraph.outputs]
try:
if python_exec is True:
raise theano.gof.cmodule.MissingGXX
cython_mintaps = numpy.asarray(self.mintaps, dtype='int32')
cython_tap_array_len = \
numpy.asarray([len(x) for x in self.tap_array],
......@@ -961,6 +965,13 @@ class Scan(PureOp):
rval.lazy = False
return rval
def make_py_thunk(self, node, storage_map, compute_map, no_recycling):
return self.make_thunk(node=node,
storage_map=storage_map,
compute_map=compute_map,
no_recycling=no_recycling,
python_exec=True)
def inner_seqs(self, list_inputs):
# Given the list of inner inputs this function grabs those
# corresponding to sequences
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论