Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion paddle/pir/core/operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class IR_API alignas(8) Operation final
const uint32_t num_operands_ = 0;
const uint32_t num_regions_ = 0;
const uint32_t num_successors_ = 0;
const uint64_t id_ = 0;
const uint64_t id_;

detail::BlockOperandImpl *block_operands_{nullptr};
Region *regions_{nullptr};
Expand Down
5 changes: 3 additions & 2 deletions paddle/pir/core/value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@

namespace pir {
bool Value::operator==(const Value &other) const {
return impl_ == other.impl_;
return impl_ == other.impl_ &&
(impl_ == nullptr || impl_->id() == other.impl_->id());
}

bool Value::operator!=(const Value &other) const {
return impl_ != other.impl_;
return !(operator==(other));
}

bool Value::operator!() const { return impl_ == nullptr; }
Expand Down
8 changes: 7 additions & 1 deletion paddle/pir/core/value_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
// limitations under the License.
#include "paddle/pir/core/value_impl.h"

namespace {
uint64_t GenerateId() {
static std::atomic<std::uint64_t> uid{0};
return ++uid;
}
} // namespace
namespace pir {

namespace detail {
Expand Down Expand Up @@ -40,7 +46,7 @@ std::string ValueImpl::PrintUdChain() {
result << "nullptr";
return result.str();
}
ValueImpl::ValueImpl(Type type, uint32_t kind) {
ValueImpl::ValueImpl(Type type, uint32_t kind) : id_(GenerateId()) {
if (kind > BLOCK_ARG_IDX) {
LOG(FATAL) << "The kind of value_impl(" << kind
<< "), is bigger than BLOCK_ARG_IDX(7)";
Expand Down
4 changes: 4 additions & 0 deletions paddle/pir/core/value_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class alignas(8) ValueImpl {
return T::classof(*this);
}

uint64_t id() const { return id_; }

protected:
///
/// \brief Only can be constructed by derived classes such as OpResultImpl.
Expand All @@ -92,6 +94,8 @@ class alignas(8) ValueImpl {
/// outline output(OpOutlineResultImpl); (3) index = 7 is reserved.
///
OpOperandImpl *first_use_offseted_by_kind_ = nullptr;

const uint64_t id_ = 0;
};

} // namespace detail
Expand Down