提交 cbb4af7b authored 作者: Ricardo's avatar Ricardo 提交者: Thomas Wiecki

Remove `warn__inc_set_subtensor1` flag

上级 e9a0e775
...@@ -1454,18 +1454,6 @@ def add_deprecated_configvars(): ...@@ -1454,18 +1454,6 @@ def add_deprecated_configvars():
in_c_key=False, in_c_key=False,
) )
config.add(
"warn__inc_set_subtensor1",
(
"Warn if previous versions of Aesara (before 0.7) could have "
"given incorrect results for inc_subtensor and set_subtensor "
"when using some patterns of advanced indexing (indexing with "
"one vector or matrix of ints)."
),
BoolParam(_warn_default("0.7")),
in_c_key=False,
)
config.add( config.add(
"warn__round", "warn__round",
"Warn when using `tensor.round` with the default mode. " "Warn when using `tensor.round` with the default mode. "
......
import logging import logging
import sys import sys
import warnings
from itertools import chain, groupby from itertools import chain, groupby
from textwrap import dedent from textwrap import dedent
from typing import Iterable, List, Tuple, Union from typing import Iterable, List, Tuple, Union
...@@ -1337,22 +1336,6 @@ def inc_subtensor( ...@@ -1337,22 +1336,6 @@ def inc_subtensor(
if v != "x" and (v - dim_offset) >= 0: if v != "x" and (v - dim_offset) >= 0:
y_order[v - dim_offset] = i y_order[v - dim_offset] = i
# Warn if this code path would have produced wrong results in the past
if config.warn__inc_set_subtensor1:
# Dimshuffle pattern for y that would be equivalent to past code
prev_y_order = ["x"] * (dim_offset) + list(range(y.ndim))
if y_order != prev_y_order:
warnings.warn(
"Although your current code is fine, please note that "
"earlier versions prior to 0.7 (or this development "
"version) may have yielded an incorrect result in "
"this `inc_subtensor` or `set_subtensor` operation. "
"To remove this warning, you can either set the "
"`warn__inc_set_subtensor1` config option to `False`, "
'or `warn__ignore_bug_before` to at least "0.7".',
stacklevel=2,
)
inner_incsubtensor = inc_subtensor( inner_incsubtensor = inc_subtensor(
inner_x, inner_x,
y.dimshuffle(y_order), y.dimshuffle(y_order),
...@@ -1385,20 +1368,6 @@ def inc_subtensor( ...@@ -1385,20 +1368,6 @@ def inc_subtensor(
else: else:
flattened_y = y flattened_y = y
# Warn if this code path would have produced wrong results in the past
if config.warn__inc_set_subtensor1:
if inner_x.ndim > 1 and sum(y.broadcastable) > 0:
warnings.warn(
"Although your current code is fine, please note that "
"earlier versions prior to 0.7 (or this development "
"version) may have yielded an incorrect result in "
"this `inc_subtensor` or `set_subtensor` operation. "
"To remove this warning, you can either set the "
"`warn__inc_set_subtensor1` config option to `False`, "
'or `warn__ignore_bug_before` to at least "0.7".',
stacklevel=2,
)
inner_incsubtensor = inc_subtensor( inner_incsubtensor = inc_subtensor(
inner_x, inner_x,
flattened_y, flattened_y,
......
...@@ -1362,11 +1362,6 @@ class TestSubtensor(utt.OptimizationTestMixin): ...@@ -1362,11 +1362,6 @@ class TestSubtensor(utt.OptimizationTestMixin):
shape_i = ((4,), (4, 2)) shape_i = ((4,), (4, 2))
shape_val = ((3, 1), (3, 1, 1)) shape_val = ((3, 1), (3, 1, 1))
# Disable the warning emitted for that case
orig_warn = config.warn__inc_set_subtensor1
try:
config.warn__inc_set_subtensor1 = False
for i, shp_i, shp_v in zip(sym_i, shape_i, shape_val): for i, shp_i, shp_v in zip(sym_i, shape_i, shape_val):
sub_m = m[:, i] sub_m = m[:, i]
m1 = set_subtensor(sub_m, np.zeros(shp_v)) m1 = set_subtensor(sub_m, np.zeros(shp_v))
...@@ -1385,8 +1380,6 @@ class TestSubtensor(utt.OptimizationTestMixin): ...@@ -1385,8 +1380,6 @@ class TestSubtensor(utt.OptimizationTestMixin):
assert np.allclose(m1_val, m1_ref), (m1_val, m1_ref) assert np.allclose(m1_val, m1_ref), (m1_val, m1_ref)
assert np.allclose(m2_val, m2_ref), (m2_val, m2_ref) assert np.allclose(m2_val, m2_ref), (m2_val, m2_ref)
finally:
config.warn__inc_set_subtensor1 = orig_warn
def test_adv1_inc_sub_notlastdim_1_2dval_no_broadcast(self): def test_adv1_inc_sub_notlastdim_1_2dval_no_broadcast(self):
# Test that taking 1-dimensional advanced indexing # Test that taking 1-dimensional advanced indexing
...@@ -1399,11 +1392,6 @@ class TestSubtensor(utt.OptimizationTestMixin): ...@@ -1399,11 +1392,6 @@ class TestSubtensor(utt.OptimizationTestMixin):
shape_i = ((4,), (4, 2)) shape_i = ((4,), (4, 2))
shape_val = ((3, 4), (3, 4, 2)) shape_val = ((3, 4), (3, 4, 2))
# Disable the warning emitted for that case
orig_warn = config.warn__inc_set_subtensor1
try:
config.warn__inc_set_subtensor1 = False
for i, shp_i, shp_v in zip(sym_i, shape_i, shape_val): for i, shp_i, shp_v in zip(sym_i, shape_i, shape_val):
sub_m = m[:, i] sub_m = m[:, i]
m1 = set_subtensor(sub_m, np.zeros(shp_v)) m1 = set_subtensor(sub_m, np.zeros(shp_v))
...@@ -1425,8 +1413,6 @@ class TestSubtensor(utt.OptimizationTestMixin): ...@@ -1425,8 +1413,6 @@ class TestSubtensor(utt.OptimizationTestMixin):
assert np.allclose(m1_val, m1_ref), (m1_val, m1_ref) assert np.allclose(m1_val, m1_ref), (m1_val, m1_ref)
assert np.allclose(m2_val, m2_ref), (m2_val, m2_ref) assert np.allclose(m2_val, m2_ref), (m2_val, m2_ref)
finally:
config.warn__inc_set_subtensor1 = orig_warn
def test_take_basic(): def test_take_basic():
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论