[XLA] Add hash function to HloUse/HloPosition.

PiperOrigin-RevId: 323944629
Change-Id: Ib66d374aea015fad3fbed063ed580034599afb18
This commit is contained in:
A. Unique TensorFlower 2020-07-29 23:15:10 -07:00 committed by TensorFlower Gardener
parent d365a03c9a
commit 9e0cfddcdb

View File

@ -57,6 +57,11 @@ struct HloPosition {
(instruction->unique_id() == other.instruction->unique_id() &&
index < other.index);
}
template <typename H>
friend H AbslHashValue(H h, const HloPosition& pos) {
return H::combine(std::move(h), pos.instruction->Hash(), pos.index);
}
};
std::ostream& operator<<(std::ostream& out, const HloPosition& position);
@ -81,6 +86,12 @@ struct HloUse {
}
bool operator!=(const HloUse& other) const { return !(*this == other); }
template <typename H>
friend H AbslHashValue(H h, const HloUse& use) {
return H::combine(std::move(h), use.instruction, use.operand_index,
use.operand_number);
}
};
std::ostream& operator<<(std::ostream& out, const HloUse& use);
@ -240,7 +251,8 @@ std::ostream& operator<<(std::ostream& out, const HloValueSet& hlo_value);
// hold multiple HloValueSets.
class InstructionValueSet : public ShapeTree<HloValueSet> {
public:
InstructionValueSet(const Shape& shape) : ShapeTree<HloValueSet>(shape) {}
explicit InstructionValueSet(const Shape& shape)
: ShapeTree<HloValueSet>(shape) {}
// Sets this value set to the union of the given value sets. Returns whether
// this value set changed.