提交 6c5ab287 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Some flake8 work (but the file does not pass yet).

上级 4450770c
...@@ -56,9 +56,9 @@ class GpuArrayType(Type): ...@@ -56,9 +56,9 @@ class GpuArrayType(Type):
data.typecode, str(data.dtype))) data.typecode, str(data.dtype)))
# fallthrough to ndim check # fallthrough to ndim check
elif (allow_downcast or elif (allow_downcast or
(allow_downcast is None and (allow_downcast is None and
type(data) == float and type(data) == float and
self.dtype == theano.config.floatX)): self.dtype == config.floatX)):
data = gpuarray.array(data, dtype=self.typecode, copy=False, data = gpuarray.array(data, dtype=self.typecode, copy=False,
ndmin=len(self.broadcastable)) ndmin=len(self.broadcastable))
else: else:
...@@ -162,18 +162,15 @@ class GpuArrayType(Type): ...@@ -162,18 +162,15 @@ class GpuArrayType(Type):
def convert_variable(self, var): def convert_variable(self, var):
if (type(self) == type(var.type) and if (type(self) == type(var.type) and
self.typecode == var.type.typecode and self.typecode == var.type.typecode and
self.ndim == var.type.ndim and self.ndim == var.type.ndim and
all(sb == ob or ob for sb, ob in zip(self.broadcastable, all(sb == ob or ob for sb, ob in zip(self.broadcastable,
var.type.broadcastable))): var.type.broadcastable))):
return theano.tensor.patternbroadcast(var, self.broadcastable) return theano.tensor.patternbroadcast(var, self.broadcastable)
def __hash__(self): def __hash__(self):
return (hash(self.typecode) ^ hash(self.broadcastable)) return (hash(self.typecode) ^ hash(self.broadcastable))
def __str__(self):
return "GpuArray<%s>" % (self.dtype,)
def dtype_specs(self): def dtype_specs(self):
"""Return a tuple (python type, c type, numpy typenum) that corresponds """Return a tuple (python type, c type, numpy typenum) that corresponds
to self.dtype. to self.dtype.
...@@ -262,9 +259,9 @@ class GpuArrayType(Type): ...@@ -262,9 +259,9 @@ class GpuArrayType(Type):
def c_headers(self): def c_headers(self):
# We need arrayobject for the PyArrayDescr struct def # We need arrayobject for the PyArrayDescr struct def
# (even if we just use a pointer to it in a function def) # (even if we just use a pointer to it in a function def)
return ['<gpuarray/array.h>', '<gpuarray/kernel.h>', '<gpuarray/error.h>', return ['<gpuarray/array.h>', '<gpuarray/kernel.h>',
'<gpuarray/buffer_blas.h>', '<numpy/arrayobject.h>', '<gpuarray/error.h>', '<gpuarray/buffer_blas.h>',
'<gpuarray_api.h>'] '<numpy/arrayobject.h>', '<gpuarray_api.h>']
def c_header_dirs(self): def c_header_dirs(self):
return [pygpu.get_include(), numpy.get_include()] return [pygpu.get_include(), numpy.get_include()]
...@@ -296,8 +293,9 @@ GpuArrayType.Variable = GpuArrayVariable ...@@ -296,8 +293,9 @@ GpuArrayType.Variable = GpuArrayVariable
class GpuArraySignature(tensor.TensorConstantSignature): class GpuArraySignature(tensor.TensorConstantSignature):
pass # might do something better if we can run the sum on the # might do something better if we can run the sum on the GPU, but
# GPU, but for now this will suffice. # for now this will suffice.
pass
class GpuArrayConstant(_operators, Constant): class GpuArrayConstant(_operators, Constant):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论