提交 254dd8b7 authored 作者: Frederic's avatar Frederic

small code cleanup

上级 1d823666
...@@ -5,11 +5,11 @@ from StringIO import StringIO ...@@ -5,11 +5,11 @@ from StringIO import StringIO
import numpy import numpy
import theano import theano
from theano import Op, Apply, scalar, config from theano import Apply, scalar, config
from theano import scalar as scal from theano import scalar as scal
from theano.scalar import Scalar from theano.scalar import Scalar
from theano.tensor.elemwise import (Elemwise, DimShuffle, from theano.tensor.elemwise import (Elemwise, DimShuffle,
CAReduce, CAReduceDtype) CAReduceDtype)
from theano.sandbox.cuda.nvcc_compiler import NVCC_compiler from theano.sandbox.cuda.nvcc_compiler import NVCC_compiler
try: try:
...@@ -76,12 +76,8 @@ class GpuElemwise(HideC, Elemwise): ...@@ -76,12 +76,8 @@ class GpuElemwise(HideC, Elemwise):
# Try to generate the kernel to catch SupportCodeErrors # Try to generate the kernel to catch SupportCodeErrors
try: try:
inps = [make_argument(i, 'i%d' % (n,)) for n, i in
enumerate(node.inputs)]
scal_ins = [scalar.get_scalar_type(i.dtype) for i in node.inputs] scal_ins = [scalar.get_scalar_type(i.dtype) for i in node.inputs]
outs = [make_argument(o, 'o%d' % (n,)) for n, o in
enumerate(node.outputs) if not n in self.inplace_pattern]
scal_out = [scalar.get_scalar_type(o.dtype) for o in node.outputs] scal_out = [scalar.get_scalar_type(o.dtype) for o in node.outputs]
fake_node = Apply(self.scalar_op, [i() for i in scal_ins], fake_node = Apply(self.scalar_op, [i() for i in scal_ins],
...@@ -404,7 +400,7 @@ class GpuElemwise(HideC, Elemwise): ...@@ -404,7 +400,7 @@ class GpuElemwise(HideC, Elemwise):
param.append("PyGpuArray_DIMS(%(name)s)[%(i)d] == 1 ? 0 : PyGpuArray_STRIDES(%(name)s)[%(i)d]" % locals()) param.append("PyGpuArray_DIMS(%(name)s)[%(i)d] == 1 ? 0 : PyGpuArray_STRIDES(%(name)s)[%(i)d]" % locals())
code += ',\n'.join(param) + ");\n" code += ',\n'.join(param) + ");\n"
if config.gpuarray.sync: if config.gpuarray.sync:
code += "GpuArray_sync(&%(zz)s->ga);\n" % dict(zz=zz) code += "GpuArray_sync(&%(z)s->ga);\n" % dict(z=z)
return str(code) return str(code)
def perform(self, node, inputs, output_storage): def perform(self, node, inputs, output_storage):
...@@ -845,7 +841,7 @@ class GpuCAReduceCuda(HideC, CAReduceDtype): ...@@ -845,7 +841,7 @@ class GpuCAReduceCuda(HideC, CAReduceDtype):
); );
[ [
if config.gpuarray.sync: if config.gpuarray.sync:
code += "GpuArray_sync(&%(zz)s->ga);\n" % dict(zz=zz) code += "GpuArray_sync(&%(z)s->ga);\n" % dict(z=z)
] ]
if (cudaSuccess != cudaGetLastError()) if (cudaSuccess != cudaGetLastError())
{ {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论