Skip to content

Commit 56bc4f8

Browse files
ezhulenevGoogle-ML-Automation
authored andcommitted
[xla:cpu] Migrate tf2xla to BufferAllocationInfo
PiperOrigin-RevId: 820707093
1 parent d6d451e commit 56bc4f8

File tree

8 files changed

+15
-184
lines changed

8 files changed

+15
-184
lines changed

xla/backends/cpu/buffer_allocation_info.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ limitations under the License.
2222
#include "absl/strings/str_format.h"
2323
#include "absl/strings/string_view.h"
2424

25-
namespace xla::cpu {
25+
namespace xla {
26+
namespace cpu {
2627

2728
// `BufferAllocationInfo` stores information about buffer allocations required
2829
// by an XLA:CPU executable at run time. It corresponds to a `BufferAllocation`
@@ -193,6 +194,14 @@ class BufferAllocationInfo {
193194
int32_t result_number_ = -1;
194195
};
195196

196-
} // namespace xla::cpu
197+
} // namespace cpu
198+
199+
// TODO(ezhulenev): This is a temporary hack to keep `tfcompile` code working.
200+
namespace cpu_function_runtime {
201+
using BufferInfo = ::xla::cpu::BufferAllocationInfo;
202+
using EncodedBufferInfo = ::xla::cpu::BufferAllocationInfo::Encoded;
203+
} // namespace cpu_function_runtime
204+
205+
} // namespace xla
197206

198207
#endif // XLA_BACKENDS_CPU_BUFFER_ALLOCATION_INFO_H_

xla/cpu_function_runtime.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ limitations under the License.
2222
#include <cstdlib>
2323

