Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
04fde4e4
提交
04fde4e4
authored
5月 16, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make a Theano flag openmp and use it in ConvOp to allow to disable it.
In case it cause too much additionel overhead for small image/filter, I want to enable the user to disable it.
上级
583a7553
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
33 行增加
和
4 行删除
+33
-4
config.txt
doc/library/config.txt
+11
-0
configdefaults.py
theano/configdefaults.py
+9
-0
conv.py
theano/tensor/nnet/conv.py
+13
-4
没有找到文件。
doc/library/config.txt
浏览文件 @
04fde4e4
...
@@ -169,6 +169,17 @@ import theano and print the config variable, as in:
...
@@ -169,6 +169,17 @@ import theano and print the config variable, as in:
and similar functions. It also sets the default theano bit width for
and similar functions. It also sets the default theano bit width for
arguments passed as Python floating-point numbers.
arguments passed as Python floating-point numbers.
.. attribute:: openmp
Bool value: either True or False
Default: True
Enable or not parallel computation on the CPU with OpenMP.
It is the default value used when creating an Op that support it.
The best is to define it via Theano configuration
file or with the environment variable THEANO_FLAGS.
.. attribute:: cast_policy
.. attribute:: cast_policy
String value: either 'numpy+floatX' or 'custom'
String value: either 'numpy+floatX' or 'custom'
...
...
theano/configdefaults.py
浏览文件 @
04fde4e4
...
@@ -16,6 +16,15 @@ AddConfigVar('floatX',
...
@@ -16,6 +16,15 @@ AddConfigVar('floatX',
EnumStr
(
'float64'
,
'float32'
),
EnumStr
(
'float64'
,
'float32'
),
)
)
AddConfigVar
(
'openmp'
,
"Enable or not parallel computation on the CPU with OpenMP. "
"It is the default value used when creating an Op that support it"
". The best is to define it via Theano configuration "
"file or with the environment variable THEANO_FLAGS."
,
BoolParam
(
True
),
in_c_key
=
False
,
)
AddConfigVar
(
'cast_policy'
,
AddConfigVar
(
'cast_policy'
,
"Rules for implicit type casting"
,
"Rules for implicit type casting"
,
EnumStr
(
'custom'
,
'numpy+floatX'
,
EnumStr
(
'custom'
,
'numpy+floatX'
,
...
...
theano/tensor/nnet/conv.py
浏览文件 @
04fde4e4
...
@@ -136,7 +136,9 @@ class ConvOp(Op):
...
@@ -136,7 +136,9 @@ class ConvOp(Op):
__attrnames
=
[
'imshp'
,
'kshp'
,
'nkern'
,
'bsize'
,
'dx'
,
'dy'
,
'out_mode'
,
__attrnames
=
[
'imshp'
,
'kshp'
,
'nkern'
,
'bsize'
,
'dx'
,
'dy'
,
'out_mode'
,
'unroll_batch'
,
'unroll_kern'
,
'unroll_patch'
,
'unroll_batch'
,
'unroll_kern'
,
'unroll_patch'
,
'imshp_logical'
,
'kshp_logical'
,
'kshp_logical_top_aligned'
]
'imshp_logical'
,
'kshp_logical'
,
'kshp_logical_top_aligned'
]
"""These attributes uniquely identify the behaviour of this op for given inputs"""
"""These attributes uniquely identify the behaviour of this op for
given inputs. Do not set openmp here.
"""
#the value of speed_unroll_batch_kern,speed_unroll_patch_noshape,speed_unroll_patch_shape
#the value of speed_unroll_batch_kern,speed_unroll_patch_noshape,speed_unroll_patch_shape
#have bean calculated on maggie36 when their is only 1 session logged on and only this was running.
#have bean calculated on maggie36 when their is only 1 session logged on and only this was running.
...
@@ -232,7 +234,8 @@ class ConvOp(Op):
...
@@ -232,7 +234,8 @@ class ConvOp(Op):
kshp_logical
=
None
,
kshp_logical
=
None
,
kshp_logical_top_aligned
=
True
,
kshp_logical_top_aligned
=
True
,
verbose
=
0
,
verbose
=
0
,
version
=-
1
):
version
=-
1
,
openmp
=
None
):
"""
"""
Initializes a ConvOp with given output_mode (full/valid). All other
Initializes a ConvOp with given output_mode (full/valid). All other
parameters are optional and are only used to generate more optimized c
parameters are optional and are only used to generate more optimized c
...
@@ -343,6 +346,9 @@ class ConvOp(Op):
...
@@ -343,6 +346,9 @@ class ConvOp(Op):
self
.
dy
=
dy
self
.
dy
=
dy
self
.
verbose
=
verbose
self
.
verbose
=
verbose
self
.
version
=
version
self
.
version
=
version
if
openmp
==
None
:
openmp
=
config
.
openmp
self
.
openmp
=
openmp
# a triple
# a triple
self
.
imshp_logical
=
self
.
imshp
self
.
imshp_logical
=
self
.
imshp
...
@@ -469,6 +475,8 @@ class ConvOp(Op):
...
@@ -469,6 +475,8 @@ class ConvOp(Op):
def
__setstate__
(
self
,
d
):
def
__setstate__
(
self
,
d
):
self
.
__dict__
.
update
(
d
)
self
.
__dict__
.
update
(
d
)
if
not
hasattr
(
self
,
"openmp"
):
self
.
openmp
=
False
self
.
_rehash
()
self
.
_rehash
()
def
_rehash
(
self
):
def
_rehash
(
self
):
...
@@ -843,7 +851,7 @@ class ConvOp(Op):
...
@@ -843,7 +851,7 @@ class ConvOp(Op):
return
[
'<numpy/noprefix.h>'
,
'<iostream>'
,
'<sstream>'
,
'<omp.h>'
]
return
[
'<numpy/noprefix.h>'
,
'<iostream>'
,
'<sstream>'
,
'<omp.h>'
]
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
7
)
return
(
7
,
self
.
openmp
)
def
c_support_code
(
self
):
def
c_support_code
(
self
):
return
"""
return
"""
...
@@ -887,7 +895,8 @@ using namespace std;
...
@@ -887,7 +895,8 @@ using namespace std;
ret
=
blas
.
ldflags
(
libs
=
False
,
flags
=
True
)
ret
=
blas
.
ldflags
(
libs
=
False
,
flags
=
True
)
if
theano
.
gof
.
cmodule
.
gcc_version
()
in
[
'4.3.0'
]
and
self
.
kshp
==
(
1
,
1
):
if
theano
.
gof
.
cmodule
.
gcc_version
()
in
[
'4.3.0'
]
and
self
.
kshp
==
(
1
,
1
):
ret
+=
[
'-O2'
]
ret
+=
[
'-O2'
]
ret
+=
[
'-fopenmp'
]
if
self
.
openmp
:
ret
+=
[
'-fopenmp'
]
return
ret
return
ret
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论