提交 baf4f195 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Fixes for python 3 in sandbox/gpuarray

上级 e991b90b
...@@ -12,7 +12,7 @@ from theano.gof.utils import MethodNotDefined ...@@ -12,7 +12,7 @@ from theano.gof.utils import MethodNotDefined
from collections import deque from collections import deque
from six import string_types from six import string_types, iterbytes
from six.moves import xrange from six.moves import xrange
try: try:
...@@ -195,7 +195,7 @@ class GpuKernelBase(object): ...@@ -195,7 +195,7 @@ class GpuKernelBase(object):
gk = gpuarray.GpuKernel(k.code, k.name, k.params, context=ctx, gk = gpuarray.GpuKernel(k.code, k.name, k.params, context=ctx,
**k.flags) **k.flags)
bin = gk._binary bin = gk._binary
bcode = ','.join(hex(ord(c)) for c in bin) bcode = ','.join(hex(c) for c in iterbytes(bin))
return ("""static const char %(bname)s[] = { %(bcode)s };""" % return ("""static const char %(bname)s[] = { %(bcode)s };""" %
dict(bname=k.binvar, bcode=bcode)) dict(bname=k.binvar, bcode=bcode))
...@@ -942,6 +942,13 @@ class GpuJoin(HideC, Join): ...@@ -942,6 +942,13 @@ class GpuJoin(HideC, Join):
def c_code_cache_version(self): def c_code_cache_version(self):
return (2,) return (2,)
def c_support_code(self):
return """
#if PY_MAJOR_VERSION >= 3
#define PyInt_AsLong PyLong_AsLong
#endif
"""
def c_code(self, node, name, inputs, out_, sub): def c_code(self, node, name, inputs, out_, sub):
copy_to_list = [] copy_to_list = []
restype = pygpu.gpuarray.dtype_to_typecode(node.outputs[0].dtype) restype = pygpu.gpuarray.dtype_to_typecode(node.outputs[0].dtype)
......
...@@ -119,7 +119,7 @@ def dnn_available(context_name): ...@@ -119,7 +119,7 @@ def dnn_available(context_name):
# This is a hack because bin_id is in the from of # This is a hack because bin_id is in the from of
# "<something>_<major><minor>" for cuda devices. # "<something>_<major><minor>" for cuda devices.
if ctx.bin_id[:-2] < '30': if ctx.bin_id[-2:] < b'30':
dnn_available.msg = "Device not supported by cuDNN" dnn_available.msg = "Device not supported by cuDNN"
return False return False
......
...@@ -632,7 +632,7 @@ class GpuAdvancedIncSubtensor1_dev20(GpuKernelBase, GpuAdvancedIncSubtensor1): ...@@ -632,7 +632,7 @@ class GpuAdvancedIncSubtensor1_dev20(GpuKernelBase, GpuAdvancedIncSubtensor1):
if (self.set_instead_of_inc or if (self.set_instead_of_inc or
node.inputs[0].ndim != node.inputs[1].ndim or node.inputs[0].ndim != node.inputs[1].ndim or
node.inputs[0].ndim != 2 or node.inputs[0].ndim != 2 or
ctx.bin_id[-2] < '2'): ctx.bin_id[-2] < b'2'):
raise NotImplementedError("This case does not have C code yet.") raise NotImplementedError("This case does not have C code yet.")
x = inputs[0] x = inputs[0]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论