提交 d8a21984 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Warn if indexing bug would have been triggered.

上级 3e79dbaf
...@@ -282,6 +282,13 @@ AddConfigVar('warn.sum_div_dimshuffle_bug', ...@@ -282,6 +282,13 @@ AddConfigVar('warn.sum_div_dimshuffle_bug',
BoolParam(warn_default('0.3')), BoolParam(warn_default('0.3')),
in_c_key=False) in_c_key=False)
AddConfigVar('warn.subtensor_merge_bug',
"Warn if previous versions of Theano (before 0.5rc2) could have given "
"incorrect results when indexing into a subtensor with negative stride "
"(for instance, for instance, x[a:b:-1][c]).",
BoolParam(warn_default('0.5')),
in_c_key=False)
AddConfigVar('compute_test_value', AddConfigVar('compute_test_value',
"If 'True', Theano will run each op at graph build time, using Constants, SharedVariables and the tag 'test_value' as inputs to the function. This helps the user track down problems in the graph before it gets optimized.", "If 'True', Theano will run each op at graph build time, using Constants, SharedVariables and the tag 'test_value' as inputs to the function. This helps the user track down problems in the graph before it gets optimized.",
EnumStr('off', 'ignore', 'warn', 'raise'), EnumStr('off', 'ignore', 'warn', 'raise'),
......
...@@ -1682,6 +1682,12 @@ def merge_two_slices(slice1, len1, slice2, len2): ...@@ -1682,6 +1682,12 @@ def merge_two_slices(slice1, len1, slice2, len2):
# the k-th element from sl.start but the k-th element from # the k-th element from sl.start but the k-th element from
# sl.stop backwards # sl.stop backwards
n_val = sl1.stop - 1 - sl2 * sl1.step n_val = sl1.stop - 1 - sl2 * sl1.step
if config.warn.subtensor_merge_bug:
_logger.warn((
'Your current code is fine, but Theano versions '
'prior to 0.5rc2 might have given an incorrect result. '
'To disable this warning, set the Theano flag '
'warn.subtensor_merge_bug to False.'))
# we need to pick either n_val or p_val and then follow same # we need to pick either n_val or p_val and then follow same
# steps as above for covering the index error cases # steps as above for covering the index error cases
val = T.switch(T.lt(reverse1, 0), n_val, p_val) val = T.switch(T.lt(reverse1, 0), n_val, p_val)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论