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

Switched from parameter in can_cast to from_. #126030

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions aten/src/ATen/native/TypeProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ ScalarType result_type(const Scalar& scalar1, const Scalar& scalar2) {
return result_type(state);
}

bool can_cast(const at::ScalarType from, const at::ScalarType to) {
return at::canCast(from, to);
bool can_cast(const at::ScalarType from_, const at::ScalarType to) {
return at::canCast(from_, to);
}

ScalarType promote_types(ScalarType type1, ScalarType type2) {
Expand Down
2 changes: 1 addition & 1 deletion aten/src/ATen/native/native_functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7714,7 +7714,7 @@

- func: result_type.Scalar_Scalar(Scalar scalar1, Scalar scalar2) -> ScalarType

- func: can_cast(ScalarType from, ScalarType to) -> bool
- func: can_cast(ScalarType from_, ScalarType to) -> bool
variants: function

- func: promote_types(ScalarType type1, ScalarType type2) -> ScalarType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
("onednn::qconv2d_pointwise", datetime.date(2024, 12, 31)),
("onednn::qconv3d_pointwise", datetime.date(2024, 12, 31)),
("onednn::qconv2d_pointwise.binary", datetime.date(2024, 12, 31)),
# BC-breaking change in can_cast signature: 'from' -> 'from_'
("aten::can_cast", datetime.date(2024, 5, 31)),
]

ALLOW_LIST_COMPILED = [
Expand Down
4 changes: 2 additions & 2 deletions torch/_torch_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2195,13 +2195,13 @@ def merge_dicts(*dicts):
add_docstr(
torch.can_cast,
r"""
can_cast(from, to) -> bool
can_cast(from_, to) -> bool

Determines if a type conversion is allowed under PyTorch casting rules
described in the type promotion :ref:`documentation <type-promotion-doc>`.

Args:
from (dtype): The original :class:`torch.dtype`.
from\_ (dtype): The original :class:`torch.dtype`.
to (dtype): The target :class:`torch.dtype`.

Example::
Expand Down