@@ -20,21 +20,10 @@ int64_t dimname_to_position(const Tensor& tensor, Dimname dim) {
2020 " Name " , dim, " not found in " , toDimnameRepr (tensor), " ." );
2121 const auto names = tensor.names ();
2222
23- const auto it = std::find_if (
24- names.begin (), names.end (),
25- [&dim](const Dimname& candidate) { return dim.can_refer_to (candidate); });
23+ const auto it = std::find (names.begin (), names.end (), dim);
2624 TORCH_CHECK (it != names.end (),
2725 " Name " , dim, " not found in " , toDimnameRepr (tensor), " ." );
2826
29- // Check that it can't refer to another dimension
30- const auto dup = std::find_if (
31- it + 1 , names.end (),
32- [&dim](const Dimname& candidate) { return dim.can_refer_to (candidate); });
33- TORCH_CHECK (
34- dup == names.end (),
35- " Name " , dim, " could refer to multiple dimensions in " ,
36- toDimnameRepr (tensor), " . Please disambiguate by using a more " ,
37- " specific name like " , *it, " or " , dup, " ." );
3827 return std::distance (names.begin (), it);
3928}
4029
@@ -68,8 +57,7 @@ static void check_for_misalignment(
6857 if (name.is_wildcard ()) {
6958 return ;
7059 }
71- auto it = std::find_if (other_names.begin (), other_names.end (),
72- [&](const Dimname& candidate) { return name.can_refer_to (candidate); });
60+ auto it = std::find (other_names.begin (), other_names.end (), name);
7361 // TODO(zou3519): Can improve message by checking if names are alignable and suggesting workarounds
7462 TORCH_CHECK (it == other_names.end (),
7563 " Misaligned dims when attempting to " , action, " dims " , names, " and dims " ,
@@ -94,11 +82,6 @@ std::vector<Dimname> unify_from_right(
9482 const auto & name = names_it == names.rend () ? wildcard : *names_it;
9583 const auto & other_name = other_it == other_names.rend () ? wildcard : *other_it;
9684
97- // TODO(zou3519): Don't support tagged names for now. They're a little weird.
98- if (name.is_tagged () || other_name.is_tagged ()) {
99- TORCH_INTERNAL_ASSERT (" unify_from_right: NYI: tagged names." );
100- }
101-
10285 // Step 1: Check that the names match
10386 const auto maybeName = unify (name, other_name);
10487 if (!maybeName) {
0 commit comments