2424
namespace xla {
25-
namespace cpu_function_runtime {
25+
namespace cpu_function_runtime_deprecated {
2626

2727
struct EncodedBufferInfo {
2828
uint64_t packed_kind_and_size = 0;
@@ -174,7 +174,7 @@ class BufferInfo {
174174
int32_t result_param_number_ = -1;
175175
};
176176

177-
} // namespace cpu_function_runtime
177+
} // namespace cpu_function_runtime_deprecated
178178
} // namespace xla
179179

180180
#endif // XLA_CPU_FUNCTION_RUNTIME_H_

xla/service/cpu/BUILD

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,25 +170,12 @@ cc_library(
170170
alwayslink = True, # Contains per-platform transfer manager registration
171171
)
172172

173-
cc_library(
174-
name = "buffer_info_util",
175-
srcs = ["buffer_info_util.cc"],
176-
hdrs = ["buffer_info_util.h"],
177-
deps = [
178-
"//xla:cpu_function_runtime",
179-
"//xla/hlo/ir:hlo",
180-
"//xla/service:buffer_assignment",
181-
"@com_google_absl//absl/types:span",
182-
],
183-
)
184-
185173
cc_library(
186174
name = "cpu_compiler_pure",
187175
srcs = ["cpu_compiler.cc"],
188176
hdrs = ["cpu_compiler.h"],
189177
copts = tsl_copts(),
190178
deps = [
191-
":buffer_info_util",
192179
":conv_canonicalization",
193180
":cpu_aot_compilation_result",
194181
":cpu_aot_loader",
@@ -427,7 +414,6 @@ cc_library(
427414
srcs = ["cpu_aot_compilation_result.cc"],
428415
hdrs = ["cpu_aot_compilation_result.h"],
429416
deps = [
430-
":buffer_info_util",
431417
":cpu_executable",
432418
":executable_proto_cc",
433419
"//xla:cpu_function_runtime",

xla/service/cpu/buffer_info_util.cc

Lines changed: 0 additions & 101 deletions
This file was deleted.

xla/service/cpu/buffer_info_util.h

Lines changed: 0 additions & 48 deletions
This file was deleted.

xla/service/cpu/cpu_aot_compilation_result.cc

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ limitations under the License.
4343
#include "xla/service/buffer_assignment.h"
4444
#include "xla/service/buffer_value.h"
4545
#include "xla/service/compiler.h"
46-
#include "xla/service/cpu/buffer_info_util.h"
4746
#include "xla/service/cpu/cpu_executable.h"
4847
#include "xla/service/cpu/executable.pb.h"
4948
#include "xla/service/executable.h"
@@ -57,7 +56,6 @@ limitations under the License.
5756
#include "xla/util.h"
5857

5958
namespace xla::cpu {
60-
using BufferInfo = cpu_function_runtime::BufferInfo;
6159

6260
CpuAotCompilationOptions::CpuAotCompilationOptions(
6361
std::string triple, std::string cpu_name, std::string features,
@@ -88,14 +86,10 @@ CpuAotCompilationResult::Create(
8886
TF_ASSIGN_OR_RETURN(ThunkSequenceProto thunk_proto,
8987
thunk_sequence_serdes.ToProto(thunks));
9088

91-
std::vector<cpu_function_runtime::BufferInfo> buffer_infos;
9289
std::vector<cpu::BufferAllocationInfo> buffer_allocation_infos;
9390
std::optional<size_t> temp_allocation_index;
9491

9592
if (buffer_assignment) {
96-
buffer_infos =
97-
CreateBufferInfosFromBufferAssignment(*hlo_module, *buffer_assignment);
98-
9993
buffer_allocation_infos =
10094
CreateBufferAllocationInfos(*hlo_module, *buffer_assignment);
10195

@@ -114,21 +108,19 @@ CpuAotCompilationResult::Create(
114108
return absl::WrapUnique(new CpuAotCompilationResult(
115109
hlo_module, buffer_assignment, function_name, std::move(obj_files),
116110
std::move(symbols), thunk_proto, std::move(temp_allocation_index),
117-
std::move(buffer_infos), std::move(buffer_allocation_infos),
118-
std::move(function_library), std::move(hlo_profile_printer_data)));
111+
std::move(buffer_allocation_infos), std::move(function_library),
112+
std::move(hlo_profile_printer_data)));
119113
}
120114

121115
CpuAotCompilationResult::CpuAotCompilationResult(
122116
const HloModule* hlo_module, const BufferAssignment* buffer_assignment,
123117
absl::string_view function_name, std::vector<ObjFileProto> obj_files,
124118
std::vector<SymbolProto> symbols, const ThunkSequenceProto& thunks,
125119
std::optional<size_t> temp_allocation_index,
126-
std::vector<cpu_function_runtime::BufferInfo> buffer_infos,
127120
std::vector<BufferAllocationInfo> buffer_allocation_infos,
128121
std::unique_ptr<FunctionLibrary> function_library,
129122
std::unique_ptr<HloProfilePrinterData> hlo_profile_printer_data)
130123
: temp_allocation_index_(temp_allocation_index),
131-
buffer_infos_(std::move(buffer_infos)),
132124
buffer_allocation_infos_(std::move(buffer_allocation_infos)),
133125
function_library_(std::move(function_library)),
134126
hlo_profile_printer_data_(std::move(hlo_profile_printer_data)) {

xla/service/cpu/cpu_aot_compilation_result.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,6 @@ class CpuAotCompilationResult : public AotCompilationResult {
148148
return temp_allocation_index_;
149149
}
150150

151-
const std::vector<cpu_function_runtime::BufferInfo>& buffer_infos() const {
152-
return buffer_infos_;
153-
}
154-
155151
absl::Span<const BufferAllocationInfo> buffer_allocation_infos() const {
156152
return buffer_allocation_infos_;
157153
}
@@ -188,7 +184,6 @@ class CpuAotCompilationResult : public AotCompilationResult {
188184
absl::string_view function_name, std::vector<ObjFileProto> obj_files,
189185
std::vector<SymbolProto> symbols, const ThunkSequenceProto& thunks,
190186
std::optional<size_t> temp_allocation_index,
191-
std::vector<cpu_function_runtime::BufferInfo> buffer_infos,
192187
std::vector<BufferAllocationInfo> buffer_allocation_infos,
193188
std::unique_ptr<FunctionLibrary> function_library,
194189
std::unique_ptr<HloProfilePrinterData> hlo_profile_printer_data);
@@ -203,7 +198,6 @@ class CpuAotCompilationResult : public AotCompilationResult {
203198
CompilationResultProto proto_;
204199
std::unique_ptr<HloModule> module_;
205200
std::optional<size_t> temp_allocation_index_;
206-
std::vector<cpu_function_runtime::BufferInfo> buffer_infos_;
207201
std::vector<BufferAllocationInfo> buffer_allocation_infos_;
208202

209203
std::unique_ptr<FunctionLibrary> function_library_;

xla/service/cpu/cpu_compiler.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ limitations under the License.
172172
#include "xla/service/conditional_simplifier.h"
173173
#include "xla/service/conditional_to_select.h"
174174
#include "xla/service/copy_insertion.h"
175-
#include "xla/service/cpu/buffer_info_util.h"
176175
#include "xla/service/cpu/conv_canonicalization.h"
177176
#include "xla/service/cpu/cpu_aot_compilation_result.h"
178177
#include "xla/service/cpu/cpu_aot_loader.h"

0 commit comments

Comments
 (0)