提交 c616a7ac authored 作者: David Warde-Farley's avatar David Warde-Farley 提交者: Arnaud Bergeron

Uncontroversial/necessary list() additions around zip().

上级 9733b595
...@@ -101,7 +101,7 @@ def fgraph_updated_vars(fgraph, expanded_inputs): ...@@ -101,7 +101,7 @@ def fgraph_updated_vars(fgraph, expanded_inputs):
potential_values = list(fgraph.outputs) # copy the list potential_values = list(fgraph.outputs) # copy the list
if len(expanded_inputs) != len(fgraph.inputs): if len(expanded_inputs) != len(fgraph.inputs):
raise ValueError('expanded_inputs must match len(fgraph.inputs)') raise ValueError('expanded_inputs must match len(fgraph.inputs)')
for e_input, ivar in reversed(zip(expanded_inputs, fgraph.inputs)): for e_input, ivar in reversed(list(zip(expanded_inputs, fgraph.inputs))):
if e_input.update is not None: if e_input.update is not None:
updated_vars[ivar] = potential_values.pop() updated_vars[ivar] = potential_values.pop()
return updated_vars return updated_vars
...@@ -657,8 +657,8 @@ returned directly?""" ...@@ -657,8 +657,8 @@ returned directly?"""
if getattr(self.fn, 'need_update_inputs', True): if getattr(self.fn, 'need_update_inputs', True):
# Update the inputs that have an update function # Update the inputs that have an update function
for input, storage in reversed(zip(self.maker.expanded_inputs, for input, storage in reversed(list(zip(self.maker.expanded_inputs,
self.input_storage)): self.input_storage))):
if input.update is not None: if input.update is not None:
storage.data = outputs.pop() storage.data = outputs.pop()
else: else:
......
...@@ -150,7 +150,7 @@ class SymbolicInputKit(object): ...@@ -150,7 +150,7 @@ class SymbolicInputKit(object):
ret.sort() ret.sort()
if not ret: if not ret:
return [[], []] return [[], []]
return zip(*ret) return list(zip(*ret))
class In(SymbolicInput): class In(SymbolicInput):
......
...@@ -7,7 +7,7 @@ import traceback ...@@ -7,7 +7,7 @@ import traceback
import numpy import numpy
import theano import theano
from theano.compat import PY3 from theano.compat import PY3, izip
from theano.compat.six import reraise from theano.compat.six import reraise
from theano.compat.six.moves import StringIO from theano.compat.six.moves import StringIO
from theano.gof import utils from theano.gof import utils
...@@ -354,7 +354,7 @@ class Linker(object): ...@@ -354,7 +354,7 @@ class Linker(object):
% (takes, ['argument', 'arguments'][takes > 1], got) % (takes, ['argument', 'arguments'][takes > 1], got)
if (len(args) != len(inputs)): if (len(args) != len(inputs)):
raise TypeError(e_arity(len(inputs), len(args))) raise TypeError(e_arity(len(inputs), len(args)))
for arg, variable in zip(args, inputs): for arg, variable in izip(args, inputs):
variable.data = arg variable.data = arg
thunk() thunk()
if unpack_single: if unpack_single:
...@@ -499,7 +499,7 @@ def map_storage(fgraph, order, input_storage, output_storage): ...@@ -499,7 +499,7 @@ def map_storage(fgraph, order, input_storage, output_storage):
assert len(fgraph.inputs) == len(input_storage) assert len(fgraph.inputs) == len(input_storage)
storage_map = {} storage_map = {}
for r, storage in zip(fgraph.inputs, input_storage): for r, storage in izip(fgraph.inputs, input_storage):
storage_map[r] = storage storage_map[r] = storage
# for orphan in fgraph.orphans: # for orphan in fgraph.orphans:
# if not isinstance(orphan, Constant): # if not isinstance(orphan, Constant):
...@@ -508,7 +508,7 @@ def map_storage(fgraph, order, input_storage, output_storage): ...@@ -508,7 +508,7 @@ def map_storage(fgraph, order, input_storage, output_storage):
if output_storage is not None: if output_storage is not None:
assert len(fgraph.outputs) == len(output_storage) assert len(fgraph.outputs) == len(output_storage)
for r, storage in zip(fgraph.outputs, output_storage): for r, storage in izip(fgraph.outputs, output_storage):
storage_map[r] = storage storage_map[r] = storage
for node in order: for node in order:
...@@ -565,7 +565,7 @@ def streamline(fgraph, thunks, order, post_thunk_old_storage=None, ...@@ -565,7 +565,7 @@ def streamline(fgraph, thunks, order, post_thunk_old_storage=None,
for x in no_recycling: for x in no_recycling:
x[0] = None x[0] = None
try: try:
for thunk, node, old_storage in zip(thunks, order, for thunk, node, old_storage in izip(thunks, order,
post_thunk_old_storage): post_thunk_old_storage):
thunk() thunk()
for old_s in old_storage: for old_s in old_storage:
...@@ -574,13 +574,11 @@ def streamline(fgraph, thunks, order, post_thunk_old_storage=None, ...@@ -574,13 +574,11 @@ def streamline(fgraph, thunks, order, post_thunk_old_storage=None,
raise_with_op(node, thunk) raise_with_op(node, thunk)
f = streamline_default_f f = streamline_default_f
elif nice_errors: elif nice_errors:
thunk_node_list = zip(thunks, order)
def streamline_nice_errors_f(): def streamline_nice_errors_f():
for x in no_recycling: for x in no_recycling:
x[0] = None x[0] = None
try: try:
for thunk, node in thunk_node_list: for thunk, node in izip(thunks, order):
thunk() thunk()
except Exception: except Exception:
raise_with_op(node, thunk) raise_with_op(node, thunk)
...@@ -743,9 +741,13 @@ class PerformLinker(LocalLinker): ...@@ -743,9 +741,13 @@ class PerformLinker(LocalLinker):
add_clear_storage(f, computed, storage_map) add_clear_storage(f, computed, storage_map)
f.storage_map = storage_map f.storage_map = storage_map
return f, [Container(input, storage) for input, storage in zip(fgraph.inputs, input_storage)], \ return (f,
[Container(output, storage, True) for output, storage in zip(fgraph.outputs, output_storage)], \ [Container(input, storage)
thunks, order for input, storage in izip(fgraph.inputs, input_storage)],
[Container(output, storage, True)
for output, storage in izip(fgraph.outputs, output_storage)],
thunks,
order)
def add_clear_storage(f, computed, storage_map): def add_clear_storage(f, computed, storage_map):
...@@ -864,11 +866,11 @@ class WrapLinker(Linker): ...@@ -864,11 +866,11 @@ class WrapLinker(Linker):
inputs0 = input_lists[0] inputs0 = input_lists[0]
outputs0 = output_lists[0] outputs0 = output_lists[0]
thunk_groups = zip(*thunk_lists) thunk_groups = list(zip(*thunk_lists))
order = [x[0] for x in zip(*order_lists)] order = [x[0] for x in zip(*order_lists)]
to_reset = [] to_reset = []
for thunks, node in zip(thunk_groups, order): for thunks, node in izip(thunk_groups, order):
for j, output in enumerate(node.outputs): for j, output in enumerate(node.outputs):
if output in no_recycling: if output in no_recycling:
for thunk in thunks: for thunk in thunks:
...@@ -879,13 +881,13 @@ class WrapLinker(Linker): ...@@ -879,13 +881,13 @@ class WrapLinker(Linker):
def f(): def f():
for inputs in input_lists[1:]: for inputs in input_lists[1:]:
for input1, input2 in zip(inputs0, inputs): for input1, input2 in izip(inputs0, inputs):
input2.storage[0] = copy(input1.storage[0]) input2.storage[0] = copy(input1.storage[0])
for x in to_reset: for x in to_reset:
x[0] = None x[0] = None
pre(self, [input.data for input in input_lists[0]], pre(self, [input.data for input in input_lists[0]],
order, thunk_groups) order, thunk_groups)
for i, (thunks, node) in enumerate(zip(thunk_groups, order)): for i, (thunks, node) in enumerate(izip(thunk_groups, order)):
try: try:
wrapper(i, node, *thunks) wrapper(i, node, *thunks)
except Exception: except Exception:
......
...@@ -253,7 +253,7 @@ class SeqOptimizer(Optimizer, list): ...@@ -253,7 +253,7 @@ class SeqOptimizer(Optimizer, list):
else: else:
ll.append((opt.name, opt.__class__.__name__, ll.append((opt.name, opt.__class__.__name__,
opts.index(opt))) opts.index(opt)))
lll = zip(prof, ll) lll = list(zip(prof, ll))
def cmp(a, b): def cmp(a, b):
if a[0] == b[0]: if a[0] == b[0]:
...@@ -539,7 +539,7 @@ class MergeFeature(object): ...@@ -539,7 +539,7 @@ class MergeFeature(object):
continue continue
# Schedule transfer of clients from node to candidate # Schedule transfer of clients from node to candidate
pairs = zip(node.outputs, candidate.outputs) pairs = izip(node.outputs, candidate.outputs)
# transfer names # transfer names
for node_output, cand_output in pairs: for node_output, cand_output in pairs:
......
...@@ -595,7 +595,7 @@ class CondMerge(gof.Optimizer): ...@@ -595,7 +595,7 @@ class CondMerge(gof.Optimizer):
old_outs += [proposal.outputs] old_outs += [proposal.outputs]
else: else:
old_outs += proposal.outputs old_outs += proposal.outputs
pairs = zip(old_outs, new_outs) pairs = list(zip(old_outs, new_outs))
fgraph.replace_all_validate(pairs, reason='cond_merge') fgraph.replace_all_validate(pairs, reason='cond_merge')
...@@ -699,7 +699,7 @@ def cond_merge_random_op(main_node): ...@@ -699,7 +699,7 @@ def cond_merge_random_op(main_node):
old_outs += [proposal.outputs] old_outs += [proposal.outputs]
else: else:
old_outs += proposal.outputs old_outs += proposal.outputs
pairs = zip(old_outs, new_outs) pairs = list(zip(old_outs, new_outs))
main_outs = clone(main_node.outputs, replace=pairs) main_outs = clone(main_node.outputs, replace=pairs)
return main_outs return main_outs
......
...@@ -235,9 +235,9 @@ class PycudaElemwiseSourceModuleOp(GpuOp): ...@@ -235,9 +235,9 @@ class PycudaElemwiseSourceModuleOp(GpuOp):
tuple([n + "[i]" for n in in_name]), tuple([n + "[i]" for n in in_name]),
tuple(n + "[i]" for n in out_name), {}) tuple(n + "[i]" for n in out_name), {})
c_code_param = ", ".join([_replace_npy_types(var.type.dtype_specs()[1]) + " *" + name c_code_param = ", ".join([_replace_npy_types(var.type.dtype_specs()[1]) + " *" + name
for var, name in (zip(inputs, in_name) + for var, name in (list(zip(inputs, in_name)) +
zip(out_node.outputs, list(zip(out_node.outputs,
out_name))] + out_name)))] +
["int size"]) ["int size"])
mod = SourceModule(""" mod = SourceModule("""
__global__ void %s(%s) __global__ void %s(%s)
...@@ -326,8 +326,8 @@ class PycudaElemwiseSourceModuleMakeThunkOp(Op): ...@@ -326,8 +326,8 @@ class PycudaElemwiseSourceModuleMakeThunkOp(Op):
tuple(n + "[i]" for n in out_name), {}) tuple(n + "[i]" for n in out_name), {})
c_code_param = ", ".join([_replace_npy_types(var.type.dtype_specs()[1]) + " *" + name c_code_param = ", ".join([_replace_npy_types(var.type.dtype_specs()[1]) + " *" + name
for var, name in for var, name in
zip(node.inputs, in_name) + list(zip(node.inputs, in_name)) +
zip(node.outputs, out_name)] + ["int size"]) list(zip(node.outputs, out_name))] + ["int size"])
mod = SourceModule(""" mod = SourceModule("""
__global__ void %s(%s) __global__ void %s(%s)
{ {
......
...@@ -2284,8 +2284,8 @@ def gpuScanOptimization(node): ...@@ -2284,8 +2284,8 @@ def gpuScanOptimization(node):
scan_outs = [safe_to_gpu(x) for x in thescan.outputs] scan_outs = [safe_to_gpu(x) for x in thescan.outputs]
scan_outs = scan_utils.clone( scan_outs = scan_utils.clone(
scan_outs, scan_outs,
replace=zip(thescan.inputs, replace=list(zip(thescan.inputs,
[safe_to_cpu(x) for x in scan_ins])) (safe_to_cpu(x) for x in scan_ins))))
# We need to construct the hash here, because scan # We need to construct the hash here, because scan
# __init__ does not know about cuda ndarray and can not # __init__ does not know about cuda ndarray and can not
# handle graphs with inputs being Cuda Ndarrays # handle graphs with inputs being Cuda Ndarrays
...@@ -2330,8 +2330,8 @@ def gpuScanOptimization(node): ...@@ -2330,8 +2330,8 @@ def gpuScanOptimization(node):
scan_outs = [safe_to_gpu(x) for x in thescan.outputs] scan_outs = [safe_to_gpu(x) for x in thescan.outputs]
scan_outs = scan_utils.clone( scan_outs = scan_utils.clone(
scan_outs, scan_outs,
replace=zip(thescan.inputs, replace=list(zip(thescan.inputs,
[safe_to_cpu(x) for x in scan_ins])) (safe_to_cpu(x) for x in scan_ins))))
# We need to construct the hash here, because scan # We need to construct the hash here, because scan
# __init__ does not know about cuda ndarray and can not # __init__ does not know about cuda ndarray and can not
......
...@@ -787,8 +787,8 @@ def local_scan_to_gpua(node): ...@@ -787,8 +787,8 @@ def local_scan_to_gpua(node):
scan_outs = [safe_to_gpu(x) for x in node.op.outputs] scan_outs = [safe_to_gpu(x) for x in node.op.outputs]
scan_outs = scan_utils.clone( scan_outs = scan_utils.clone(
scan_outs, scan_outs,
replace=zip(node.op.inputs, replace=list(zip(node.op.inputs,
[safe_to_cpu(x) for x in scan_ins])) (safe_to_cpu(x) for x in scan_ins))))
# We need to construct the hash here, because scan # We need to construct the hash here, because scan
# __init__ does not know about the gpu and can not # __init__ does not know about the gpu and can not
......
...@@ -3293,11 +3293,9 @@ class Composite(ScalarOp): ...@@ -3293,11 +3293,9 @@ class Composite(ScalarOp):
def init_c_code(self): def init_c_code(self):
"""Return the C code for this Composite Op. """ """Return the C code for this Composite Op. """
subd = dict( subd = dict(chain(
zip(self.fgraph.inputs, ((e, "%%(i%i)s" % i) for i, e in enumerate(self.fgraph.inputs)),
["%%(i%i)s" % i for i in xrange(len(self.fgraph.inputs))]) ((e, "%%(o%i)s" % i) for i, e in enumerate(self.fgraph.outputs))))
+ zip(self.fgraph.outputs,
["%%(o%i)s" % i for i in xrange(len(self.fgraph.outputs))]))
for var in self.fgraph.variables: for var in self.fgraph.variables:
if var.owner is None: if var.owner is None:
......
...@@ -346,7 +346,7 @@ class PushOutNonSeqScan(gof.Optimizer): ...@@ -346,7 +346,7 @@ class PushOutNonSeqScan(gof.Optimizer):
**dict(return_list=True))[0].owner **dict(return_list=True))[0].owner
fgraph.replace_all_validate_remove( fgraph.replace_all_validate_remove(
zip(node.outputs, nw_node.outputs), list(zip(node.outputs, nw_node.outputs)),
remove=[node], remove=[node],
reason='scanOp_pushout_nonseqs_ops') reason='scanOp_pushout_nonseqs_ops')
return True return True
...@@ -558,7 +558,7 @@ class PushOutSeqScan(gof.Optimizer): ...@@ -558,7 +558,7 @@ class PushOutSeqScan(gof.Optimizer):
**dict(return_list=True))[0].owner **dict(return_list=True))[0].owner
fgraph.replace_all_validate_remove( fgraph.replace_all_validate_remove(
zip(node.outputs, nw_node.outputs), list(zip(node.outputs, nw_node.outputs)),
remove=[node], remove=[node],
reason='scanOp_pushout_seqs_ops') reason='scanOp_pushout_seqs_ops')
return True return True
...@@ -921,7 +921,7 @@ class PushOutScanOutput(gof.Optimizer): ...@@ -921,7 +921,7 @@ class PushOutScanOutput(gof.Optimizer):
new_scan_node.outputs[new_node_new_outputs_idx+nb_new_outs:]) new_scan_node.outputs[new_node_new_outputs_idx+nb_new_outs:])
fgraph.replace_all_validate_remove( fgraph.replace_all_validate_remove(
zip(old_scan_node.outputs, new_node_old_outputs), list(zip(old_scan_node.outputs, new_node_old_outputs)),
remove=[old_scan_node], remove=[old_scan_node],
reason='scanOp_pushout_output') reason='scanOp_pushout_output')
...@@ -981,7 +981,7 @@ class ScanInplaceOptimizer(Optimizer): ...@@ -981,7 +981,7 @@ class ScanInplaceOptimizer(Optimizer):
new_outs = new_op(*inputs, **dict(return_list=True)) new_outs = new_op(*inputs, **dict(return_list=True))
try: try:
fgraph.replace_all_validate_remove( fgraph.replace_all_validate_remove(
zip(node.outputs, new_outs), list(zip(node.outputs, new_outs)),
remove=[node], remove=[node],
reason='scanOp_make_inplace') reason='scanOp_make_inplace')
op = new_op op = new_op
...@@ -1702,7 +1702,7 @@ class ScanMerge(gof.Optimizer): ...@@ -1702,7 +1702,7 @@ class ScanMerge(gof.Optimizer):
if not isinstance(new_outs, (list, tuple)): if not isinstance(new_outs, (list, tuple)):
new_outs = [new_outs] new_outs = [new_outs]
return zip(outer_outs, new_outs) return list(zip(outer_outs, new_outs))
def belongs_to_set(self, node, set_nodes): def belongs_to_set(self, node, set_nodes):
""" """
...@@ -2126,10 +2126,10 @@ class PushOutDot1(gof.Optimizer): ...@@ -2126,10 +2126,10 @@ class PushOutDot1(gof.Optimizer):
new_out = tensor.dot(val, out_seq) new_out = tensor.dot(val, out_seq)
pos = node.outputs.index(outer_out) pos = node.outputs.index(outer_out)
old_new = zip(node.outputs[:pos], new_outs[:pos]) old_new = list(zip(node.outputs[:pos], new_outs[:pos]))
old = node.outputs[pos].clients[0][0].outputs[0] old = node.outputs[pos].clients[0][0].outputs[0]
old_new.append((old, new_out)) old_new.append((old, new_out))
old_new += zip(node.outputs[pos+1:], new_outs[pos:]) old_new += list(zip(node.outputs[pos+1:], new_outs[pos:]))
fgraph.replace_all_validate_remove( fgraph.replace_all_validate_remove(
old_new, remove=[node], reason='scan_pushout_dot1') old_new, remove=[node], reason='scan_pushout_dot1')
......
...@@ -4479,7 +4479,7 @@ class ScanGpuTests: ...@@ -4479,7 +4479,7 @@ class ScanGpuTests:
# Compute the cost and take the gradient wrt params # Compute the cost and take the gradient wrt params
cost = tensor.sum((l2_out - yout) ** 2) cost = tensor.sum((l2_out - yout) ** 2)
grads = tensor.grad(cost, nparams) grads = tensor.grad(cost, nparams)
updates = zip(nparams, [n - g for n, g in zip(nparams, grads)]) updates = list(zip(nparams, (n - g for n, g in zip(nparams, grads))))
# Compile the theano function # Compile the theano function
feval_backprop = theano.function([xin, yout], cost, updates=updates, feval_backprop = theano.function([xin, yout], cost, updates=updates,
......
...@@ -1578,7 +1578,7 @@ class GemmOptimizer(Optimizer): ...@@ -1578,7 +1578,7 @@ class GemmOptimizer(Optimizer):
assert len(new_outputs) == len(node.outputs) assert len(new_outputs) == len(node.outputs)
try: try:
fgraph.replace_all_validate_remove( fgraph.replace_all_validate_remove(
zip(node.outputs, new_outputs), list(zip(node.outputs, new_outputs)),
[old_dot22], [old_dot22],
reason='GemmOptimizer', reason='GemmOptimizer',
# For now we disable the warning as we know case # For now we disable the warning as we know case
......
...@@ -787,7 +787,7 @@ class Elemwise(OpenMPOp): ...@@ -787,7 +787,7 @@ class Elemwise(OpenMPOp):
super(Elemwise, self).perform(node, inputs, output_storage) super(Elemwise, self).perform(node, inputs, output_storage)
maxsize = max(len(input.shape) for input in inputs) maxsize = max(len(input.shape) for input in inputs)
for dims in izip(*[zip(input.shape, sinput.type.broadcastable) for dims in izip(*[list(zip(input.shape, sinput.type.broadcastable))
for input, sinput in zip(inputs, node.inputs)]): for input, sinput in zip(inputs, node.inputs)]):
if max(d for d, b in dims) != 1 and (1, False) in dims: if max(d for d, b in dims) != 1 and (1, False) in dims:
# yes there may be more compact ways to write this code, # yes there may be more compact ways to write this code,
...@@ -930,7 +930,7 @@ class Elemwise(OpenMPOp): ...@@ -930,7 +930,7 @@ class Elemwise(OpenMPOp):
# assert that inames and inputs order stay consistent. # assert that inames and inputs order stay consistent.
# This is to protect again futur change of uniq. # This is to protect again futur change of uniq.
assert len(inames) == len(inputs) assert len(inames) == len(inputs)
ii, iii = zip(*gof.utils.uniq(zip(_inames, node.inputs))) ii, iii = list(zip(*gof.utils.uniq(list(zip(_inames, node.inputs)))))
assert all([x == y for x, y in zip(ii, inames)]) assert all([x == y for x, y in zip(ii, inames)])
assert all([x == y for x, y in zip(iii, inputs)]) assert all([x == y for x, y in zip(iii, inputs)])
...@@ -948,8 +948,9 @@ class Elemwise(OpenMPOp): ...@@ -948,8 +948,9 @@ class Elemwise(OpenMPOp):
# These are the outputs that we will need to allocate # These are the outputs that we will need to allocate
# (output, name, name of the c type), transposed # (output, name, name of the c type), transposed
real = zip(*[(r, s, r.type.dtype_specs()[1]) real = list(zip(*[(r, s, r.type.dtype_specs()[1])
for r, s in izip(node.outputs, onames) if r not in dmap]) for r, s in izip(node.outputs, onames)
if r not in dmap]))
if real: if real:
real_outputs, real_onames, real_odtypes = real real_outputs, real_onames, real_odtypes = real
else: else:
...@@ -958,8 +959,9 @@ class Elemwise(OpenMPOp): ...@@ -958,8 +959,9 @@ class Elemwise(OpenMPOp):
# Outputs that are aliased with an input (inplace) # Outputs that are aliased with an input (inplace)
# (output, name), transposed (c type name not needed since we don't # (output, name), transposed (c type name not needed since we don't
# need to allocate. # need to allocate.
aliased = zip(*[(r, s) aliased = list(zip(*[(r, s)
for (r, s) in izip(node.outputs, onames) if r in dmap]) for (r, s) in izip(node.outputs, onames)
if r in dmap]))
if aliased: if aliased:
aliased_outputs, aliased_onames = aliased aliased_outputs, aliased_onames = aliased
else: else:
...@@ -985,7 +987,7 @@ class Elemwise(OpenMPOp): ...@@ -985,7 +987,7 @@ class Elemwise(OpenMPOp):
# Check if all inputs (except broadcasted scalar) are fortran. # Check if all inputs (except broadcasted scalar) are fortran.
# In that case, create an fortran output ndarray. # In that case, create an fortran output ndarray.
z = zip(inames, inputs) z = list(zip(inames, inputs))
alloc_fortran = ' && '.join(["PyArray_ISFORTRAN(%s)" % arr alloc_fortran = ' && '.join(["PyArray_ISFORTRAN(%s)" % arr
for arr, var in z for arr, var in z
if not all(var.broadcastable)]) if not all(var.broadcastable)])
...@@ -1156,7 +1158,7 @@ class Elemwise(OpenMPOp): ...@@ -1156,7 +1158,7 @@ class Elemwise(OpenMPOp):
} }
""" % locals() """ % locals()
if contig is not None: if contig is not None:
z = zip(inames + onames, inputs + node.outputs) z = list(zip(inames + onames, inputs + node.outputs))
cond1 = ' && '.join(["PyArray_ISCONTIGUOUS(%s)" % arr cond1 = ' && '.join(["PyArray_ISCONTIGUOUS(%s)" % arr
for arr, var in z for arr, var in z
if not all(var.broadcastable)]) if not all(var.broadcastable)])
......
...@@ -236,7 +236,7 @@ def make_loop(loop_orders, dtypes, loop_tasks, sub, openmp=None): ...@@ -236,7 +236,7 @@ def make_loop(loop_orders, dtypes, loop_tasks, sub, openmp=None):
s = "" s = ""
for i, (pre_task, task), indices in reversed(zip(xrange(len(loop_tasks) - 1), loop_tasks, zip(*loop_orders))): for i, (pre_task, task), indices in reversed(list(zip(xrange(len(loop_tasks) - 1), loop_tasks, list(zip(*loop_orders))))):
s = loop_over(preloops.get(i, "") + pre_task, s + task, indices, i) s = loop_over(preloops.get(i, "") + pre_task, s + task, indices, i)
s += loop_tasks[-1] s += loop_tasks[-1]
...@@ -521,7 +521,7 @@ def make_loop_careduce(loop_orders, dtypes, loop_tasks, sub): ...@@ -521,7 +521,7 @@ def make_loop_careduce(loop_orders, dtypes, loop_tasks, sub):
s = preloops.get(0, "") s = preloops.get(0, "")
else: else:
s = "" s = ""
for i, (pre_task, task), indices in reversed(zip(xrange(len(loop_tasks) - 1), loop_tasks, zip(*loop_orders))): for i, (pre_task, task), indices in reversed(list(zip(xrange(len(loop_tasks) - 1), loop_tasks, list(zip(*loop_orders))))):
s = loop_over(preloops.get(i, "") + pre_task, s + task, indices, i) s = loop_over(preloops.get(i, "") + pre_task, s + task, indices, i)
s += loop_tasks[-1] s += loop_tasks[-1]
......
...@@ -5776,7 +5776,7 @@ class FusionOptimizer(Optimizer): ...@@ -5776,7 +5776,7 @@ class FusionOptimizer(Optimizer):
assert len(new_outputs) == len(node.outputs) assert len(new_outputs) == len(node.outputs)
try: try:
fgraph.replace_all_validate( fgraph.replace_all_validate(
zip(node.outputs, new_outputs), list(zip(node.outputs, new_outputs)),
reason=self.__class__.__name__) reason=self.__class__.__name__)
did_something = True did_something = True
nb_replacement += 1 nb_replacement += 1
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论