提交 c624c7b5 authored 作者: ChienliMa's avatar ChienliMa

small change to fix python3

上级 2ddb82a9
...@@ -5,7 +5,7 @@ Driver of graph construction, optimization, and linking. ...@@ -5,7 +5,7 @@ Driver of graph construction, optimization, and linking.
from __future__ import print_function from __future__ import print_function
import copy import copy
from six import string_types, iteritems from six import string_types, iteritems, iterkeys
from six.moves import xrange from six.moves import xrange
import six.moves.copyreg as copyreg import six.moves.copyreg as copyreg
import six.moves.cPickle as pickle import six.moves.cPickle as pickle
...@@ -613,11 +613,10 @@ class Function(object): ...@@ -613,11 +613,10 @@ class Function(object):
# swap SharedVariable # swap SharedVariable
if swap is not None: if swap is not None:
swap_svs_ori = swap.keys()
exist_svs = [i.variable for i in maker.inputs] exist_svs = [i.variable for i in maker.inputs]
# Check if given ShareVariables exist # Check if given ShareVariables exist
for sv in swap_svs_ori: for sv in iterkeys(swap):
if sv not in exist_svs: if sv not in exist_svs:
raise ValueError("SharedVariable: %s not found" % raise ValueError("SharedVariable: %s not found" %
(sv.name)) (sv.name))
...@@ -629,7 +628,7 @@ class Function(object): ...@@ -629,7 +628,7 @@ class Function(object):
# Otherwise we don't touch them. # Otherwise we don't touch them.
var = maker.inputs[index].variable var = maker.inputs[index].variable
if var in swap_svs_ori: if var in iterkeys(swap):
swap_sv = swap[var] swap_sv = swap[var]
checkSV(i.variable, swap_sv) checkSV(i.variable, swap_sv)
...@@ -702,7 +701,7 @@ class Function(object): ...@@ -702,7 +701,7 @@ class Function(object):
f_cpy.input_storage): f_cpy.input_storage):
# Share immutable ShareVariable and constant input's storage # Share immutable ShareVariable and constant input's storage
swapped = swap is not None and in_ori.variable in swap_svs_ori swapped = swap is not None and swap.has_key(in_ori.variable)
# Using the original storage if SharedVariable will not be updated # Using the original storage if SharedVariable will not be updated
# and is not swapped # and is not swapped
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论