Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
bc1320a5
提交
bc1320a5
authored
6月 27, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow a_cuda_ndarray.strides = [...]
上级
09017085
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
38 行增加
和
19 行删除
+38
-19
cuda_ndarray.cu
theano/sandbox/cuda/cuda_ndarray.cu
+28
-13
test_cuda_ndarray.py
theano/sandbox/cuda/tests/test_cuda_ndarray.py
+10
-6
没有找到文件。
theano/sandbox/cuda/cuda_ndarray.cu
浏览文件 @
bc1320a5
...
@@ -2391,22 +2391,37 @@ CudaNdarray_get_strides(CudaNdarray *self, void *closure)
...
@@ -2391,22 +2391,37 @@ CudaNdarray_get_strides(CudaNdarray *self, void *closure)
static
int
static
int
CudaNdarray_set_strides
(
CudaNdarray
*
self
,
PyObject
*
value
,
void
*
closure
)
CudaNdarray_set_strides
(
CudaNdarray
*
self
,
PyObject
*
value
,
void
*
closure
)
{
{
if
(
!
PyTuple_Check
(
value
)){
//npy_intp newstrides_bytes[PyTuple_Size(value)];
PyErr_SetString
(
PyExc_ValueError
,
if
(
PyTuple_Check
(
value
)){
"The new strides need to be encoded in a tupe"
);
if
(
PyTuple_Size
(
value
)
!=
CudaNdarray_NDIM
(
self
)){
return
-
1
;
PyErr_SetString
(
PyExc_ValueError
,
}
"The new strides tuple must have the same lenght"
if
(
PyTuple_Size
(
value
)
!=
CudaNdarray_NDIM
(
self
)){
" as the number of dimensions"
);
return
-
1
;
}
}
else
if
(
PyList_Check
(
value
)){
if
(
PyList_Size
(
value
)
!=
CudaNdarray_NDIM
(
self
)){
PyErr_SetString
(
PyExc_ValueError
,
"The new strides tuple must have the same lenght"
" as the number of dimensions"
);
return
-
1
;
}
}
else
{
PyErr_SetString
(
PyExc_ValueError
,
PyErr_SetString
(
PyExc_ValueError
,
"The new strides tuple must have the same lenght"
"The new strides need to be encoded in a tuple or list"
);
" as the number of dimensions"
);
return
-
1
;
return
-
1
;
}
}
npy_intp
newstrides
[
PyTuple_Size
(
value
)];
npy_intp
newstrides
[
CudaNdarray_NDIM
(
self
)];
//npy_intp newstrides_bytes[PyTuple_Size(value)];
if
(
PyTuple_Check
(
value
)){
for
(
int
i
=
0
;
i
<
CudaNdarray_NDIM
(
self
);
i
++
){
for
(
int
i
=
0
;
i
<
CudaNdarray_NDIM
(
self
);
i
++
){
newstrides
[
i
]
=
PyInt_AsLong
(
PyTuple_GetItem
(
value
,
Py_ssize_t
(
i
)));
newstrides
[
i
]
=
PyInt_AsLong
(
PyTuple_GetItem
(
value
,
Py_ssize_t
(
i
)));
//newstrides_bytes[i] = newstrides[i] * 4;
//newstrides_bytes[i] = newstrides[i] * 4;
}
}
else
if
(
PyList_Check
(
value
)){
for
(
int
i
=
0
;
i
<
CudaNdarray_NDIM
(
self
);
i
++
){
newstrides
[
i
]
=
PyInt_AsLong
(
PyList_GetItem
(
value
,
Py_ssize_t
(
i
)));
//newstrides_bytes[i] = newstrides[i] * 4;
}
}
}
/*
/*
// Don't do the check as ExtractDiag need that and NumPy seam to don't do
// Don't do the check as ExtractDiag need that and NumPy seam to don't do
...
...
theano/sandbox/cuda/tests/test_cuda_ndarray.py
浏览文件 @
bc1320a5
...
@@ -944,12 +944,16 @@ def test_base():
...
@@ -944,12 +944,16 @@ def test_base():
def
test_set_strides
():
def
test_set_strides
():
a
=
cuda_ndarray
.
CudaNdarray
.
zeros
((
5
,
5
))
a
=
cuda_ndarray
.
CudaNdarray
.
zeros
((
5
,
5
))
a
.
strides
=
(
a
.
strides
[
1
],
a
.
strides
[
0
])
try
:
# Test with tuple
a
.
strides
=
[
a
.
strides
[
1
],
a
.
strides
[
0
]]
new_strides
=
(
a
.
strides
[
1
],
a
.
strides
[
0
])
assert
False
a
.
strides
=
new_strides
except
ValueError
:
assert
a
.
strides
==
new_strides
pass
# Test with list
new_strides
=
(
a
.
strides
[
1
],
a
.
strides
[
0
])
a
.
strides
=
[
a
.
strides
[
1
],
a
.
strides
[
0
]]
assert
a
.
strides
==
new_strides
try
:
try
:
a
.
strides
=
(
a
.
strides
[
1
],)
a
.
strides
=
(
a
.
strides
[
1
],)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论