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