提交 26eb2c22 authored 作者: Frederic Bastien's avatar Frederic Bastien

print " Sorry no tip for today." when no tips in the profiler following code review comments.

上级 9dbacd88
......@@ -476,7 +476,9 @@ class ProfileMode(Mode):
print
print "Here are tips to potentially make your code run faster (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."
print """Here are tips to potentially make your code run faster
(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."""
from theano import tensor as T
from theano.tensor.raw_random import RandomFunction
import theano
......@@ -514,33 +516,41 @@ class ProfileMode(Mode):
l = list_scalar_op(op)
return any([s_op.__class__ in [scal.Exp] for s_op in l])
gived_tip = False
#tip 1
if config.floatX=='float64':
print " - Try the Theano flag floatX=float32"
gived_tip = True
#tip 2
if not config.lib.amdlibm and any([amdlibm_speed_up(a.op) for i,a in apply_time]):
print " - Try installing amdlibm and set the Theano flag lib.amdlibm=True. This speed up only some Elemwise operation."
gived_tip = True
#tip 3
if not config.lib.amdlibm and any([exp_float32_op(a.op) and a.inputs[0].dtype=='float32' for i,a in apply_time]):
print " - With the default gcc libm, exp in float32 is slower then in float64! Try Theano flags floatX=float64 or install amdlibm and set the theano flags lib.amdlibm=True"
gived_tip = True
#tip 4
for a, t in apply_time.iteritems():
node = a[1]
if isinstance(node.op, T.Dot) and all([ len(i.type.broadcastable)==2 for i in node.inputs]):
print " - You have a dot operation that was not optimized to dot22 that is faster. Make sure the inputs are float32 or 64 and are the same for both input. Currently they are:",[i.type for i in node.inputs]
gived_tip = True
#tip 5
for a, t in apply_time.iteritems():
node = a[1]
if isinstance(node.op, RandomFunction):
gived_tip = True
print " - Replace the default random number generator by 'from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams' as this is is faster. It is still experimental, but seam to work correctly."
if config.device.startswith("gpu"):
print " - MRG_RandomStreams is the only random number supported on the GPU."
break
if not gived_tip:
print " Sorry no tip for today."
register_mode('PROFILE_MODE',ProfileMode())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论