Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9df6ce4e
提交
9df6ce4e
authored
7月 01, 2017
作者:
Pascal Lamblin
提交者:
GitHub
7月 01, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6085 from nouiz/deterministic
Add deterministic={default,more} flag
上级
5df0cfd8
c05f0a57
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
53 行增加
和
2 行删除
+53
-2
config.txt
doc/library/config.txt
+16
-0
configdefaults.py
theano/configdefaults.py
+11
-0
opt.py
theano/gpuarray/opt.py
+4
-2
test_subtensor.py
theano/gpuarray/tests/test_subtensor.py
+22
-0
没有找到文件。
doc/library/config.txt
浏览文件 @
9df6ce4e
...
@@ -179,6 +179,19 @@ import theano and print the config variable, as in:
...
@@ -179,6 +179,19 @@ import theano and print the config variable, as in:
When creating a TensorVariable with dtype float64, what should be done?
When creating a TensorVariable with dtype float64, what should be done?
This is useful to help find upcast to float64 in user code.
This is useful to help find upcast to float64 in user code.
.. attribute:: deterministic
String value: either ``'default'``, ``'more'``
Default: ``'default'``
If `more`, sometimes we will select some implementation that
are more deterministic, but slower. In particular, on the GPU,
we will avoid using AtomicAdd. Sometimes we will still use
non-deterministic implementaion, e.g. when we do not have a GPU
implementation that is deterministic. Also see the dnn.conv.algo*
flags to cover more cases.
.. attribute:: allow_gc
.. attribute:: allow_gc
Bool value: either ``True`` or ``False``
Bool value: either ``True`` or ``False``
...
@@ -194,6 +207,9 @@ import theano and print the config variable, as in:
...
@@ -194,6 +207,9 @@ import theano and print the config variable, as in:
significant speed up on functions with many ops that are fast to
significant speed up on functions with many ops that are fast to
execute, but this increases Theano's memory usage.
execute, but this increases Theano's memory usage.
.. note:: if :attr:`config.gpuarray.preallocate` is the default value
or not disabled (-1), this is not useful anymore on the GPU.
.. attribute:: config.scan.allow_output_prealloc
.. attribute:: config.scan.allow_output_prealloc
Bool value, either ``True`` or ``False``
Bool value, either ``True`` or ``False``
...
...
theano/configdefaults.py
浏览文件 @
9df6ce4e
...
@@ -79,6 +79,17 @@ AddConfigVar('int_division',
...
@@ -79,6 +79,17 @@ AddConfigVar('int_division',
EnumStr
(
'int'
,
'raise'
,
'floatX'
),
EnumStr
(
'int'
,
'raise'
,
'floatX'
),
in_c_key
=
False
)
in_c_key
=
False
)
AddConfigVar
(
'deterministic'
,
"If `more`, sometimes we will select some implementation that "
"are more deterministic, but slower. In particular, on the GPU, "
"we will avoid using AtomicAdd. Sometimes we will still use "
"non-deterministic implementaion, e.g. when we do not have a GPU "
"implementation that is deterministic. Also see "
"the dnn.conv.algo* flags to cover more cases."
,
EnumStr
(
'default'
,
'more'
),
in_c_key
=
False
,
)
# gpu means let the driver select the gpu. Needed in case of gpu in
# gpu means let the driver select the gpu. Needed in case of gpu in
# exclusive mode.
# exclusive mode.
# gpuX mean use the gpu number X.
# gpuX mean use the gpu number X.
...
...
theano/gpuarray/opt.py
浏览文件 @
9df6ce4e
...
@@ -1077,14 +1077,16 @@ def local_gpua_advanced_incsubtensor(op, context_name, inputs, outputs):
...
@@ -1077,14 +1077,16 @@ def local_gpua_advanced_incsubtensor(op, context_name, inputs, outputs):
set_instead_of_inc
=
op
.
set_instead_of_inc
set_instead_of_inc
=
op
.
set_instead_of_inc
compute_capability
=
int
(
context
.
bin_id
[
-
2
])
compute_capability
=
int
(
context
.
bin_id
[
-
2
])
if
compute_capability
>=
2
and
x
.
ndim
==
1
and
y
.
ndim
==
0
:
if
(
compute_capability
>=
2
and
x
.
ndim
==
1
and
y
.
ndim
==
0
and
config
.
deterministic
==
'default'
):
x
=
x
.
dimshuffle
(
0
,
'x'
)
x
=
x
.
dimshuffle
(
0
,
'x'
)
y
=
y
.
dimshuffle
(
'x'
,
'x'
)
y
=
y
.
dimshuffle
(
'x'
,
'x'
)
ret
=
GpuAdvancedIncSubtensor1_dev20
(
ret
=
GpuAdvancedIncSubtensor1_dev20
(
set_instead_of_inc
=
set_instead_of_inc
)(
x
,
y
,
ilist
)
set_instead_of_inc
=
set_instead_of_inc
)(
x
,
y
,
ilist
)
ret
=
GpuDimShuffle
(
ret
.
type
.
broadcastable
,
[
0
])(
ret
)
ret
=
GpuDimShuffle
(
ret
.
type
.
broadcastable
,
[
0
])(
ret
)
return
ret
return
ret
elif
compute_capability
<
2
or
x
.
ndim
!=
2
or
y
.
ndim
!=
2
:
elif
(
compute_capability
<
2
or
x
.
ndim
!=
2
or
y
.
ndim
!=
2
or
config
.
deterministic
==
'more'
):
return
GpuAdvancedIncSubtensor1
(
return
GpuAdvancedIncSubtensor1
(
set_instead_of_inc
=
set_instead_of_inc
)
set_instead_of_inc
=
set_instead_of_inc
)
else
:
else
:
...
...
theano/gpuarray/tests/test_subtensor.py
浏览文件 @
9df6ce4e
...
@@ -121,6 +121,28 @@ def test_advinc_subtensor1_dtype():
...
@@ -121,6 +121,28 @@ def test_advinc_subtensor1_dtype():
assert
np
.
allclose
(
rval
,
rep
)
assert
np
.
allclose
(
rval
,
rep
)
@theano.configparser.change_flags
(
deterministic
=
'more'
)
def
test_deterministic_flag
():
shp
=
(
3
,
4
)
for
dtype1
,
dtype2
in
[(
'float32'
,
'int8'
)]:
shared
=
gpuarray_shared_constructor
xval
=
np
.
arange
(
np
.
prod
(
shp
),
dtype
=
dtype1
)
.
reshape
(
shp
)
+
1
yval
=
np
.
empty
((
2
,)
+
shp
[
1
:],
dtype
=
dtype2
)
yval
[:]
=
10
x
=
shared
(
xval
,
name
=
'x'
)
y
=
tensor
.
tensor
(
dtype
=
yval
.
dtype
,
broadcastable
=
(
False
,)
*
len
(
yval
.
shape
),
name
=
'y'
)
expr
=
tensor
.
advanced_inc_subtensor1
(
x
,
y
,
[
0
,
2
])
f
=
theano
.
function
([
y
],
expr
,
mode
=
mode_with_gpu
)
assert
sum
([
isinstance
(
node
.
op
,
GpuAdvancedIncSubtensor1
)
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
==
1
rval
=
f
(
yval
)
rep
=
xval
.
copy
()
rep
[[
0
,
2
]]
+=
yval
assert
np
.
allclose
(
rval
,
rep
)
def
test_advinc_subtensor1_vector_scalar
():
def
test_advinc_subtensor1_vector_scalar
():
# Test the case where x is a vector and y a scalar
# Test the case where x is a vector and y a scalar
shp
=
(
3
,)
shp
=
(
3
,)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论