[XLA] Add hash function to HloUse/HloPosition.

PiperOrigin-RevId: 323944629
Change-Id: Ib66d374aea015fad3fbed063ed580034599afb18
diff --git a/tensorflow/compiler/xla/service/hlo_value.h b/tensorflow/compiler/xla/service/hlo_value.h
index a1150ae..a721aab 100644
--- a/tensorflow/compiler/xla/service/hlo_value.h
+++ b/tensorflow/compiler/xla/service/hlo_value.h
@@ -57,6 +57,11 @@
            (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 @@
   }
 
   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 @@
 // 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.