You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[TIR] Moved PrimExpr operator overload from op.h to expr.h (#11973)
* [TIR] Moved PrimExpr operator overload from op.h to expr.h
If a compilation unit includes `<tvm/ir/expr.h>`, but does not include
`<tvm/tir/op.h>`, the operator overloads for `ObjectRef` are declared,
but the operator overloads for `PrimExpr` are not. In this case, any
use of `expr_a == expr_b` would use `ObjectRef`'s implementation and
compare reference equality of the two expressions, rather than
returning a `PrimExpr` that represents the comparison. By having the
operator overloads in the `<tvm/ir/expr.h>` header file, directly
adjacent to the `PrimExpr` declaration, the correct overload must be
available whenever the `PrimExpr` can be used.
Even though this would only impact `operator==`, `operator!=`, and
`operator<`, the three operators defined for `ObjectRef`, this PR
moves all operator overloads to `expr.h` for consistency.
The named version of the operators (e.g. `tvm::add`) do not have
overloaded variants, and so they are intentionally kept in
`<tvm/tir/op.h>`.
* Explicitly convert TVMRetValue to bool in target.cc
Needed to avoid ambiguity between `TVMRetValue -> bool` conversion and
`TVMRetValue -> int -> PrimExpr` conversion.
* Used vector/unordered_set to track BufferInfoExtractor::call_order_
Use of `std::set<Call>` had ambiguity between `operator<` by
`PrimExpr` or by `ObjectRef`.
The comment for `call_order_` implied that the previous usage of
`std::set<Call>` was intended to have a de-duplicated list in the
order of occurrence. However, the `std::set` was ordered by
`ObjectRef::operator<`, not by insertion order. Switching to using a
`vector` for ordering and `unordered_set` for de-duplication resolves
this issue, and also removes the use of `operator<`.
* Remove C-style cast to fix lint error
0 commit comments