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

[TIR] Moved PrimExpr operator overload from op.h to expr.h #11973

Merged
merged 4 commits into from
Jul 18, 2022

Commits on Jul 6, 2022

  1. [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>`.
    Lunderberg committed Jul 6, 2022
    Configuration menu
    Copy the full SHA
    6230030 View commit details
    Browse the repository at this point in the history
  2. Explicitly convert TVMRetValue to bool in target.cc

    Needed to avoid ambiguity between `TVMRetValue -> bool` conversion and
    `TVMRetValue -> int -> PrimExpr` conversion.
    Lunderberg committed Jul 6, 2022
    Configuration menu
    Copy the full SHA
    3271b64 View commit details
    Browse the repository at this point in the history
  3. 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<`.
    Lunderberg committed Jul 6, 2022
    Configuration menu
    Copy the full SHA
    4eca8e0 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    365b5b0 View commit details
    Browse the repository at this point in the history