1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15
16 #include "tensorflow/compiler/xla/service/logical_buffer.h"
17
18 #include "absl/strings/str_cat.h"
19 #include "absl/strings/str_join.h"
20 #include "tensorflow/compiler/xla/service/hlo_computation.h"
21 #include "tensorflow/compiler/xla/service/hlo_instruction.h"
22 #include "tensorflow/compiler/xla/types.h"
23
24 namespace xla {
25
LogicalBuffer(HloInstruction * instruction,const ShapeIndex & index,Id id)26 LogicalBuffer::LogicalBuffer(HloInstruction* instruction,
27 const ShapeIndex& index, Id id)
28 : BufferValue(instruction, index, id),
29 instruction_(instruction),
30 index_(index) {}
31
~LogicalBuffer()32 LogicalBuffer::~LogicalBuffer() {}
33
ToString() const34 string LogicalBuffer::ToString() const {
35 string color_string;
36 if (has_color()) {
37 color_string = absl::StrCat(" @", color().value());
38 }
39 return absl::StrCat(instruction_->name(), "[", absl::StrJoin(index_, ","),
40 "](#", id(), color_string, ")");
41 }
42
43 } // namespace xla
44