aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-10-08 08:22:48 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-10-08 08:27:19 -0700
commit53961cc2f16dea9d9b2286950c1e4d4c0a3743c5 (patch)
tree82697bddfcdd856b41bbbb5067d8c9610ae5b885 /tensorflow/compiler
parent3bdf3c592472c2b54c513417de8d9b538d3f6078 (diff)
Improve const correctness of HloDomainMap
PiperOrigin-RevId: 216189458
Diffstat (limited to 'tensorflow/compiler')
-rw-r--r--tensorflow/compiler/xla/service/hlo_domain_map.cc12
-rw-r--r--tensorflow/compiler/xla/service/hlo_domain_map.h14
2 files changed, 14 insertions, 12 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_domain_map.cc b/tensorflow/compiler/xla/service/hlo_domain_map.cc
index 6ca1255ede..c6d02f9f67 100644
--- a/tensorflow/compiler/xla/service/hlo_domain_map.cc
+++ b/tensorflow/compiler/xla/service/hlo_domain_map.cc
@@ -42,18 +42,19 @@ namespace xla {
return std::move(domain_map);
}
-bool HloDomainMap::InSameDomain(HloInstruction* instruction1,
- HloInstruction* instruction2) const {
+bool HloDomainMap::InSameDomain(const HloInstruction* instruction1,
+ const HloInstruction* instruction2) const {
int64 domain_id1 = GetDomainId(instruction1);
int64 domain_id2 = GetDomainId(instruction2);
return domain_id1 >= 0 && domain_id1 == domain_id2;
}
-int64 HloDomainMap::GetDomainId(HloInstruction* instruction) const {
+int64 HloDomainMap::GetDomainId(const HloInstruction* instruction) const {
return FindOrDefault(instruction_to_domain_, instruction, -1);
}
-int64 HloDomainMap::GetDomainMetadataId(HloInstruction* instruction) const {
+int64 HloDomainMap::GetDomainMetadataId(
+ const HloInstruction* instruction) const {
return FindOrDie(domain_metadata_id_, instruction);
}
@@ -200,7 +201,8 @@ StatusOr<std::unique_ptr<DomainMetadata::Domain>> HloDomainMap::CreateDomain(
return std::move(domain);
}
-bool HloDomainMap::IsDomainInstruction(HloInstruction* instruction) const {
+bool HloDomainMap::IsDomainInstruction(
+ const HloInstruction* instruction) const {
if (instruction->opcode() != HloOpcode::kDomain) {
return false;
}
diff --git a/tensorflow/compiler/xla/service/hlo_domain_map.h b/tensorflow/compiler/xla/service/hlo_domain_map.h
index c8d581b746..bce7d1aa7c 100644
--- a/tensorflow/compiler/xla/service/hlo_domain_map.h
+++ b/tensorflow/compiler/xla/service/hlo_domain_map.h
@@ -58,21 +58,21 @@ class HloDomainMap {
}
// Checks whether two instructions are within the same domain.
- bool InSameDomain(HloInstruction* instruction1,
- HloInstruction* instruction2) const;
+ bool InSameDomain(const HloInstruction* instruction1,
+ const HloInstruction* instruction2) const;
// Checks whether instruction is a kDomain instruction of the kind we are
// currently processing.
- bool IsDomainInstruction(HloInstruction* instruction) const;
+ bool IsDomainInstruction(const HloInstruction* instruction) const;
// Retrieves the domain identifier of the instruction, or -1 in case
// instruction is not found within any domain.
- int64 GetDomainId(HloInstruction* instruction) const;
+ int64 GetDomainId(const HloInstruction* instruction) const;
// Returns the unique id of the domain metadata for the domain the given
// instruction belongs to. The given instruction must not be a kDomain
// instruction since each domain instruction is associated with 2 domains.
- int64 GetDomainMetadataId(HloInstruction* instruction) const;
+ int64 GetDomainMetadataId(const HloInstruction* instruction) const;
private:
// Map used for representing instruction ordering, i.e.
@@ -119,8 +119,8 @@ class HloDomainMap {
string domain_kind_;
std::vector<std::unique_ptr<DomainMetadata::Domain>> instruction_domains_;
- absl::flat_hash_map<HloInstruction*, int64> instruction_to_domain_;
- absl::flat_hash_map<HloInstruction*, int64> domain_metadata_id_;
+ absl::flat_hash_map<const HloInstruction*, int64> instruction_to_domain_;
+ absl::flat_hash_map<const HloInstruction*, int64> domain_metadata_id_;
};
} // namespace xla