Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8f21a69a
提交
8f21a69a
authored
9月 23, 2013
作者:
Frederic
提交者:
Arnaud Bergeron
10月 30, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix some compilation crash of the new GpuSubtensor
上级
d24e99ff
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
19 行增加
和
9 行删除
+19
-9
subtensor.py
theano/sandbox/gpuarray/subtensor.py
+19
-9
没有找到文件。
theano/sandbox/gpuarray/subtensor.py
浏览文件 @
8f21a69a
import
StringIO
import
numpy
import
numpy
import
theano
import
theano
from
theano
import
tensor
from
theano
import
tensor
,
gof
from
theano.tensor.subtensor
import
Subtensor
,
get_idx_list
from
theano.tensor.subtensor
import
Subtensor
,
get_idx_list
from
theano.gof.python25
import
all
,
any
from
theano.gof.python25
import
all
,
any
...
@@ -21,7 +23,7 @@ class GpuSubtensor(HideC, Subtensor):
...
@@ -21,7 +23,7 @@ class GpuSubtensor(HideC, Subtensor):
otype
=
GpuArrayType
(
dtype
=
rval
.
outputs
[
0
]
.
type
.
dtype
,
otype
=
GpuArrayType
(
dtype
=
rval
.
outputs
[
0
]
.
type
.
dtype
,
broadcastable
=
rval
.
outputs
[
0
]
.
type
.
broadcastable
)
broadcastable
=
rval
.
outputs
[
0
]
.
type
.
broadcastable
)
x
=
as_gpuarray_variable
(
x
)
x
=
as_gpuarray_variable
(
x
)
return
Apply
(
self
,
[
x
]
+
rval
.
inputs
[
1
:],
[
otype
()])
return
gof
.
Apply
(
self
,
[
x
]
+
rval
.
inputs
[
1
:],
[
otype
()])
def
perform
(
self
,
node
,
inputs
,
out_
):
def
perform
(
self
,
node
,
inputs
,
out_
):
out
,
=
out_
out
,
=
out_
...
@@ -42,15 +44,16 @@ class GpuSubtensor(HideC, Subtensor):
...
@@ -42,15 +44,16 @@ class GpuSubtensor(HideC, Subtensor):
view_ndim
=
node
.
outputs
[
0
]
.
ndim
view_ndim
=
node
.
outputs
[
0
]
.
ndim
indices
=
inputs
[
1
:]
indices
=
inputs
[
1
:]
sio
=
StringIO
.
StringIO
(
"""
sio
=
StringIO
.
StringIO
()
print
>>
sio
,
"""
ssize_t
%(name)
s_starts[
%(sz)
s];
ssize_t
%(name)
s_starts[
%(sz)
s];
ssize_t
%(name)
s_stops[
%(sz)
s];
ssize_t
%(name)
s_stops[
%(sz)
s];
ssize_t
%(name)
s_steps[
%(sz)
s];
ssize_t
%(name)
s_steps[
%(sz)
s];
"""
%
dict
(
name
=
name
,
sz
=
len
(
self
.
idx_list
))
)
"""
%
dict
(
name
=
name
,
sz
=
len
(
self
.
idx_list
))
ndim
=
0
ndim
=
0
for
i
,
idx
in
enumerate
(
self
.
idx_list
):
for
i
,
idx
in
enumerate
(
self
.
idx_list
):
if
isinstance
(
idx
,
Type
):
if
isinstance
(
idx
,
gof
.
Type
):
# Index by an input number
# Index by an input number
print
>>
sio
,
"""
print
>>
sio
,
"""
%(name)
s_starts[
%(i)
s] =
%(start)
s;
%(name)
s_starts[
%(i)
s] =
%(start)
s;
...
@@ -58,12 +61,19 @@ class GpuSubtensor(HideC, Subtensor):
...
@@ -58,12 +61,19 @@ class GpuSubtensor(HideC, Subtensor):
"""
%
dict
(
name
=
name
,
i
=
i
,
start
=
indices
.
pop
(),
step
=
0
)
"""
%
dict
(
name
=
name
,
i
=
i
,
start
=
indices
.
pop
(),
step
=
0
)
elif
isinstance
(
idx
,
slice
):
elif
isinstance
(
idx
,
slice
):
# index by a fixed slice
# index by a fixed slice
step
=
idx
.
step
if
step
is
None
:
step
=
1
stop
=
idx
.
stop
if
stop
is
None
:
#TODO find what is needed
raise
NotImplementedError
(
"This case is not yet implemented!"
)
print
>>
sio
,
"""
print
>>
sio
,
"""
%(name)
s_starts[
%(i)
s] =
%(start)
s;
%(name)
s_starts[
%(i)
s] =
%(start)
s;
%(name)
s_stops[
%(i)
s] =
%(stop)
s;
%(name)
s_stops[
%(i)
s] =
%(stop)
s;
%(name)
s_steps[
%(i)
s] =
%(step)
s;
%(name)
s_steps[
%(i)
s] =
%(step)
s;
"""
%
dict
(
i
=
i
,
name
=
name
,
start
=
idx
.
start
,
stop
=
idx
.
stop
,
"""
%
dict
(
i
=
i
,
name
=
name
,
start
=
idx
.
start
,
stop
=
stop
,
step
=
idx
.
step
)
step
=
step
)
ndim
+=
1
ndim
+=
1
else
:
else
:
# Index by a fixed number
# Index by a fixed number
...
@@ -77,13 +87,13 @@ class GpuSubtensor(HideC, Subtensor):
...
@@ -77,13 +87,13 @@ class GpuSubtensor(HideC, Subtensor):
// Try to reuse the python object.
// Try to reuse the python object.
GpuArray_clear(&
%(out)
s->ga);
GpuArray_clear(&
%(out)
s->ga);
} else {
} else {
%(out)
s = new_GpuArray((PyObject *)&PyGpuArrayType, pygpu_default_context, Py_None);
%(out)
s = new_GpuArray((PyObject *)&PyGpuArrayType, pygpu_default_context
()
, Py_None);
}
}
if (!
%(out)
s) {
%(fail)
s }
if (!
%(out)
s) {
%(fail)
s }
int
%(name)
s_err;
int
%(name)
s_err;
%(name)
s_err = GpuArray_index(&
%(out)
s->ga, &
%(inp)
s->ga,
%(name)
s_err = GpuArray_index(&
%(out)
s->ga, &
%(inp)
s->ga,
%(name)
s_starts,
%(name)
s_steps,
%(name)
s_starts,
%(name)
s_steps,
%(name)
s_stops)
%(name)
s_stops)
;
if (
%(name)
s_err != GA_NO_ERROR) {
if (
%(name)
s_err != GA_NO_ERROR) {
Py_DECREF(
%(out)
s);
%(out)
s = NULL;
Py_DECREF(
%(out)
s);
%(out)
s = NULL;
PyErr_SetString(PyExc_RuntimeError, "Error during index");
PyErr_SetString(PyExc_RuntimeError, "Error during index");
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论