Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7885227c
提交
7885227c
authored
8月 22, 2016
作者:
sentient07
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Made the suggested changes
上级
0792f335
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
21 行增加
和
19 行删除
+21
-19
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+8
-5
blas.py
theano/sandbox/cuda/blas.py
+3
-0
opt.py
theano/sandbox/cuda/opt.py
+3
-6
elemwise.py
theano/tensor/elemwise.py
+5
-3
opt.py
theano/tensor/opt.py
+2
-5
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
7885227c
...
@@ -121,7 +121,6 @@ class GpuFromHost(GpuOp):
...
@@ -121,7 +121,6 @@ class GpuFromHost(GpuOp):
check_input
=
False
check_input
=
False
__props__
=
()
def
make_node
(
self
,
x
):
def
make_node
(
self
,
x
):
if
not
isinstance
(
x
.
type
,
tensor
.
TensorType
):
if
not
isinstance
(
x
.
type
,
tensor
.
TensorType
):
...
@@ -178,8 +177,6 @@ class GpuElemwise(GpuOp):
...
@@ -178,8 +177,6 @@ class GpuElemwise(GpuOp):
"""
"""
__props__
=
(
"scalar_op"
,
"inplace_pattern"
,
"sync"
,
)
nin
=
property
(
lambda
self
:
self
.
scalar_op
.
nin
)
nin
=
property
(
lambda
self
:
self
.
scalar_op
.
nin
)
nout
=
property
(
lambda
self
:
self
.
scalar_op
.
nout
)
nout
=
property
(
lambda
self
:
self
.
scalar_op
.
nout
)
...
@@ -231,6 +228,12 @@ class GpuElemwise(GpuOp):
...
@@ -231,6 +228,12 @@ class GpuElemwise(GpuOp):
assert
h
==
getattr
(
self
,
'_hashval'
,
h
)
assert
h
==
getattr
(
self
,
'_hashval'
,
h
)
self
.
_hashval
=
h
self
.
_hashval
=
h
def
__eq__
(
self
,
other
):
return
(
type
(
self
)
==
type
(
other
)
and
self
.
scalar_op
==
other
.
scalar_op
and
self
.
inplace_pattern
==
other
.
inplace_pattern
and
self
.
sync
==
other
.
sync
)
def
__hash__
(
self
):
def
__hash__
(
self
):
return
self
.
_hashval
return
self
.
_hashval
...
@@ -309,9 +312,9 @@ class GpuDimShuffle(GpuOp):
...
@@ -309,9 +312,9 @@ class GpuDimShuffle(GpuOp):
check_broadcast
=
False
check_broadcast
=
False
__props__
=
(
"input_broadcastable"
,
"
inplace"
,
"
new_order"
)
__props__
=
(
"input_broadcastable"
,
"new_order"
)
def
__init__
(
self
,
input_broadcastable
,
inplace
,
new_order
):
def
__init__
(
self
,
input_broadcastable
,
new_order
):
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
)
...
...
theano/sandbox/cuda/blas.py
浏览文件 @
7885227c
...
@@ -2207,6 +2207,9 @@ class GpuDownsampleFactorMax(GpuOp):
...
@@ -2207,6 +2207,9 @@ class GpuDownsampleFactorMax(GpuOp):
Implement downsample with max on the gpu.
Implement downsample with max on the gpu.
"""
"""
__props__
=
(
'ds'
,
'ignore_border'
)
def
__init__
(
self
,
ds
,
ignore_border
=
False
):
def
__init__
(
self
,
ds
,
ignore_border
=
False
):
self
.
ds
=
tuple
(
ds
)
self
.
ds
=
tuple
(
ds
)
self
.
ignore_border
=
ignore_border
self
.
ignore_border
=
ignore_border
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
7885227c
...
@@ -288,7 +288,7 @@ def local_gpu_elemwise_0(node):
...
@@ -288,7 +288,7 @@ def local_gpu_elemwise_0(node):
new_op
=
GpuElemwise
(
erfcx_gpu
)
new_op
=
GpuElemwise
(
erfcx_gpu
)
else
:
else
:
try
:
try
:
new_op
=
GpuElemwise
(
**
node
.
op
.
_props_dict
()
)
new_op
=
GpuElemwise
(
node
.
op
.
scalar_op
)
except
SupportCodeError
:
except
SupportCodeError
:
# This happens when scalar_op requires support code
# This happens when scalar_op requires support code
return
False
return
False
...
@@ -398,9 +398,6 @@ def local_gpu_dimshuffle_0(node):
...
@@ -398,9 +398,6 @@ def local_gpu_dimshuffle_0(node):
input
,
=
node
.
inputs
input
,
=
node
.
inputs
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
if
'inplace'
in
node
.
op
.
_props_dict
():
import
pdb
pdb
.
set_trace
()
new_op
=
GpuDimShuffle
(
**
node
.
op
.
_props_dict
())
new_op
=
GpuDimShuffle
(
**
node
.
op
.
_props_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
):
...
@@ -1130,7 +1127,7 @@ def local_gpu_advanced_incsubtensor1(node):
...
@@ -1130,7 +1127,7 @@ def local_gpu_advanced_incsubtensor1(node):
compute_capability
=
device_properties
(
active_device_no
)[
'major'
]
compute_capability
=
device_properties
(
active_device_no
)[
'major'
]
if
(
compute_capability
<
2
or
y
.
ndim
!=
2
or
x
.
ndim
!=
2
):
if
(
compute_capability
<
2
or
y
.
ndim
!=
2
or
x
.
ndim
!=
2
):
gpu_op
=
tensor
.
AdvancedIncSubtensor1
(
**
node
.
op
.
_props_dict
()
)
gpu_op
=
GpuAdvancedIncSubtensor1
(
set_instead_of_inc
=
set_instead_of_inc
)
else
:
else
:
gpu_op
=
theano
.
sandbox
.
cuda
.
basic_ops
.
GPUAdvancedIncSubtensor1_dev20
(
**
node
.
op
.
_props_dict
())
gpu_op
=
theano
.
sandbox
.
cuda
.
basic_ops
.
GPUAdvancedIncSubtensor1_dev20
(
**
node
.
op
.
_props_dict
())
return
[
gpu_op
(
as_cuda_ndarray_variable
(
x
),
return
[
gpu_op
(
as_cuda_ndarray_variable
(
x
),
...
@@ -1915,7 +1912,7 @@ def local_gpu_downsample_factor_max(node):
...
@@ -1915,7 +1912,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
.
ds
,
node
.
op
.
ignore_border
)
gpu_ds
=
GpuDownsampleFactorMax
(
**
node
.
op
.
_props_dict
()
)
return
[
host_from_gpu
(
gpu_ds
(
x
.
owner
.
inputs
[
0
]))]
return
[
host_from_gpu
(
gpu_ds
(
x
.
owner
.
inputs
[
0
]))]
...
...
theano/tensor/elemwise.py
浏览文件 @
7885227c
...
@@ -140,7 +140,11 @@ class DimShuffle(Op):
...
@@ -140,7 +140,11 @@ class DimShuffle(Op):
self
.
input_broadcastable
=
input_broadcastable
self
.
input_broadcastable
=
input_broadcastable
new_order
=
tuple
(
new_order
)
new_order
=
tuple
(
new_order
)
self
.
new_order
=
new_order
self
.
new_order
=
new_order
if
inplace
is
True
:
self
.
inplace
=
inplace
self
.
inplace
=
inplace
self
.
_props_dict
()
.
pop
(
'inplace'
)
else
:
raise
ValueError
(
"DimShuffle is inplace by default and hence the inplace for DimShuffle must be true"
)
for
i
,
j
in
enumerate
(
new_order
):
for
i
,
j
in
enumerate
(
new_order
):
if
j
!=
'x'
:
if
j
!=
'x'
:
...
@@ -503,8 +507,6 @@ second dimension
...
@@ -503,8 +507,6 @@ second dimension
"""
"""
__props__
=
(
"scalar_op"
,
"inplace_pattern"
)
def
__init__
(
self
,
scalar_op
,
inplace_pattern
=
None
,
name
=
None
,
def
__init__
(
self
,
scalar_op
,
inplace_pattern
=
None
,
name
=
None
,
nfunc_spec
=
None
,
openmp
=
None
):
nfunc_spec
=
None
,
openmp
=
None
):
if
inplace_pattern
is
None
:
if
inplace_pattern
is
None
:
...
@@ -800,7 +802,7 @@ second dimension
...
@@ -800,7 +802,7 @@ second dimension
# dimensions
# dimensions
res
=
theano
.
tensor
.
constant
(
numpy
.
asarray
(
r
.
data
),
res
=
theano
.
tensor
.
constant
(
numpy
.
asarray
(
r
.
data
),
dtype
=
r
.
type
.
dtype
)
dtype
=
r
.
type
.
dtype
)
return
DimShuffle
((),
[
'x'
]
*
nd
,
inplace
=
False
)(
res
)
return
DimShuffle
((),
[
'x'
]
*
nd
)(
res
)
new_r
=
Elemwise
(
node
.
op
,
{})(
new_r
=
Elemwise
(
node
.
op
,
{})(
*
[
transform
(
ipt
)
for
ipt
in
node
.
inputs
])
*
[
transform
(
ipt
)
for
ipt
in
node
.
inputs
])
...
...
theano/tensor/opt.py
浏览文件 @
7885227c
...
@@ -561,8 +561,7 @@ def local_dimshuffle_lift(node):
...
@@ -561,8 +561,7 @@ def local_dimshuffle_lift(node):
new_inputs
=
[]
new_inputs
=
[]
for
inp
in
inode
.
inputs
:
for
inp
in
inode
.
inputs
:
new_inp
=
op
.
__class__
(
inp
.
type
.
broadcastable
,
new_inp
=
op
.
__class__
(
inp
.
type
.
broadcastable
,
op
.
new_order
,
op
.
new_order
)(
inp
)
op
.
inplace
)(
inp
)
new_inputs
.
append
(
apply_local_dimshuffle_lift
(
new_inp
))
new_inputs
.
append
(
apply_local_dimshuffle_lift
(
new_inp
))
copy_stack_trace
(
node
.
outputs
[
0
],
new_inputs
)
copy_stack_trace
(
node
.
outputs
[
0
],
new_inputs
)
ret
=
inode
.
op
(
*
new_inputs
,
**
dict
(
return_list
=
True
))
ret
=
inode
.
op
(
*
new_inputs
,
**
dict
(
return_list
=
True
))
...
@@ -570,14 +569,12 @@ def local_dimshuffle_lift(node):
...
@@ -570,14 +569,12 @@ def local_dimshuffle_lift(node):
if
inode
and
isinstance
(
inode
.
op
,
DimShuffle
):
if
inode
and
isinstance
(
inode
.
op
,
DimShuffle
):
new_order
=
[
x
==
'x'
and
'x'
or
inode
.
op
.
new_order
[
x
]
for
x
in
new_order
=
[
x
==
'x'
and
'x'
or
inode
.
op
.
new_order
[
x
]
for
x
in
new_order
]
new_order
]
inplace
=
op
.
inplace
and
inode
.
op
.
inplace
input
=
inode
.
inputs
[
0
]
input
=
inode
.
inputs
[
0
]
if
is_dimshuffle_useless
(
new_order
,
input
):
if
is_dimshuffle_useless
(
new_order
,
input
):
return
[
input
]
return
[
input
]
elif
inode
and
isinstance
(
inode
.
op
,
DimShuffle
):
elif
inode
and
isinstance
(
inode
.
op
,
DimShuffle
):
ret
=
op
.
__class__
(
input
.
type
.
broadcastable
,
new_order
,
ret
=
op
.
__class__
(
input
.
type
.
broadcastable
,
new_order
)(
input
)
inplace
)(
input
)
ret
=
apply_local_dimshuffle_lift
(
ret
)
ret
=
apply_local_dimshuffle_lift
(
ret
)
copy_stack_trace
(
node
.
outputs
[
0
],
ret
)
copy_stack_trace
(
node
.
outputs
[
0
],
ret
)
return
[
ret
]
return
[
ret
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论