Skip to content

Commit a9073f0

Browse files
author
eellison
committed
comment
1 parent 7a2c840 commit a9073f0

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

torch/csrc/jit/ir/alias_analysis.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -860,16 +860,17 @@ void AliasDb::makePointerTo(const Value* from, const Value* to) {
860860
return;
861861
}
862862

863-
// covariant type containers can be point to types which are not
864-
// also mutable/immutable because we unify the contained types
865-
// Any can point to/from immutable types
863+
// the contained types of immutable type containers (optional, tuple, future)
864+
// are unified, so these types can be mutable or immutable
865+
// and point to a type which is mutable or immutable.
866+
// Any is mutable but can point to a immutable type through refinement
866867
if (isMutableTypeInternal(from) != isMutableTypeInternal(to)) {
867-
auto from_kind = from->type()->kind();
868868
bool expected_kind = false;
869869
for (auto kind : {from->type()->kind(), to->type()->kind()}) {
870-
expected_kind = expected_kind || kind == TypeKind::OptionalType ||
871-
kind == TypeKind::FutureType || kind == TypeKind::TupleType ||
872-
kind == TypeKind::AnyType;
870+
expected_kind = expected_kind ||
871+
(kind == TypeKind::OptionalType || kind == TypeKind::FutureType ||
872+
kind == TypeKind::TupleType) // immutable type containers
873+
|| kind == TypeKind::AnyType;
873874
}
874875
TORCH_INTERNAL_ASSERT(
875876
expected_kind, from->type()->str(), to->type()->str());

0 commit comments

Comments
 (0)