提交 2846a3aa authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #2993 from caglar/fix_advanced_subtensor_cast

fix casting in advanced subtensor.
...@@ -61,7 +61,7 @@ class HostFromGpu(GpuOp): ...@@ -61,7 +61,7 @@ class HostFromGpu(GpuOp):
Implement the transfer from gpu to the cpu. Implement the transfer from gpu to the cpu.
""" """
check_input = False check_input = False
def __eq__(self, other): def __eq__(self, other):
return type(self) == type(other) return type(self) == type(other)
...@@ -120,7 +120,7 @@ class GpuFromHost(GpuOp): ...@@ -120,7 +120,7 @@ class GpuFromHost(GpuOp):
Implement the transfer from cpu to the gpu. Implement the transfer from cpu to the gpu.
""" """
check_input = False check_input = False
def __eq__(self, other): def __eq__(self, other):
return type(self) == type(other) return type(self) == type(other)
...@@ -2566,7 +2566,8 @@ class GpuAdvancedSubtensor1(tensor.AdvancedSubtensor1, GpuOp): ...@@ -2566,7 +2566,8 @@ class GpuAdvancedSubtensor1(tensor.AdvancedSubtensor1, GpuOp):
# c code suppose it is int64 # c code suppose it is int64
if x.ndim in [2, 3] and ilist_.dtype in [ if x.ndim in [2, 3] and ilist_.dtype in [
'int8', 'int16', 'int32', 'uint8', 'uint16', 'uint32']: 'int8', 'int16', 'int32', 'uint8', 'uint16', 'uint32']:
ilist_ = ilist_.cast('int64') ilist_ = tensor.cast(ilist_, 'int64')
bcast = (ilist_.broadcastable[0],) + x_.broadcastable[1:] bcast = (ilist_.broadcastable[0],) + x_.broadcastable[1:]
return Apply(self, [x_, ilist_], return Apply(self, [x_, ilist_],
[CudaNdarrayType(dtype=x.dtype, [CudaNdarrayType(dtype=x.dtype,
...@@ -3251,7 +3252,7 @@ class GpuJoin(tensor.Join, GpuOp): ...@@ -3251,7 +3252,7 @@ class GpuJoin(tensor.Join, GpuOp):
# Test negative axis # Test negative axis
str += """ str += """
if( axis < -nd ){ if( axis < -nd ){
PyErr_Format(PyExc_IndexError, PyErr_Format(PyExc_IndexError,
"Join axis %%d out of bounds [0, %%d)", axis, nd); "Join axis %%d out of bounds [0, %%d)", axis, nd);
%(fail)s %(fail)s
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论