Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4f1c2697
提交
4f1c2697
authored
9月 16, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Type context for subtensor.py.
上级
c887bc14
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
19 行增加
和
10 行删除
+19
-10
subtensor.py
theano/sandbox/gpuarray/subtensor.py
+19
-10
没有找到文件。
theano/sandbox/gpuarray/subtensor.py
浏览文件 @
4f1c2697
...
@@ -26,10 +26,12 @@ class GpuSubtensor(HideC, Subtensor):
...
@@ -26,10 +26,12 @@ class GpuSubtensor(HideC, Subtensor):
_f16_ok
=
True
_f16_ok
=
True
def
make_node
(
self
,
x
,
*
inputs
):
def
make_node
(
self
,
x
,
*
inputs
):
ctx_name
=
infer_context_name
(
x
)
rval
=
tensor
.
Subtensor
.
make_node
(
self
,
x
,
*
inputs
)
rval
=
tensor
.
Subtensor
.
make_node
(
self
,
x
,
*
inputs
)
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
)
context_name
=
ctx_name
)
x
=
as_gpuarray_variable
(
x
,
ctx_name
)
return
gof
.
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_
):
...
@@ -190,14 +192,18 @@ class GpuIncSubtensor(GpuKernelBase, IncSubtensor):
...
@@ -190,14 +192,18 @@ class GpuIncSubtensor(GpuKernelBase, IncSubtensor):
return
self
.
iadd_node
.
op
.
gpu_kernels
(
self
.
iadd_node
,
subname
)
return
self
.
iadd_node
.
op
.
gpu_kernels
(
self
.
iadd_node
,
subname
)
def
make_node
(
self
,
x
,
y
,
*
inputs
):
def
make_node
(
self
,
x
,
y
,
*
inputs
):
x
=
as_gpuarray_variable
(
x
)
ctx_name
=
infer_context_name
(
x
,
y
)
y
=
as_gpuarray_variable
(
y
)
x
=
as_gpuarray_variable
(
x
,
ctx_name
)
y
=
as_gpuarray_variable
(
y
,
ctx_name
)
rval
=
tensor
.
IncSubtensor
.
make_node
(
self
,
x
,
y
,
*
inputs
)
rval
=
tensor
.
IncSubtensor
.
make_node
(
self
,
x
,
y
,
*
inputs
)
op
=
copy
.
copy
(
self
)
op
=
copy
.
copy
(
self
)
ret
=
gof
.
Apply
(
op
,
[
x
,
y
]
+
rval
.
inputs
[
2
:],
[
x
.
type
()])
ret
=
gof
.
Apply
(
op
,
[
x
,
y
]
+
rval
.
inputs
[
2
:],
[
x
.
type
()])
op
.
create_iadd_node
(
ret
)
op
.
create_iadd_node
(
ret
)
return
ret
return
ret
def
get_context
(
self
,
node
):
return
node
.
outputs
[
0
]
.
type
.
context
def
create_iadd_node
(
self
,
node
):
def
create_iadd_node
(
self
,
node
):
# We store a iadd_node in the op that contain the info needed
# We store a iadd_node in the op that contain the info needed
# for the inplace add.
# for the inplace add.
...
@@ -365,10 +371,10 @@ class GpuIncSubtensor(GpuKernelBase, IncSubtensor):
...
@@ -365,10 +371,10 @@ class GpuIncSubtensor(GpuKernelBase, IncSubtensor):
"""
%
locals
()
"""
%
locals
()
inputs
=
[
"dst"
,
"src"
]
inputs
=
[
"dst"
,
"src"
]
outputs
=
[
"ret"
]
outputs
=
[
"ret"
]
sub
=
{
"fail"
:
"return NULL;"
}
sub
=
{
"fail"
:
"return NULL;"
,
"context"
:
"dst->ctx"
}
ret
+=
gop
.
c_code
(
self
.
iadd_node
,
sub_name
,
inputs
,
outputs
,
sub
)
ret
+=
gop
.
c_code
(
self
.
iadd_node
,
sub_name
,
inputs
,
outputs
,
sub
)
ret
+=
"""
ret
+=
"""
return
ds
t;
return
re
t;
}
}
"""
"""
return
ret
return
ret
...
@@ -398,7 +404,8 @@ class GpuIncSubtensor(GpuKernelBase, IncSubtensor):
...
@@ -398,7 +404,8 @@ class GpuIncSubtensor(GpuKernelBase, IncSubtensor):
class
GpuAdvancedSubtensor1
(
HideC
,
tensor
.
AdvancedSubtensor1
):
class
GpuAdvancedSubtensor1
(
HideC
,
tensor
.
AdvancedSubtensor1
):
def
make_node
(
self
,
x
,
ilist
):
def
make_node
(
self
,
x
,
ilist
):
x_
=
as_gpuarray_variable
(
x
)
ctx_name
=
infer_context_name
(
x
,
ilist
)
x_
=
as_gpuarray_variable
(
x
,
ctx_name
)
ilist__
=
tensor
.
as_tensor_variable
(
ilist
)
ilist__
=
tensor
.
as_tensor_variable
(
ilist
)
if
ilist__
.
type
.
dtype
[:
3
]
not
in
(
'int'
,
'uin'
):
if
ilist__
.
type
.
dtype
[:
3
]
not
in
(
'int'
,
'uin'
):
...
@@ -406,7 +413,7 @@ class GpuAdvancedSubtensor1(HideC, tensor.AdvancedSubtensor1):
...
@@ -406,7 +413,7 @@ class GpuAdvancedSubtensor1(HideC, tensor.AdvancedSubtensor1):
if
ilist__
.
type
.
dtype
!=
'int64'
:
if
ilist__
.
type
.
dtype
!=
'int64'
:
ilist__
=
tensor
.
cast
(
ilist__
,
'int64'
)
ilist__
=
tensor
.
cast
(
ilist__
,
'int64'
)
ilist_
=
as_gpuarray_variable
(
ilist__
)
ilist_
=
as_gpuarray_variable
(
ilist__
,
ctx_name
)
if
ilist_
.
type
.
dtype
!=
'int64'
:
if
ilist_
.
type
.
dtype
!=
'int64'
:
raise
TypeError
(
'index must be int64'
)
raise
TypeError
(
'index must be int64'
)
...
@@ -418,6 +425,7 @@ class GpuAdvancedSubtensor1(HideC, tensor.AdvancedSubtensor1):
...
@@ -418,6 +425,7 @@ class GpuAdvancedSubtensor1(HideC, tensor.AdvancedSubtensor1):
bcast
=
ilist_
.
broadcastable
+
x_
.
broadcastable
[
1
:]
bcast
=
ilist_
.
broadcastable
+
x_
.
broadcastable
[
1
:]
return
gof
.
Apply
(
self
,
[
x_
,
ilist_
],
return
gof
.
Apply
(
self
,
[
x_
,
ilist_
],
[
GpuArrayType
(
dtype
=
x
.
dtype
,
[
GpuArrayType
(
dtype
=
x
.
dtype
,
context_name
=
ctx_name
,
broadcastable
=
bcast
)()])
broadcastable
=
bcast
)()])
def
perform
(
self
,
node
,
inp
,
out_
):
def
perform
(
self
,
node
,
inp
,
out_
):
...
@@ -474,8 +482,9 @@ class GpuAdvancedIncSubtensor1(HideC, tensor.AdvancedIncSubtensor1):
...
@@ -474,8 +482,9 @@ class GpuAdvancedIncSubtensor1(HideC, tensor.AdvancedIncSubtensor1):
"""
"""
def
make_node
(
self
,
x
,
y
,
ilist
):
def
make_node
(
self
,
x
,
y
,
ilist
):
x_
=
as_gpuarray_variable
(
x
)
ctx_name
=
infer_context_name
(
x
,
y
)
y_
=
as_gpuarray_variable
(
y
)
x_
=
as_gpuarray_variable
(
x
,
ctx_name
)
y_
=
as_gpuarray_variable
(
y
,
ctx_name
)
ilist_
=
tensor
.
as_tensor_variable
(
ilist
)
ilist_
=
tensor
.
as_tensor_variable
(
ilist
)
assert
x_
.
type
.
dtype
==
y_
.
type
.
dtype
assert
x_
.
type
.
dtype
==
y_
.
type
.
dtype
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论