Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
290fc8bc
提交
290fc8bc
authored
1月 21, 2016
作者:
Saizheng Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
profile: more changes
上级
96a257ad
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
20 行删除
+19
-20
profiling.py
theano/compile/profiling.py
+19
-20
:w
theano/tensor/:w
+0
-0
没有找到文件。
theano/compile/profiling.py
浏览文件 @
290fc8bc
...
@@ -31,7 +31,6 @@ from six import iteritems
...
@@ -31,7 +31,6 @@ from six import iteritems
from
theano.gof
import
graph
from
theano.gof
import
graph
from
theano.configparser
import
AddConfigVar
,
BoolParam
,
IntParam
,
StrParam
from
theano.configparser
import
AddConfigVar
,
BoolParam
,
IntParam
,
StrParam
theano_imported_time
=
time
.
time
()
theano_imported_time
=
time
.
time
()
config
=
theano
.
config
config
=
theano
.
config
...
@@ -1302,16 +1301,16 @@ class ProfileStats(object):
...
@@ -1302,16 +1301,16 @@ class ProfileStats(object):
print
(
"-----------------"
,
file
=
file
)
print
(
"-----------------"
,
file
=
file
)
self
.
optimizer_profile
[
0
]
.
print_profile
(
file
,
self
.
optimizer_profile
[
0
]
.
print_profile
(
file
,
self
.
optimizer_profile
[
1
])
self
.
optimizer_profile
[
1
])
self
.
print_tips
()
self
.
print_tips
(
file
)
def
print_tips
(
self
):
def
print_tips
(
self
,
file
):
print
(
"""Here are tips to potentially make your code run faster
print
(
"""Here are tips to potentially make your code run faster
(if you think of new ones, suggest them on the mailing list).
(if you think of new ones, suggest them on the mailing list).
Test them first, as they are not guaranteed to always provide a speedup."""
)
Test them first, as they are not guaranteed to always provide a speedup."""
,
file
=
file
)
from
theano
import
tensor
as
T
from
theano.tensor.raw_random
import
RandomFunction
RandomFunction
=
theano
.
tensor
.
raw_random
.
RandomFunction
import
theano
scal
=
theano
.
scalar
import
theano.scalar
as
scal
T
=
theano
.
tensor
scalar_op_amdlibm_no_speed_up
=
[
scal
.
LT
,
scal
.
GT
,
scal
.
LE
,
scal
.
GE
,
scalar_op_amdlibm_no_speed_up
=
[
scal
.
LT
,
scal
.
GT
,
scal
.
LE
,
scal
.
GE
,
scal
.
EQ
,
scal
.
NEQ
,
scal
.
InRange
,
scal
.
EQ
,
scal
.
NEQ
,
scal
.
InRange
,
scal
.
Switch
,
scal
.
OR
,
scal
.
XOR
,
scal
.
Switch
,
scal
.
OR
,
scal
.
XOR
,
...
@@ -1356,7 +1355,7 @@ class ProfileStats(object):
...
@@ -1356,7 +1355,7 @@ class ProfileStats(object):
return
True
return
True
elif
s_op
.
__class__
not
in
scalar_op_amdlibm_no_speed_up
:
elif
s_op
.
__class__
not
in
scalar_op_amdlibm_no_speed_up
:
print
(
"We don't know if amdlibm will accelerate "
print
(
"We don't know if amdlibm will accelerate "
"this scalar op."
,
s_op
)
"this scalar op."
,
s_op
,
file
=
file
)
return
False
return
False
def
exp_float32_op
(
op
):
def
exp_float32_op
(
op
):
...
@@ -1369,28 +1368,28 @@ class ProfileStats(object):
...
@@ -1369,28 +1368,28 @@ class ProfileStats(object):
printed_tip
=
False
printed_tip
=
False
# tip 1
# tip 1
if
config
.
floatX
==
'float64'
:
if
config
.
floatX
==
'float64'
:
print
(
" - Try the Theano flag floatX=float32"
)
print
(
" - Try the Theano flag floatX=float32"
,
file
=
file
)
printed_tip
=
True
printed_tip
=
True
# tip 2
# tip 2
if
not
config
.
lib
.
amdlibm
and
any
([
amdlibm_speed_up
(
a
.
op
)
for
i
,
a
if
not
config
.
lib
.
amdlibm
and
any
([
amdlibm_speed_up
(
a
.
op
)
for
a
in
self
.
apply_time
]):
in
self
.
apply_time
]):
print
(
" - Try installing amdlibm and set the Theano flag "
print
(
" - Try installing amdlibm and set the Theano flag "
"lib.amdlibm=True. This speeds up only some Elemwise "
"lib.amdlibm=True. This speeds up only some Elemwise "
"operation."
)
"operation."
,
file
=
file
)
printed_tip
=
True
printed_tip
=
True
# tip 3
# tip 3
if
not
config
.
lib
.
amdlibm
and
any
([
exp_float32_op
(
a
.
op
)
and
if
not
config
.
lib
.
amdlibm
and
any
([
exp_float32_op
(
a
.
op
)
and
a
.
inputs
[
0
]
.
dtype
==
'float32'
a
.
inputs
[
0
]
.
dtype
==
'float32'
for
i
,
a
in
self
.
apply_time
]):
for
a
in
self
.
apply_time
]):
print
(
" - With the default gcc libm, exp in float32 is slower "
print
(
" - With the default gcc libm, exp in float32 is slower "
"than in float64! Try Theano flag floatX=float64, or "
"than in float64! Try Theano flag floatX=float64, or "
"install amdlibm and set the theano flags lib.amdlibm=True"
)
"install amdlibm and set the theano flags lib.amdlibm=True"
,
file
=
file
)
printed_tip
=
True
printed_tip
=
True
# tip 4
# tip 4
for
a
,
t
in
iteritems
(
self
.
apply_time
)
:
for
a
in
self
.
apply_time
:
node
=
a
node
=
a
if
(
isinstance
(
node
.
op
,
T
.
Dot
)
and
if
(
isinstance
(
node
.
op
,
T
.
Dot
)
and
all
([
len
(
i
.
type
.
broadcastable
)
==
2
all
([
len
(
i
.
type
.
broadcastable
)
==
2
...
@@ -1399,25 +1398,25 @@ class ProfileStats(object):
...
@@ -1399,25 +1398,25 @@ class ProfileStats(object):
" dot22 (which is faster). Make sure the inputs are "
" dot22 (which is faster). Make sure the inputs are "
"float32 or float64, and are the same for both inputs. "
"float32 or float64, and are the same for both inputs. "
"Currently they are:
%
s"
%
"Currently they are:
%
s"
%
[
i
.
type
for
i
in
node
.
inputs
])
[
i
.
type
for
i
in
node
.
inputs
]
,
file
=
file
)
printed_tip
=
True
printed_tip
=
True
# tip 5
# tip 5
for
a
,
t
in
iteritems
(
self
.
apply_time
)
:
for
a
in
self
.
apply_time
:
node
=
a
node
=
a
if
isinstance
(
node
.
op
,
RandomFunction
):
if
isinstance
(
node
.
op
,
RandomFunction
):
printed_tip
=
True
printed_tip
=
True
print
(
" - Replace the default random number generator by "
print
(
" - Replace the default random number generator by "
"'from theano.sandbox.rng_mrg import MRG_RandomStreams "
"'from theano.sandbox.rng_mrg import MRG_RandomStreams "
"as RandomStreams', as this is is faster. It is still "
"as RandomStreams', as this is is faster. It is still "
"experimental, but seems to work correctly."
)
"experimental, but seems to work correctly."
,
file
=
file
)
if
config
.
device
.
startswith
(
"gpu"
):
if
config
.
device
.
startswith
(
"gpu"
):
print
(
" - MRG_RandomStreams is the only random number"
print
(
" - MRG_RandomStreams is the only random number"
" generator supported on the GPU."
)
" generator supported on the GPU."
,
file
=
file
)
break
break
if
not
printed_tip
:
if
not
printed_tip
:
print
(
" Sorry, no tip for today."
)
print
(
" Sorry, no tip for today."
,
file
=
file
)
if
False
:
# old code still to be ported from ProfileMode
if
False
:
# old code still to be ported from ProfileMode
...
...
theano/tensor/:w
0 → 100644
浏览文件 @
290fc8bc
This source diff could not be displayed because it is too large. You can
view the blob
instead.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论