Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
97174b84
提交
97174b84
authored
11月 10, 2015
作者:
carriepl
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3619 from nouiz/switch_opt
fix gh-3614, fix switch opt when both branch are the same and we broa…
上级
29732d84
ced1686d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
2 行删除
+17
-2
opt.py
theano/tensor/opt.py
+3
-1
test_opt.py
theano/tensor/tests/test_opt.py
+14
-1
没有找到文件。
theano/tensor/opt.py
浏览文件 @
97174b84
...
@@ -3471,7 +3471,9 @@ def local_useless_switch(node):
...
@@ -3471,7 +3471,9 @@ def local_useless_switch(node):
return
[
out
]
return
[
out
]
# if left is right -> left
# if left is right -> left
if
node
.
inputs
[
1
]
is
node
.
inputs
[
2
]:
if
node
.
inputs
[
1
]
is
node
.
inputs
[
2
]:
return
[
node
.
inputs
[
1
]]
if
cond
.
type
==
node
.
inputs
[
1
]
.
type
:
return
[
node
.
inputs
[
1
]]
return
[
T
.
fill
(
cond
,
node
.
inputs
[
1
])]
# This case happens with scan.
# This case happens with scan.
# Elemwise{switch}(le(shape_i{id}(X), 0), 0, shape_i{id}(X)) -> shape_i{id}(X)
# Elemwise{switch}(le(shape_i{id}(X), 0), 0, shape_i{id}(X)) -> shape_i{id}(X)
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
97174b84
...
@@ -4589,7 +4589,7 @@ class T_local_erfc(unittest.TestCase):
...
@@ -4589,7 +4589,7 @@ class T_local_erfc(unittest.TestCase):
print
(
t1
-
t0
,
t2
-
t1
)
print
(
t1
-
t0
,
t2
-
t1
)
class
test_local_
remove_switch_const_cond
(
unittest
.
TestCase
):
class
test_local_
useless_switch
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
mode
=
mode_opt
.
excluding
(
'constant_folding'
)
self
.
mode
=
mode_opt
.
excluding
(
'constant_folding'
)
...
@@ -4717,6 +4717,19 @@ class test_local_remove_switch_const_cond(unittest.TestCase):
...
@@ -4717,6 +4717,19 @@ class test_local_remove_switch_const_cond(unittest.TestCase):
vy
=
numpy
.
array
([[
7
,
8
,
9
],
[
10
,
11
,
12
]],
dtype
=
'int64'
)
vy
=
numpy
.
array
([[
7
,
8
,
9
],
[
10
,
11
,
12
]],
dtype
=
'int64'
)
assert
numpy
.
all
(
f
(
vx
,
vy
)
==
vy
)
assert
numpy
.
all
(
f
(
vx
,
vy
)
==
vy
)
def
test_broadcast3
(
self
):
# test switch(matrix, same_vector, same_vector)
x
=
theano
.
tensor
.
matrix
(
'x'
,
dtype
=
'int32'
)
y
=
theano
.
tensor
.
vector
(
'y'
,
dtype
=
'int64'
)
z
=
theano
.
tensor
.
switch
(
x
,
y
,
y
)
f
=
theano
.
function
([
x
,
y
],
z
,
mode
=
self
.
mode
)
vx
=
numpy
.
array
([[
0
,
1
],
[
1
,
0
]],
dtype
=
'int32'
)
vy
=
numpy
.
array
([
7
,
8
],
dtype
=
'int64'
)
utt
.
assert_allclose
(
f
(
vx
,
vy
),
numpy
.
where
(
vx
,
vy
,
vy
))
assert
len
([
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()
if
isinstance
(
node
.
op
,
theano
.
tensor
.
Elemwise
)])
==
0
class
T_local_sum_prod
(
unittest
.
TestCase
):
class
T_local_sum_prod
(
unittest
.
TestCase
):
"""
"""
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论