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

list(zip()) + ... -> chain(izip()..) in pycuda_example.py

上级 0bbab8e7
......@@ -539,7 +539,7 @@ class MergeFeature(object):
continue
# Schedule transfer of clients from node to candidate
pairs = izip(node.outputs, candidate.outputs)
pairs = list(zip(node.outputs, candidate.outputs))
# transfer names
for node_output, cand_output in pairs:
......
......@@ -19,12 +19,13 @@ pycuda.elementwise.ElementwiseKernel. It must be wrapper by
TheanoElementwiseKernel.
"""
from itertools import chain
import numpy
import theano
from six import string_types
from six.moves import xrange
from theano.compat import izip
from theano.gof import Op, Apply, local_optimizer, EquilibriumDB
from theano.sandbox.cuda import GpuElemwise, CudaNdarrayType, GpuOp
from theano.sandbox.cuda.basic_ops import (as_cuda_ndarray_variable,
......@@ -234,11 +235,12 @@ class PycudaElemwiseSourceModuleOp(GpuOp):
c_code = self.scalar_op.c_code(out_node, "some_name",
tuple([n + "[i]" for n in in_name]),
tuple(n + "[i]" for n in out_name), {})
c_code_param = ", ".join([_replace_npy_types(var.type.dtype_specs()[1]) + " *" + name
for var, name in (list(zip(inputs, in_name)) +
list(zip(out_node.outputs,
out_name)))] +
["int size"])
c_code_param = ", ".join([
_replace_npy_types(var.type.dtype_specs()[1]) + " *" + name
for var, name in chain(izip(inputs, in_name),
izip(out_node.outputs,
out_name))
] + ["int size"])
mod = SourceModule("""
__global__ void %s(%s)
{
......@@ -324,10 +326,12 @@ class PycudaElemwiseSourceModuleMakeThunkOp(Op):
c_code = self.scalar_op.c_code(node, "some_name",
tuple([n + "[i]" for n in in_name]),
tuple(n + "[i]" for n in out_name), {})
c_code_param = ", ".join([_replace_npy_types(var.type.dtype_specs()[1]) + " *" + name
for var, name in
list(zip(node.inputs, in_name)) +
list(zip(node.outputs, out_name))] + ["int size"])
c_code_param = ", ".join(
[_replace_npy_types(var.type.dtype_specs()[1]) + " *" + name
for var, name in chain(izip(node.inputs, in_name),
izip(node.outputs, out_name))]
+ ["int size"])
mod = SourceModule("""
__global__ void %s(%s)
{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论