提交 ac4d5af8 authored 作者: Frederic Bastien's avatar Frederic Bastien

Add TypedListConstant. This fix the added test.

上级 73dfccfb
...@@ -53,6 +53,15 @@ class TypedListVariable(_typed_list_py_operators, Variable): ...@@ -53,6 +53,15 @@ class TypedListVariable(_typed_list_py_operators, Variable):
TypedListType.Variable = TypedListVariable TypedListType.Variable = TypedListVariable
class TypedListConstant(_typed_list_py_operators, Constant):
"""
Subclass to add the typed list operators to the basic `Variable` class.
"""
TypedListType.Constant = TypedListConstant
class GetItem(Op): class GetItem(Op):
# See doc in instance of this Op or function after this class definition. # See doc in instance of this Op or function after this class definition.
view_map = {0: [0]} view_map = {0: [0]}
......
...@@ -110,3 +110,13 @@ class test_inplace(unittest.TestCase): ...@@ -110,3 +110,13 @@ class test_inplace(unittest.TestCase):
y = rand_ranged_matrix(-1000, 1000, [100, 101]) y = rand_ranged_matrix(-1000, 1000, [100, 101])
self.assertTrue(numpy.array_equal(f([x, y], y), [x])) self.assertTrue(numpy.array_equal(f([x, y], y), [x]))
def test_constant_folding():
m = theano.tensor.ones((1,), dtype='int8')
l = theano.typed_list.make_list([m, m])
f = theano.function([], l)
topo = f.maker.fgraph.toposort()
assert len(topo)
assert isinstance(topo[0].op, theano.compile.ops.DeepCopyOp)
assert f() == [1, 1]
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论