Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
264ea310
提交
264ea310
authored
2月 26, 2016
作者:
Caglar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed the flake8 errors.
上级
73c28a05
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
16 行删除
+16
-16
opt.py
theano/tensor/opt.py
+16
-16
没有找到文件。
theano/tensor/opt.py
浏览文件 @
264ea310
...
...
@@ -1220,7 +1220,7 @@ class ShapeFeature(object):
# But we never timed this speed optimization!
self
.
lscalar_one
.
equals
(
new_shape
[
idx
])
or
self
.
lscalar_one
.
equals
(
T
.
extract_constant
(
new_shape
[
idx
],
only_process_constants
=
True
))
only_process_constants
=
True
))
for
idx
in
xrange
(
r
.
ndim
)])
self
.
shape_of
[
r
]
=
tuple
(
new_shape
)
for
sv
in
self
.
shape_of
[
r
]:
...
...
@@ -2393,7 +2393,7 @@ def local_useless_inc_subtensor(node):
idx_cst
=
get_idx_list
(
node
.
inputs
[
1
:],
node
.
op
.
idx_list
)
if
all
(
isinstance
(
e
,
slice
)
and
e
.
start
is
None
and
e
.
stop
is
None
and
(
e
.
step
is
None
or
T
.
extract_constant
(
e
.
step
,
only_process_constants
=
True
)
==
-
1
)
only_process_constants
=
True
)
==
-
1
)
for
e
in
idx_cst
):
# IncSubtensor broadcast node.inputs[1] on node.inputs[0]
# based on run time shapes, so we must check they are the same.
...
...
@@ -2464,7 +2464,7 @@ def local_useless_slice(node):
# check if slice and then check slice indices
if
(
isinstance
(
s
,
slice
)
and
s
.
start
is
None
and
s
.
stop
is
None
and
(
s
.
step
is
None
or
T
.
extract_constant
(
s
.
step
,
only_process_constants
=
True
)
==
1
)):
only_process_constants
=
True
)
==
1
)):
last_slice
-=
1
else
:
break
...
...
@@ -2580,7 +2580,7 @@ def local_useless_subtensor(node):
elif
idx
.
owner
is
not
None
and
isinstance
(
idx
.
owner
.
op
,
T
.
ARange
):
try
:
start
,
stop
,
step
=
map
(
lambda
x
:
get_scalar_constant_value
(
x
,
only_process_constants
=
True
),
only_process_constants
=
True
),
idx
.
owner
.
inputs
)
except
NotScalarConstantError
:
return
False
...
...
@@ -3577,7 +3577,7 @@ def local_join_empty(node):
new_inputs
=
[]
try
:
join_idx
=
get_scalar_constant_value
(
node
.
inputs
[
0
],
only_process_constants
=
True
)
only_process_constants
=
True
)
except
NotScalarConstantError
:
return
for
idx
in
xrange
(
1
,
len
(
node
.
inputs
)):
...
...
@@ -3737,7 +3737,7 @@ def local_useless_switch(node):
if
(
isinstance
(
node
.
op
,
T
.
Elemwise
)
and
isinstance
(
node
.
op
.
scalar_op
,
scalar
.
basic
.
Switch
)):
cond
=
T
.
extract_constant
(
node
.
inputs
[
0
],
elemwise
=
False
,
only_process_constants
=
True
)
only_process_constants
=
True
)
if
type
(
cond
)
is
numpy
.
ndarray
and
cond
.
ndim
==
0
:
if
cond
==
0
:
correct_out
=
node
.
inputs
[
2
]
...
...
@@ -3900,7 +3900,7 @@ def local_div_switch_sink(node):
switch
=
node
.
inputs
[
0
]
.
owner
try
:
if
get_scalar_constant_value
(
switch
.
inputs
[
1
],
only_process_constants
=
True
)
==
0.
:
only_process_constants
=
True
)
==
0.
:
fdiv
=
op
(
switch
.
inputs
[
2
],
node
.
inputs
[
1
])
# Copy over stacktrace for elementwise division op
# from previous elementwise multiplication op.
...
...
@@ -3923,7 +3923,7 @@ def local_div_switch_sink(node):
pass
try
:
if
get_scalar_constant_value
(
switch
.
inputs
[
2
],
only_process_constants
=
True
)
==
0.
:
only_process_constants
=
True
)
==
0.
:
fdiv
=
op
(
switch
.
inputs
[
1
],
node
.
inputs
[
1
])
# Copy over stacktrace for elementwise division op
# from previous elementwise multiplication op.
...
...
@@ -3989,7 +3989,7 @@ def local_useless_tile(node):
if
isinstance
(
node
.
op
,
T
.
Tile
):
try
:
a
=
T
.
get_scalar_constant_value
(
node
.
inputs
[
1
],
only_process_constants
=
True
)
only_process_constants
=
True
)
if
a
==
1
:
try
:
l
=
T
.
get_vector_length
(
node
.
inputs
[
1
])
...
...
@@ -4173,7 +4173,7 @@ if 0:
def
tmp
(
thing
):
try
:
return
T
.
get_scalar_constant_value
(
thing
,
only_process_constants
=
True
)
only_process_constants
=
True
)
except
(
TypeError
,
ValueError
)
as
e
:
print
(
e
,
thing
.
owner
.
inputs
[
0
])
return
None
...
...
@@ -5221,7 +5221,7 @@ def local_reduce_join(node):
# We add the new check late to don't add extra warning.
try
:
join_axis
=
get_scalar_constant_value
(
join
.
inputs
[
0
],
only_process_constants
=
True
)
only_process_constants
=
True
)
if
join_axis
!=
reduce_axis
[
0
]:
return
...
...
@@ -5305,7 +5305,7 @@ def local_opt_alloc(node):
node
.
op
.
axis
==
tuple
(
range
(
input
.
ndim
))):
try
:
val
=
get_scalar_constant_value
(
input
,
only_process_constants
=
True
)
only_process_constants
=
True
)
assert
val
.
size
==
1
# check which type of op
casted
=
T
.
mul
(
*
shapes
)
.
astype
(
str
(
input
.
dtype
))
...
...
@@ -5320,7 +5320,7 @@ def local_opt_alloc(node):
else
:
try
:
val
=
get_scalar_constant_value
(
input
,
only_process_constants
=
True
)
only_process_constants
=
True
)
assert
val
.
size
==
1
val
=
val
.
reshape
(
1
)[
0
]
to_prod
=
[
shapes
[
i
]
for
i
in
xrange
(
len
(
shapes
))
...
...
@@ -5765,7 +5765,7 @@ def local_abs_merge(node):
elif
isinstance
(
i
,
Constant
):
try
:
const
=
get_scalar_constant_value
(
i
,
only_process_constants
=
True
)
only_process_constants
=
True
)
except
NotScalarConstantError
:
return
False
if
not
(
const
>=
0
)
.
all
():
...
...
@@ -6348,7 +6348,7 @@ def local_grad_log_erfc_neg(node):
try
:
cst2
=
get_scalar_constant_value
(
mul_neg
.
owner
.
inputs
[
0
],
only_process_constants
=
True
)
only_process_constants
=
True
)
except
NotScalarConstantError
:
return
False
...
...
@@ -6376,7 +6376,7 @@ def local_grad_log_erfc_neg(node):
x
=
erfc_x
try
:
cst
=
get_scalar_constant_value
(
erfc_x
.
owner
.
inputs
[
0
],
only_process_constants
=
True
)
only_process_constants
=
True
)
except
NotScalarConstantError
:
return
False
if
cst2
!=
-
cst
*
2
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论