Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a500f3a9
提交
a500f3a9
authored
10月 30, 2009
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implemented theano.gof.utils.get_theano_flag to parse the THEANO_FLAGS env variable and use it.
上级
c807a893
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
36 行增加
和
10 行删除
+36
-10
profilemode.py
theano/compile/profilemode.py
+5
-0
utils.py
theano/gof/utils.py
+25
-1
opt.py
theano/tensor/opt.py
+6
-9
没有找到文件。
theano/compile/profilemode.py
浏览文件 @
a500f3a9
...
@@ -5,6 +5,7 @@ from theano.gof.cutils import run_cthunk
...
@@ -5,6 +5,7 @@ from theano.gof.cutils import run_cthunk
from
theano.compile.mode
import
Mode
,
register_mode
,
predefined_modes
,
predefined_linkers
,
predefined_optimizers
,
default_linker
,
default_optimizer
from
theano.compile.mode
import
Mode
,
register_mode
,
predefined_modes
,
predefined_linkers
,
predefined_optimizers
,
default_linker
,
default_optimizer
from
theano.gof.cc
import
OpWiseCLinker
from
theano.gof.cc
import
OpWiseCLinker
from
theano
import
gof
from
theano
import
gof
from
theano.gof.utils
import
get_theano_flag
class
ProfileMode
(
Mode
):
class
ProfileMode
(
Mode
):
def
__init__
(
self
,
linker
=
default_linker
,
optimizer
=
default_optimizer
):
def
__init__
(
self
,
linker
=
default_linker
,
optimizer
=
default_optimizer
):
...
@@ -85,6 +86,10 @@ class ProfileMode(Mode):
...
@@ -85,6 +86,10 @@ class ProfileMode(Mode):
param: n_ops_to_print the number of ops to print. Default 20.
param: n_ops_to_print the number of ops to print. Default 20.
"""
"""
n_ops_to_print
=
int
(
get_theano_flag
(
"n_ops_to_print"
,
n_ops_to_print
))
n_apply_to_print
=
int
(
get_theano_flag
(
"n_apply_to_print"
,
n_apply_to_print
))
local_time
=
self
.
local_time
[
0
]
local_time
=
self
.
local_time
[
0
]
compile_time
=
self
.
compile_time
compile_time
=
self
.
compile_time
apply_time
=
self
.
apply_time
apply_time
=
self
.
apply_time
...
...
theano/gof/utils.py
浏览文件 @
a500f3a9
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
# import op
# import op
# import variable
# import variable
import
re
import
re
,
os
def
hashgen
():
def
hashgen
():
hashgen
.
next
+=
1
hashgen
.
next
+=
1
...
@@ -369,3 +369,27 @@ def type_guard(type1):
...
@@ -369,3 +369,27 @@ def type_guard(type1):
return
new_f
return
new_f
return
wrap
return
wrap
def
get_theano_flag
(
key
,
default
=
None
):
"""
This function parse the environement variable THEANO_FLAGS.
if the variable don't exist return None
if the key is not in the variable return None
if the key is in the variable but without a value return True
if the key is in the variable with a value return the value
if the key appear many times, we return the last value
the THEANO_FLAGS environement variable is a list of key[=value] that is separated by comma.
"""
f
=
os
.
getenv
(
"THEANO_FLAGS"
)
ret
=
default
key2
=
key
+
"="
for
fl
in
f
.
split
(
','
):
if
fl
==
key
:
ret
=
True
elif
fl
.
startswith
(
key2
):
ret
=
fl
.
split
(
'='
,
1
)[
1
]
return
ret
theano/tensor/opt.py
浏览文件 @
a500f3a9
...
@@ -8,7 +8,7 @@ _logger = logging.getLogger('theano.tensor.opt')
...
@@ -8,7 +8,7 @@ _logger = logging.getLogger('theano.tensor.opt')
from
theano
import
gof
from
theano
import
gof
from
theano.gof
import
opt
,
InconsistencyError
,
TopoOptimizer
,
graph
from
theano.gof
import
opt
,
InconsistencyError
,
TopoOptimizer
,
graph
from
theano.gof.utils
import
MethodNotDefined
from
theano.gof.utils
import
MethodNotDefined
,
get_theano_flag
from
elemwise
import
Elemwise
,
DimShuffle
from
elemwise
import
Elemwise
,
DimShuffle
from
theano
import
scalar
from
theano
import
scalar
import
basic
as
T
import
basic
as
T
...
@@ -1339,14 +1339,11 @@ def local_elemwise_fusion(node):
...
@@ -1339,14 +1339,11 @@ def local_elemwise_fusion(node):
# print "local_elemwise_fusion: FUSED",nb_elemwise+1,"elemwise!"
# print "local_elemwise_fusion: FUSED",nb_elemwise+1,"elemwise!"
return
n
.
outputs
return
n
.
outputs
flags
=
os
.
getenv
(
'THEANO_FLAGS'
,
None
)
if
get_theano_flag
(
'local_elemwise_fusion'
,
False
):
if
flags
:
_logger
.
debug
(
"enabling optimization: fusion elemwise"
)
flags
=
flags
.
split
(
','
)
register_specialize
(
local_elemwise_fusion
)
if
'local_elemwise_fusion'
in
flags
:
else
:
_logger
.
debug
(
"enabling optimization: fusion elemwise"
)
_logger
.
debug
(
"not enabling optimization: fusion elemwise"
)
register_specialize
(
local_elemwise_fusion
)
else
:
_logger
.
debug
(
"not enabling optimization: fusion elemwise"
)
# def make_composite(inputs, outputs):
# def make_composite(inputs, outputs):
# scalar_inputs = [scalar.Scalar(dtype = i.type.dtype)() for i in inputs]
# scalar_inputs = [scalar.Scalar(dtype = i.type.dtype)() for i in inputs]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论