Skip to content

[TIR] Fix Tensorization IR-Comparator for Annotations#10498

Merged
junrushao merged 1 commit intoapache:mainfrom
MasterJH5574:bugfix/2022-03-05-fix-tensorization-ir-comparator
Mar 5, 2022
Merged

[TIR] Fix Tensorization IR-Comparator for Annotations#10498
junrushao merged 1 commit intoapache:mainfrom
MasterJH5574:bugfix/2022-03-05-fix-tensorization-ir-comparator

Conversation

@MasterJH5574
Copy link
Contributor

This PR fixes the way of comparison in which the tensorization IR-comparator deals with annotations.

Prior to this PR, the comparator requires the annotation values from LHS and RHS to be exactly the same, which is, in fact, never possible. And this PR removes this comparison requirement (with a regression unit test).

bool TensorizeComparator::CompareAnnotation(const std::pair<String, ObjectRef>& lhs,
                                            const std::pair<String, ObjectRef>& rhs) {
  if (lhs.first != rhs.first) return false;
  if (!lhs.second.same_as(rhs.second)) return false;  // <== The values would never be the same.
                                                      //     Thus this line should be removed.
  return VisitExpr(Downcast<PrimExpr>(lhs.second), Downcast<PrimExpr>(rhs.second));
}

cc @spectrometerHBH @vinx13

@junrushao junrushao merged commit ff3a48e into apache:main Mar 5, 2022
@junrushao
Copy link
Member

Thanks! This is merged!

ziqiangxu8457 pushed a commit to ziqiangxu8457/tvm that referenced this pull request Mar 6, 2022
This PR fixes the way of comparison in which the tensorization IR-comparator deals with annotations.

Prior to this PR, the comparator requires the annotation values from LHS and RHS to be exactly the same, which is, in fact, never possible. And this PR removes this comparison requirement (with a regression unit test).

```c++
bool TensorizeComparator::CompareAnnotation(const std::pair<String, ObjectRef>& lhs,
                                            const std::pair<String, ObjectRef>& rhs) {
  if (lhs.first != rhs.first) return false;
  if (!lhs.second.same_as(rhs.second)) return false;  // <== The values would never be the same.
                                                      //     Thus this line should be removed.
  return VisitExpr(Downcast<PrimExpr>(lhs.second), Downcast<PrimExpr>(rhs.second));
}
```
pfk-beta pushed a commit to pfk-beta/tvm that referenced this pull request Apr 11, 2022
This PR fixes the way of comparison in which the tensorization IR-comparator deals with annotations.

Prior to this PR, the comparator requires the annotation values from LHS and RHS to be exactly the same, which is, in fact, never possible. And this PR removes this comparison requirement (with a regression unit test).

```c++
bool TensorizeComparator::CompareAnnotation(const std::pair<String, ObjectRef>& lhs,
                                            const std::pair<String, ObjectRef>& rhs) {
  if (lhs.first != rhs.first) return false;
  if (!lhs.second.same_as(rhs.second)) return false;  // <== The values would never be the same.
                                                      //     Thus this line should be removed.
  return VisitExpr(Downcast<PrimExpr>(lhs.second), Downcast<PrimExpr>(rhs.second));
}
```
MasterJH5574 added a commit to MasterJH5574/tvm that referenced this pull request May 5, 2022
This PR fixes the way of comparison in which the tensorization IR-comparator deals with annotations.

Prior to this PR, the comparator requires the annotation values from LHS and RHS to be exactly the same, which is, in fact, never possible. And this PR removes this comparison requirement (with a regression unit test).

```c++
bool TensorizeComparator::CompareAnnotation(const std::pair<String, ObjectRef>& lhs,
                                            const std::pair<String, ObjectRef>& rhs) {
  if (lhs.first != rhs.first) return false;
  if (!lhs.second.same_as(rhs.second)) return false;  // <== The values would never be the same.
                                                      //     Thus this line should be removed.
  return VisitExpr(Downcast<PrimExpr>(lhs.second), Downcast<PrimExpr>(rhs.second));
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants