Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d4feee66
提交
d4feee66
authored
3月 20, 2012
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix indexing by slice with python2.4
Also add (disabled by default) debug printing statements.
上级
790c2a77
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
26 行增加
和
2 行删除
+26
-2
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+11
-1
cuda_ndarray.cu
theano/sandbox/cuda/cuda_ndarray.cu
+4
-0
basic.py
theano/tensor/basic.py
+11
-1
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
d4feee66
...
@@ -1756,7 +1756,17 @@ class GpuSubtensor(tensor.Subtensor, GpuOp):
...
@@ -1756,7 +1756,17 @@ class GpuSubtensor(tensor.Subtensor, GpuOp):
def
convert
(
entry
):
def
convert
(
entry
):
if
isinstance
(
entry
,
Type
):
if
isinstance
(
entry
,
Type
):
return
indices
.
pop
()
rval
=
indices
.
pop
()
if
sys
.
version_info
<
(
2
,
5
):
# Before Python 2.5, PySlice_GetIndicesEx requires
# Python int to be passed.
rval_
=
int
(
rval
)
if
rval_
!=
rval
:
raise
IndexError
((
"Invalid value for indexing:
%
s. "
"That value may be too big."
)
%
rval
)
return
rval_
return
rval
elif
isinstance
(
entry
,
slice
):
elif
isinstance
(
entry
,
slice
):
return
slice
(
convert
(
entry
.
start
),
return
slice
(
convert
(
entry
.
start
),
convert
(
entry
.
stop
),
convert
(
entry
.
stop
),
...
...
theano/sandbox/cuda/cuda_ndarray.cu
浏览文件 @
d4feee66
...
@@ -1521,6 +1521,7 @@ CudaNdarray_Subscript(PyObject * py_self, PyObject * key)
...
@@ -1521,6 +1521,7 @@ CudaNdarray_Subscript(PyObject * py_self, PyObject * key)
}
}
if
(
PySlice_Check
(
key
))
//INDEXING BY SLICE
if
(
PySlice_Check
(
key
))
//INDEXING BY SLICE
{
{
if
(
verbose
)
fprintf
(
stderr
,
"by slice
\n
"
);
if
(
self
->
nd
==
0
)
if
(
self
->
nd
==
0
)
{
{
PyErr_SetString
(
PyExc_ValueError
,
"cannot slice a 0-d array"
);
PyErr_SetString
(
PyExc_ValueError
,
"cannot slice a 0-d array"
);
...
@@ -1531,6 +1532,8 @@ CudaNdarray_Subscript(PyObject * py_self, PyObject * key)
...
@@ -1531,6 +1532,8 @@ CudaNdarray_Subscript(PyObject * py_self, PyObject * key)
Py_ssize_t
start
,
stop
,
step
,
slen
;
Py_ssize_t
start
,
stop
,
step
,
slen
;
if
(
PySlice_GetIndicesEx
((
PySliceObject
*
)
key
,
d_dim
,
&
start
,
&
stop
,
&
step
,
&
slen
))
if
(
PySlice_GetIndicesEx
((
PySliceObject
*
)
key
,
d_dim
,
&
start
,
&
stop
,
&
step
,
&
slen
))
{
{
if
(
verbose
)
fprintf
(
stderr
,
"PySlice_GetIndicesEx failed
\n
"
);
return
NULL
;
return
NULL
;
}
}
if
(
verbose
)
if
(
verbose
)
...
@@ -1569,6 +1572,7 @@ CudaNdarray_Subscript(PyObject * py_self, PyObject * key)
...
@@ -1569,6 +1572,7 @@ CudaNdarray_Subscript(PyObject * py_self, PyObject * key)
}
}
if
(
PyTuple_Check
(
key
))
//INDEXING BY TUPLE
if
(
PyTuple_Check
(
key
))
//INDEXING BY TUPLE
{
{
if
(
verbose
)
fprintf
(
stderr
,
"by tuple
\n
"
);
//elements of the tuple can be either integers or slices
//elements of the tuple can be either integers or slices
//the dimensionality of the view we will return is diminished for each slice in the tuple
//the dimensionality of the view we will return is diminished for each slice in the tuple
...
...
theano/tensor/basic.py
浏览文件 @
d4feee66
...
@@ -4126,7 +4126,17 @@ class IncSubtensor(Op):
...
@@ -4126,7 +4126,17 @@ class IncSubtensor(Op):
def
convert
(
entry
):
def
convert
(
entry
):
if
isinstance
(
entry
,
gof
.
Type
):
if
isinstance
(
entry
,
gof
.
Type
):
return
indices
.
pop
()
rval
=
indices
.
pop
()
if
sys
.
version_info
<
(
2
,
5
):
# Before Python 2.5, PySlice_GetIndicesEx requires
# Python int to be passed.
rval_
=
int
(
rval
)
if
rval_
!=
rval
:
raise
IndexError
((
"Invalid value for indexing:
%
s. "
"That value may be too big."
)
%
rval
)
return
rval_
return
rval
elif
isinstance
(
entry
,
slice
):
elif
isinstance
(
entry
,
slice
):
return
slice
(
convert
(
entry
.
start
),
return
slice
(
convert
(
entry
.
start
),
convert
(
entry
.
stop
),
convert
(
entry
.
stop
),
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论