Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
66d7f5c7
提交
66d7f5c7
authored
4月 01, 2014
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1789 from nouiz/faster_opt
Faster opt (and other unrelated things).
上级
7194cb2b
59fa3b3f
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
7 行增加
和
30 行删除
+7
-30
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+1
-26
opt.py
theano/sandbox/cuda/opt.py
+2
-2
opt.py
theano/tensor/opt.py
+4
-2
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
66d7f5c7
...
...
@@ -296,38 +296,15 @@ class GpuDimShuffle(GpuOp):
def
__init__
(
self
,
input_broadcastable
,
new_order
):
input_broadcastable
=
tuple
(
input_broadcastable
)
self
.
input_broadcastable
=
input_broadcastable
new_order
=
tuple
(
new_order
)
self
.
new_order
=
new_order
# list of dimensions of the input to drop
self
.
drop
=
[]
# this maps i before dropping dimensions to j after dropping
# dimensions so self.shuffle can be set properly later on
i2j
=
{}
j
=
0
for
i
,
b
in
enumerate
(
input_broadcastable
):
if
i
not
in
new_order
:
# we want to drop this dimension because it's not a
# value in new_order
if
b
==
1
:
# 1 aka True
self
.
drop
.
append
(
i
)
else
:
if
not
b
:
# we cannot drop non-broadcastable dimensions
raise
ValueError
(
"You cannot drop a non-broadcastable"
" dimension."
,
(
input_broadcastable
,
new_order
))
else
:
i2j
[
i
]
=
j
j
+=
1
# transposition of non-broadcastable dimensions This is how
# the dimensions will be permuted, without accounting for the
# extra 'x' broadcastable dimensions to insert.
self
.
shuffle
=
[
i2j
[
x
]
for
x
in
new_order
if
x
!=
'x'
]
# list of dimensions of the output that are broadcastable and
# were not in the original input
self
.
augment
=
[
i
for
i
,
x
in
enumerate
(
new_order
)
if
x
==
'x'
]
self
.
view_map
=
{
0
:
[
0
]}
...
...
@@ -481,8 +458,6 @@ class GpuDimShuffle(GpuOp):
print
self
print
"IN BROAD"
,
self
.
input_broadcastable
print
"NEW ORDER"
,
self
.
new_order
print
"SHUFFLE"
,
self
.
shuffle
print
"AUGMENT"
,
self
.
augment
print
'------------'
print
''
print
sio
.
getvalue
()
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
66d7f5c7
...
...
@@ -284,7 +284,7 @@ def local_gpu_dimshuffle_0(node):
if
input
.
owner
and
isinstance
(
input
.
owner
.
op
,
HostFromGpu
):
# move the add to a GpuAdd
new_op
=
GpuDimShuffle
(
node
.
op
.
input_broadcastable
,
node
.
op
.
new_order
)
node
.
op
.
new_order
)
return
[
host_from_gpu
(
new_op
(
gpu_from_host
(
input
)))]
if
isinstance
(
node
.
op
,
GpuFromHost
):
host_input
=
node
.
inputs
[
0
]
...
...
@@ -292,7 +292,7 @@ def local_gpu_dimshuffle_0(node):
tensor
.
DimShuffle
):
dimshuffle_node
=
host_input
.
owner
new_op
=
GpuDimShuffle
(
dimshuffle_node
.
op
.
input_broadcastable
,
dimshuffle_node
.
op
.
new_order
)
dimshuffle_node
.
op
.
new_order
)
return
[
new_op
(
gpu_from_host
(
dimshuffle_node
.
inputs
[
0
]))]
return
False
...
...
theano/tensor/opt.py
浏览文件 @
66d7f5c7
...
...
@@ -2611,8 +2611,10 @@ register_canonicalize(gof.OpRemove(T.tensor_copy), name='remove_tensor_copy')
def
local_fill_sink
(
node
):
"""
f(fill(a, b), fill(c, d), e) -> fill(a, fill(c, f(b, d, e)))
f need to be an elemwise
"""
if
not
(
node
.
op
and
isinstance
(
node
.
op
,
T
.
Elemwise
)
and
node
.
op
!=
T
.
fill
)
:
if
not
isinstance
(
node
.
op
,
T
.
Elemwise
)
or
node
.
op
==
T
.
fill
:
return
False
models
=
[]
inputs
=
[]
...
...
@@ -2622,7 +2624,7 @@ def local_fill_sink(node):
inputs
.
append
(
input
.
owner
.
inputs
[
1
])
else
:
inputs
.
append
(
input
)
if
inputs
==
node
.
input
s
:
if
not
model
s
:
return
False
c
=
node
.
op
(
*
inputs
)
for
model
in
models
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论