Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5b16f045
提交
5b16f045
authored
6月 27, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement a_cuda_ndarray.strides = (...)
上级
03b0acc7
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
60 行增加
和
2 行删除
+60
-2
cuda_ndarray.cu
theano/sandbox/cuda/cuda_ndarray.cu
+37
-2
test_cuda_ndarray.py
theano/sandbox/cuda/tests/test_cuda_ndarray.py
+23
-0
没有找到文件。
theano/sandbox/cuda/cuda_ndarray.cu
浏览文件 @
5b16f045
...
...
@@ -2391,8 +2391,43 @@ CudaNdarray_get_strides(CudaNdarray *self, void *closure)
static
int
CudaNdarray_set_strides
(
CudaNdarray
*
self
,
PyObject
*
value
,
void
*
closure
)
{
PyErr_SetString
(
PyExc_NotImplementedError
,
""
);
return
-
1
;
if
(
!
PyTuple_Check
(
value
)){
PyErr_SetString
(
PyExc_ValueError
,
"The new strides need to be encoded in a tupe"
);
return
-
1
;
}
if
(
PyTuple_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
;
}
npy_intp
newstrides
[
PyTuple_Size
(
value
)];
//npy_intp newstrides_bytes[PyTuple_Size(value)];
for
(
int
i
=
0
;
i
<
CudaNdarray_NDIM
(
self
);
i
++
){
newstrides
[
i
]
=
PyInt_AsLong
(
PyTuple_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
// it.
npy_intp dims[PyTuple_Size(value)];
for(int i=0; i < CudaNdarray_NDIM(self); i++){
dims[i] = CudaNdarray_HOST_DIMS(self)[i];
}
if (!PyArray_CheckStrides(4,
CudaNdarray_NDIM(self),
0, 0,
dims,
newstrides_bytes)){
PyErr_SetString(PyExc_ValueError, "bad new strides");
return -1;
}
*/
for
(
int
i
=
0
;
i
<
CudaNdarray_NDIM
(
self
);
i
++
){
CudaNdarray_set_stride
(
self
,
i
,
newstrides
[
i
]);
}
return
0
;
}
static
PyObject
*
...
...
theano/sandbox/cuda/tests/test_cuda_ndarray.py
浏览文件 @
5b16f045
...
...
@@ -941,6 +941,29 @@ def test_base():
e
=
b
.
reshape
((
5
,
2
,
2
,
3
))
assert
e
.
base
is
a
def
test_set_strides
():
a
=
cuda_ndarray
.
CudaNdarray
.
zeros
((
5
,
5
))
a
.
strides
=
(
a
.
strides
[
1
],
a
.
strides
[
0
])
try
:
a
.
strides
=
[
a
.
strides
[
1
],
a
.
strides
[
0
]]
assert
False
except
ValueError
:
pass
try
:
a
.
strides
=
(
a
.
strides
[
1
],)
assert
False
except
ValueError
:
pass
try
:
a
.
strides
=
(
1
,
1
,
1
)
assert
False
except
ValueError
:
pass
def
test_is_c_contiguous
():
a
=
cuda_ndarray
.
CudaNdarray
.
zeros
((
3
,
4
,
5
))
assert
a
.
is_c_contiguous
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论