提交 613a642a authored 作者: Razvan Pascanu's avatar Razvan Pascanu

added function to do constant folding on indices before introducing them

into the graph
上级 246a557b
......@@ -1168,6 +1168,20 @@ def merge_two_slices(slice1, len1, slice2, len2):
``len1`` is the length of the tensor **before** applying the first slice,
while ``len2`` is the length **after** applying the first slice.
'''
def const_fold(n):
while True:
ret = constant_folding.transform(n)
if ret is not False and ret is not None:
#print n,ret
assert len(ret)==len(n.outputs)
assert len(ret)==1
n = ret[0].owner
else: break
return n.outputs
if type(slice1) is not slice:
raise ValueError( ('First provided slice should actually be of type'
'slice and not an index !'),slice1)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论