Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b44d2bf6
提交
b44d2bf6
authored
9月 20, 2016
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix and revert stuff in this PR.
上级
c260ecf4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
33 行增加
和
20 行删除
+33
-20
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+8
-8
blas.py
theano/sandbox/cuda/blas.py
+19
-0
opt.py
theano/sandbox/cuda/opt.py
+6
-11
elemwise.py
theano/tensor/elemwise.py
+0
-1
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
b44d2bf6
...
@@ -319,7 +319,6 @@ class GpuDimShuffle(GpuOp):
...
@@ -319,7 +319,6 @@ class GpuDimShuffle(GpuOp):
input_broadcastable
=
tuple
(
input_broadcastable
)
input_broadcastable
=
tuple
(
input_broadcastable
)
self
.
input_broadcastable
=
input_broadcastable
self
.
input_broadcastable
=
input_broadcastable
self
.
new_order
=
tuple
(
new_order
)
self
.
new_order
=
tuple
(
new_order
)
self
.
inplace
=
True
for
i
,
b
in
enumerate
(
input_broadcastable
):
for
i
,
b
in
enumerate
(
input_broadcastable
):
if
i
not
in
new_order
:
if
i
not
in
new_order
:
...
@@ -347,7 +346,6 @@ class GpuDimShuffle(GpuOp):
...
@@ -347,7 +346,6 @@ class GpuDimShuffle(GpuOp):
def
__setstate__
(
self
,
d
):
def
__setstate__
(
self
,
d
):
self
.
__dict__
.
update
(
d
)
self
.
__dict__
.
update
(
d
)
self
.
_rehash
()
def
make_node
(
self
,
input
):
def
make_node
(
self
,
input
):
ib
=
tuple
(
input
.
type
.
broadcastable
)
ib
=
tuple
(
input
.
type
.
broadcastable
)
...
@@ -375,12 +373,6 @@ class GpuDimShuffle(GpuOp):
...
@@ -375,12 +373,6 @@ class GpuDimShuffle(GpuOp):
ob
.
append
(
ib
[
value
])
ob
.
append
(
ib
[
value
])
return
Apply
(
self
,
[
input
],
[
CudaNdarrayType
(
broadcastable
=
ob
)()])
return
Apply
(
self
,
[
input
],
[
CudaNdarrayType
(
broadcastable
=
ob
)()])
def
_rehash
(
self
):
self
.
_hashval
=
(
hash
(
type
(
self
)
.
__name__
)
^
hash
(
type
(
self
)
.
__module__
)
^
hash
(
self
.
new_order
)
^
hash
(
self
.
input_broadcastable
))
def
__str__
(
self
):
def
__str__
(
self
):
return
"GpuDimShuffle{
%
s}"
%
","
.
join
(
str
(
x
)
for
x
in
self
.
new_order
)
return
"GpuDimShuffle{
%
s}"
%
","
.
join
(
str
(
x
)
for
x
in
self
.
new_order
)
...
@@ -3731,6 +3723,14 @@ class GpuAlloc(GpuAllocEmpty):
...
@@ -3731,6 +3723,14 @@ class GpuAlloc(GpuAllocEmpty):
def
__init__
(
self
,
memset_0
=
False
):
def
__init__
(
self
,
memset_0
=
False
):
self
.
memset_0
=
memset_0
self
.
memset_0
=
memset_0
def
__str__
(
self
):
# Hide the memset parameter when not used to prevent confusion.
if
self
.
memset_0
:
s
=
"
%
s{memset_0=
%
s}"
%
(
self
.
__class__
.
__name__
,
self
.
memset_0
)
else
:
s
=
self
.
__class__
.
__name__
return
s
def
make_node
(
self
,
value
,
*
shape
):
def
make_node
(
self
,
value
,
*
shape
):
# if there is unneeded transfert generated by the next line
# if there is unneeded transfert generated by the next line
# the optimizer will remove them.
# the optimizer will remove them.
...
...
theano/sandbox/cuda/blas.py
浏览文件 @
b44d2bf6
...
@@ -898,6 +898,13 @@ class BaseGpuCorrMM(GpuOp):
...
@@ -898,6 +898,13 @@ class BaseGpuCorrMM(GpuOp):
return
self
.
border_mode
return
self
.
border_mode
return
(
0
,
0
)
return
(
0
,
0
)
def
__str__
(
self
):
return
'
%
s{
%
s,
%
s,
%
s}'
%
(
self
.
__class__
.
__name__
,
self
.
border_mode
,
str
(
self
.
subsample
),
str
(
self
.
filter_dilation
))
def
flops
(
self
,
inp
,
outp
):
def
flops
(
self
,
inp
,
outp
):
"""
"""
Useful with the hack in profilemode to print the MFlops.
Useful with the hack in profilemode to print the MFlops.
...
@@ -1406,6 +1413,13 @@ class BaseGpuCorr3dMM(GpuOp):
...
@@ -1406,6 +1413,13 @@ class BaseGpuCorr3dMM(GpuOp):
raise
ValueError
(
"pad must be 'half', 'full', or have three elements"
)
raise
ValueError
(
"pad must be 'half', 'full', or have three elements"
)
self
.
pad
=
pad
self
.
pad
=
pad
def
__str__
(
self
):
return
'
%
s{
%
s,
%
s, pad=
%
r}'
%
(
self
.
__class__
.
__name__
,
self
.
border_mode
,
str
(
self
.
subsample
),
self
.
pad
)
def
flops
(
self
,
inp
,
outp
):
def
flops
(
self
,
inp
,
outp
):
""" Useful with the hack in profilemode to print the MFlops"""
""" Useful with the hack in profilemode to print the MFlops"""
# if the output shape is correct, then this gives the correct
# if the output shape is correct, then this gives the correct
...
@@ -2199,6 +2213,11 @@ class GpuDownsampleFactorMax(GpuOp):
...
@@ -2199,6 +2213,11 @@ class GpuDownsampleFactorMax(GpuOp):
self
.
ds
=
tuple
(
ds
)
self
.
ds
=
tuple
(
ds
)
self
.
ignore_border
=
ignore_border
self
.
ignore_border
=
ignore_border
def
__str__
(
self
):
return
'
%
s{
%
s,
%
s}'
%
(
self
.
__class__
.
__name__
,
self
.
ds
,
self
.
ignore_border
)
def
make_node
(
self
,
x
):
def
make_node
(
self
,
x
):
if
not
isinstance
(
x
.
type
,
CudaNdarrayType
):
if
not
isinstance
(
x
.
type
,
CudaNdarrayType
):
raise
TypeError
()
raise
TypeError
()
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
b44d2bf6
...
@@ -399,10 +399,7 @@ def local_gpu_dimshuffle_0(node):
...
@@ -399,10 +399,7 @@ def local_gpu_dimshuffle_0(node):
if
input
.
owner
and
isinstance
(
input
.
owner
.
op
,
HostFromGpu
):
if
input
.
owner
and
isinstance
(
input
.
owner
.
op
,
HostFromGpu
):
# move the add to a GpuAdd
# move the add to a GpuAdd
p_dict
=
node
.
op
.
_props_dict
()
p_dict
=
node
.
op
.
_props_dict
()
try
:
p_dict
.
pop
(
'inplace'
,
None
)
p_dict
.
pop
(
'inplace'
)
except
KeyError
:
pass
new_op
=
GpuDimShuffle
(
**
p_dict
)
new_op
=
GpuDimShuffle
(
**
p_dict
)
return
[
host_from_gpu
(
new_op
(
as_cuda_ndarray_variable
(
input
)))]
return
[
host_from_gpu
(
new_op
(
as_cuda_ndarray_variable
(
input
)))]
if
isinstance
(
node
.
op
,
GpuFromHost
):
if
isinstance
(
node
.
op
,
GpuFromHost
):
...
@@ -411,10 +408,7 @@ def local_gpu_dimshuffle_0(node):
...
@@ -411,10 +408,7 @@ def local_gpu_dimshuffle_0(node):
tensor
.
DimShuffle
):
tensor
.
DimShuffle
):
dimshuffle_node
=
host_input
.
owner
dimshuffle_node
=
host_input
.
owner
p_dict
=
dimshuffle_node
.
op
.
_props_dict
()
p_dict
=
dimshuffle_node
.
op
.
_props_dict
()
try
:
p_dict
.
pop
(
'inplace'
,
None
)
p_dict
.
pop
(
'inplace'
)
except
KeyError
:
pass
new_op
=
GpuDimShuffle
(
**
p_dict
)
new_op
=
GpuDimShuffle
(
**
p_dict
)
return
[
new_op
(
return
[
new_op
(
as_cuda_ndarray_variable
(
dimshuffle_node
.
inputs
[
0
]))]
as_cuda_ndarray_variable
(
dimshuffle_node
.
inputs
[
0
]))]
...
@@ -1189,6 +1183,7 @@ def local_gpu_incsubtensor(node):
...
@@ -1189,6 +1183,7 @@ def local_gpu_incsubtensor(node):
host_output
=
node
.
inputs
[
0
]
host_output
=
node
.
inputs
[
0
]
if
host_output
.
owner
and
\
if
host_output
.
owner
and
\
type
(
host_output
.
owner
.
op
)
==
tensor
.
IncSubtensor
:
type
(
host_output
.
owner
.
op
)
==
tensor
.
IncSubtensor
:
incsubt
=
host_output
.
owner
.
op
x
,
y
=
host_output
.
owner
.
inputs
[
0
:
2
]
x
,
y
=
host_output
.
owner
.
inputs
[
0
:
2
]
coords
=
host_output
.
owner
.
inputs
[
2
:]
coords
=
host_output
.
owner
.
inputs
[
2
:]
if
x
.
dtype
!=
"float32"
:
if
x
.
dtype
!=
"float32"
:
...
@@ -1197,7 +1192,7 @@ def local_gpu_incsubtensor(node):
...
@@ -1197,7 +1192,7 @@ def local_gpu_incsubtensor(node):
# The IncSubtensor upcast to float32 y, so we do it
# The IncSubtensor upcast to float32 y, so we do it
# explicitly to move it to the GPU.
# explicitly to move it to the GPU.
y
=
y
.
astype
(
'float32'
)
y
=
y
.
astype
(
'float32'
)
ret
=
GpuIncSubtensor
(
**
node
.
op
.
_props_dict
())(
as_cuda_ndarray_variable
(
x
),
ret
=
GpuIncSubtensor
(
**
incsubt
.
_props_dict
())(
as_cuda_ndarray_variable
(
x
),
as_cuda_ndarray_variable
(
y
),
as_cuda_ndarray_variable
(
y
),
*
coords
)
*
coords
)
ret
.
tag
.
nan_guard_mode_check
=
getattr
(
ret
.
tag
.
nan_guard_mode_check
=
getattr
(
...
@@ -1922,7 +1917,7 @@ def local_gpu_downsample_factor_max(node):
...
@@ -1922,7 +1917,7 @@ def local_gpu_downsample_factor_max(node):
if
(
pad
)
!=
(
0
,
0
)
or
node
.
op
.
mode
!=
'max'
or
stride
!=
ws
:
if
(
pad
)
!=
(
0
,
0
)
or
node
.
op
.
mode
!=
'max'
or
stride
!=
ws
:
return
return
if
(
x
.
owner
and
isinstance
(
x
.
owner
.
op
,
HostFromGpu
)):
if
(
x
.
owner
and
isinstance
(
x
.
owner
.
op
,
HostFromGpu
)):
gpu_ds
=
GpuDownsampleFactorMax
(
**
node
.
op
.
_props_dict
()
)
gpu_ds
=
GpuDownsampleFactorMax
(
ws
,
node
.
op
.
ignore_border
)
return
[
host_from_gpu
(
gpu_ds
(
x
.
owner
.
inputs
[
0
]))]
return
[
host_from_gpu
(
gpu_ds
(
x
.
owner
.
inputs
[
0
]))]
...
@@ -1939,7 +1934,7 @@ def local_gpu_downsample_factor_max_grad(node):
...
@@ -1939,7 +1934,7 @@ def local_gpu_downsample_factor_max_grad(node):
if
pad
!=
(
0
,
0
)
or
node
.
op
.
mode
!=
'max'
or
stride
!=
ws
:
if
pad
!=
(
0
,
0
)
or
node
.
op
.
mode
!=
'max'
or
stride
!=
ws
:
return
return
if
(
x
.
owner
and
isinstance
(
x
.
owner
.
op
,
HostFromGpu
)):
if
(
x
.
owner
and
isinstance
(
x
.
owner
.
op
,
HostFromGpu
)):
gpu_ds_grad
=
GpuDownsampleFactorMaxGrad
(
node
.
op
.
d
s
,
node
.
op
.
ignore_border
)
gpu_ds_grad
=
GpuDownsampleFactorMaxGrad
(
w
s
,
node
.
op
.
ignore_border
)
return
[
host_from_gpu
(
gpu_ds_grad
(
x
.
owner
.
inputs
[
0
],
return
[
host_from_gpu
(
gpu_ds_grad
(
x
.
owner
.
inputs
[
0
],
as_cuda_ndarray_variable
(
z
),
as_cuda_ndarray_variable
(
z
),
as_cuda_ndarray_variable
(
gz
)))]
as_cuda_ndarray_variable
(
gz
)))]
...
...
theano/tensor/elemwise.py
浏览文件 @
b44d2bf6
...
@@ -142,7 +142,6 @@ class DimShuffle(Op):
...
@@ -142,7 +142,6 @@ class DimShuffle(Op):
self
.
new_order
=
new_order
self
.
new_order
=
new_order
if
inplace
is
True
:
if
inplace
is
True
:
self
.
inplace
=
inplace
self
.
inplace
=
inplace
self
.
_props_dict
()
.
pop
(
'inplace'
)
else
:
else
:
raise
ValueError
(
"DimShuffle is inplace by default and hence the inplace for DimShuffle must be true"
)
raise
ValueError
(
"DimShuffle is inplace by default and hence the inplace for DimShuffle must be true"
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论