提交 2bac5a41 authored 作者: abergeron's avatar abergeron

Merge pull request #3767 from lamblin/gpuarray_py3

Fixes for python 3 in sandbox/gpuarray
......@@ -12,7 +12,7 @@ from theano.gof.utils import MethodNotDefined
from collections import deque
from six import string_types
from six import string_types, iterbytes
from six.moves import xrange
try:
......@@ -195,7 +195,7 @@ class GpuKernelBase(object):
gk = gpuarray.GpuKernel(k.code, k.name, k.params, context=ctx,
**k.flags)
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 };""" %
dict(bname=k.binvar, bcode=bcode))
......@@ -943,6 +943,13 @@ class GpuJoin(HideC, Join):
def c_code_cache_version(self):
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):
copy_to_list = []
restype = pygpu.gpuarray.dtype_to_typecode(node.outputs[0].dtype)
......
......@@ -119,7 +119,7 @@ def dnn_available(context_name):
# This is a hack because bin_id is in the from of
# "<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"
return False
......
......@@ -632,7 +632,7 @@ class GpuAdvancedIncSubtensor1_dev20(GpuKernelBase, GpuAdvancedIncSubtensor1):
if (self.set_instead_of_inc or
node.inputs[0].ndim != node.inputs[1].ndim 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.")
x = inputs[0]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论