Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lang] Add deprecation warning for the removal of the packed switch #6753

Merged
merged 2 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions python/taichi/lang/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,17 @@ def init(arch=None,
if require_version is not None:
check_require_version(require_version)

if "packed" in kwargs:
if kwargs["packed"] is True:
warnings.warn(
"Currently packed=True is the default setting and the switch will be removed in v1.4.0.",
DeprecationWarning)
else:
warnings.warn(
"The automatic padding mode (packed=False) will no longer exist in v1.4.0. The switch will "
"also be removed then. Make sure your code doesn't rely on it.",
DeprecationWarning)

if "default_up" in kwargs:
raise KeyError(
"'default_up' is always the unsigned type of 'default_ip'. Please set 'default_ip' instead."
Expand Down
8 changes: 3 additions & 5 deletions taichi/ir/snode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ SNode &SNode::create_node(std::vector<Axis> axes,
} else {
TI_WARN_IF(
packed && !bit::is_power_of_two(sizes[i]),
"Non-first division of an axis on a SNodeTree path should be a power "
"of two to achieve best performance:\n{} We plan to turn this "
"warning into an error at v1.4.0. If you do have a use case that "
"needs to violate this rule, please submit an issue to notify us.",
tb);
"Shape {} is detected on non-first division of axis {}:\n{} For "
"best performance, we recommend that you set it to a power of two.",
sizes[i], char('i' + ind), tb);
}
new_node.extractors[ind].activate(
bit::log2int(bit::least_pot_bound(sizes[i])));
Expand Down
18 changes: 18 additions & 0 deletions tests/python/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,21 @@ def test_deprecate_metal_sparse():
"Dynamic SNode on metal backend is deprecated and removed in this release."
):
ti.root.dynamic(ti.i, 10)


def test_deprecated_packed_true():
with pytest.warns(
DeprecationWarning,
match=
"Currently packed=True is the default setting and the switch will be removed in v1.4.0."
):
ti.init(packed=True)


def test_deprecated_packed_false():
with pytest.warns(
DeprecationWarning,
match=
r"The automatic padding mode \(packed=False\) will no longer exist in v1.4.0. The switch will "
"also be removed then. Make sure your code doesn't rely on it."):
ti.init(packed=False)