aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-05-19 16:27:52 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-05-19 16:31:21 -0700
commitad9358f3174871585048e1005affe2559d5613ac (patch)
tree1e2d19cc87075011c2c06293b10dfd34c5b637e0
parent8fd3e9fda7aa9f09cec9229bb3278e49a1416736 (diff)
[XLA] Simplify BufferAlias class by removing unused member.
Points-to analyis stores buffera aliases in a map: buffer->(buffer,instruction,index) Storing buffer in each BufferAlias again is redundant, and it was actually unused. PiperOrigin-RevId: 156610923
-rw-r--r--tensorflow/compiler/xla/service/tuple_points_to_analysis.cc9
-rw-r--r--tensorflow/compiler/xla/service/tuple_points_to_analysis.h12
-rw-r--r--tensorflow/compiler/xla/service/tuple_points_to_analysis_test.cc2
3 files changed, 8 insertions, 15 deletions
diff --git a/tensorflow/compiler/xla/service/tuple_points_to_analysis.cc b/tensorflow/compiler/xla/service/tuple_points_to_analysis.cc
index 554adaf0e3..fe6eadd4db 100644
--- a/tensorflow/compiler/xla/service/tuple_points_to_analysis.cc
+++ b/tensorflow/compiler/xla/service/tuple_points_to_analysis.cc
@@ -33,10 +33,9 @@ limitations under the License.
namespace xla {
string BufferAlias::ToString() const {
- return tensorflow::strings::StrCat("BufferAlias(",
- instruction_->FullyQualifiedName(), "[",
- tensorflow::str_util::Join(index_, ","),
- "] => ", buffer_->ToString(), ")");
+ return tensorflow::strings::StrCat(
+ "BufferAlias(", instruction_->FullyQualifiedName(), "[",
+ tensorflow::str_util::Join(index_, ","), "])");
}
std::ostream& operator<<(std::ostream& out, const BufferAlias& buffer_alias) {
@@ -174,7 +173,7 @@ Status TuplePointsToAnalysis::PopulateDefinedBuffersAndAliases(
if (buffer_aliases_.count(buffer) == 0) {
buffer_aliases_.insert({buffer, std::vector<BufferAlias>()});
}
- buffer_aliases_[buffer].emplace_back(*buffer, instruction.get(), index);
+ buffer_aliases_[buffer].emplace_back(instruction.get(), index);
}
return Status::OK();
}));
diff --git a/tensorflow/compiler/xla/service/tuple_points_to_analysis.h b/tensorflow/compiler/xla/service/tuple_points_to_analysis.h
index 85a71b56ce..3593cd993d 100644
--- a/tensorflow/compiler/xla/service/tuple_points_to_analysis.h
+++ b/tensorflow/compiler/xla/service/tuple_points_to_analysis.h
@@ -117,27 +117,21 @@ class PointsToSet : public ShapeTree<std::vector<const LogicalBuffer*>> {
// value.
class BufferAlias {
public:
- BufferAlias(const LogicalBuffer& buffer, HloInstruction* instruction,
- const ShapeIndex& index)
- : buffer_(&buffer), instruction_(instruction), index_(index) {}
-
- // Return the logical buffer aliased at the instruction and index.
- const LogicalBuffer& buffer() const { return *buffer_; }
+ BufferAlias(HloInstruction* instruction, const ShapeIndex& index)
+ : instruction_(instruction), index_(index) {}
// Return the instruction/index of the subshape.
HloInstruction* instruction() const { return instruction_; }
const ShapeIndex& index() const { return index_; }
bool operator==(const BufferAlias& other) const {
- return buffer_ == other.buffer_ && instruction_ == other.instruction_ &&
- index_ == other.index_;
+ return instruction_ == other.instruction_ && index_ == other.index_;
}
bool operator!=(const BufferAlias& other) const { return !(*this == other); }
string ToString() const;
private:
- const LogicalBuffer* buffer_;
HloInstruction* instruction_;
const ShapeIndex index_;
};
diff --git a/tensorflow/compiler/xla/service/tuple_points_to_analysis_test.cc b/tensorflow/compiler/xla/service/tuple_points_to_analysis_test.cc
index 87e1b058b7..2a761d70e5 100644
--- a/tensorflow/compiler/xla/service/tuple_points_to_analysis_test.cc
+++ b/tensorflow/compiler/xla/service/tuple_points_to_analysis_test.cc
@@ -111,7 +111,7 @@ class TuplePointsToAnalysisTest : public HloTestBase {
.ValueOrDie();
std::vector<BufferAlias> expected_aliases;
for (auto& pair : expected) {
- expected_aliases.push_back(BufferAlias(*buffer, pair.first, pair.second));
+ expected_aliases.push_back(BufferAlias(pair.first, pair.second));
}
EXPECT_THAT(points_to_analysis_->GetBufferAliases(*buffer),
UnorderedElementsAreArray(expected_aliases));