Skip to content

Commit 8f5945f

Browse files
hawkinsptensorflower-gardener
authored andcommitted
Remove proto serialization and deserialization from HloModuleGroup.
Inline these into their only user. PiperOrigin-RevId: 855971432
1 parent 6ab7c15 commit 8f5945f

File tree

6 files changed

+6
-66
lines changed

6 files changed

+6
-66
lines changed

third_party/xla/xla/hlo/ir/BUILD

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,9 @@ cc_library(
329329
hdrs = ["hlo_module_group.h"],
330330
deps = [
331331
":hlo",
332-
"//xla:status_macros",
333332
"//xla/service:hlo_module_config",
334333
"//xla/service:hlo_proto_cc",
335-
"//xla/tsl/platform:statusor",
336334
"@com_google_absl//absl/log:check",
337-
"@com_google_absl//absl/status",
338335
"@com_google_absl//absl/status:statusor",
339336
"@com_google_absl//absl/strings",
340337
"@com_google_absl//absl/types:span",

third_party/xla/xla/hlo/ir/hlo_module_group.cc

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,7 @@ limitations under the License.
2323
#include <vector>
2424

2525
#include "absl/log/check.h"
26-
#include "absl/status/status.h"
27-
#include "absl/status/statusor.h"
28-
#include "absl/strings/str_cat.h"
29-
#include "absl/types/span.h"
3026
#include "xla/hlo/ir/hlo_module.h"
31-
#include "xla/service/hlo.pb.h"
32-
#include "xla/service/hlo_module_config.h"
33-
#include "xla/status_macros.h"
34-
#include "xla/tsl/platform/statusor.h"
3527

3628
namespace xla {
3729

@@ -55,38 +47,6 @@ std::string HloModuleGroup::ToString() const {
5547
return s.str();
5648
}
5749

58-
HloModuleGroupProto HloModuleGroup::ToProto() const {
59-
HloModuleGroupProto proto;
60-
proto.set_name(name());
61-
if (module_) {
62-
*proto.add_hlo_modules() = module_->ToProto();
63-
}
64-
return proto;
65-
}
66-
67-
/* static */ absl::StatusOr<HloModuleGroup> HloModuleGroup::CreateFromProto(
68-
const HloModuleGroupProto& proto,
69-
absl::Span<const HloModuleConfig> module_configs) {
70-
TF_RET_CHECK(!proto.name().empty()) << "Module group name cannot be empty";
71-
TF_RET_CHECK(proto.hlo_modules_size() > 0)
72-
<< "Module group must have at least one HLO module";
73-
TF_RET_CHECK(proto.hlo_modules_size() == module_configs.size());
74-
75-
std::vector<std::unique_ptr<HloModule>> modules;
76-
if (proto.hlo_modules_size() != 1) {
77-
return absl::InvalidArgumentError(
78-
absl::StrCat("HloModuleGroupProto should have exactly one module, "
79-
"but it has ",
80-
proto.hlo_modules_size()));
81-
}
82-
const HloModuleProto& module_proto = proto.hlo_modules(0);
83-
TF_ASSIGN_OR_RETURN(
84-
std::unique_ptr<HloModule> module,
85-
HloModule::CreateFromProto(module_proto, module_configs[0]));
86-
87-
return HloModuleGroup(std::move(module));
88-
}
89-
9050
void HloModuleGroup::AddModule(std::unique_ptr<HloModule> module) {
9151
CHECK_EQ(module_, nullptr);
9252
module_ = std::move(module);

third_party/xla/xla/hlo/ir/hlo_module_group.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ class HloModuleGroup {
8080
return H::combine(std::move(h), group.module_);
8181
}
8282

83-
// Serialize the module group to/from a proto.
84-
HloModuleGroupProto ToProto() const;
85-
static absl::StatusOr<HloModuleGroup> CreateFromProto(
86-
const HloModuleGroupProto& proto,
87-
absl::Span<const HloModuleConfig> module_configs);
8883

8984
// Returns the number of modules in the module group.
9085
int size() const { return module_ ? 1 : 0; }

third_party/xla/xla/service/hlo_module_group_test.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ ENTRY %entry (x: f32[], y: f32[]) -> f32[] {
5858
group.module(0).entry_computation()->instructions(),
5959
::testing::ElementsAre(op::Parameter(), op::Parameter(), op::Add()));
6060

61-
TF_ASSERT_OK_AND_ASSIGN(HloModuleGroup group_copy,
62-
HloModuleGroup::CreateFromProto(
63-
group.ToProto(), {group.module(0).config()}));
64-
EXPECT_EQ(group_copy.modules().size(), 1);
65-
EXPECT_THAT(
66-
group_copy.module(0).entry_computation()->instructions(),
67-
::testing::ElementsAre(op::Parameter(), op::Parameter(), op::Add()));
6861

6962
std::vector<std::unique_ptr<HloModule>> modules = group.ConsumeModules();
7063
EXPECT_EQ(modules.size(), 1);

third_party/xla/xla/stream_executor/tpu/BUILD

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,13 +565,10 @@ cc_library(
565565
":status_helper",
566566
":tpu_executable",
567567
":tpu_executor_api",
568-
":tpu_executor_c_api_hdrs",
569568
":tpu_executor_hdrs",
570569
":tpu_platform_id",
571570
"//xla:shape_util",
572-
"//xla:util",
573571
"//xla/hlo/ir:hlo",
574-
"//xla/hlo/ir:hlo_module_group",
575572
"//xla/service:compiler",
576573
"//xla/service:executable",
577574
"//xla/service:hlo_cost_analysis",

third_party/xla/xla/stream_executor/tpu/tpu_on_demand_compiler.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ limitations under the License.
2121
#include "absl/cleanup/cleanup.h"
2222
#include "absl/status/statusor.h"
2323
#include "xla/hlo/ir/hlo_module.h"
24-
#include "xla/hlo/ir/hlo_module_group.h"
2524
#include "xla/service/compiler.h"
2625
#include "xla/service/executable.h"
2726
#include "xla/service/hlo.pb.h"
@@ -35,9 +34,7 @@ limitations under the License.
3534
#include "xla/stream_executor/tpu/tpu_executable.h"
3635
#include "xla/stream_executor/tpu/tpu_executor.h"
3736
#include "xla/stream_executor/tpu/tpu_executor_api.h"
38-
#include "xla/stream_executor/tpu/tpu_executor_c_api.h"
3937
#include "xla/stream_executor/tpu/tpu_platform_id.h"
40-
#include "xla/util.h"
4138
#include "tsl/platform/statusor.h"
4239

4340
namespace xla {
@@ -116,13 +113,14 @@ class TpuCompiler : public Compiler {
116113
std::unique_ptr<HloModule> hlo_module,
117114
std::vector<stream_executor::StreamExecutor*> stream_exec,
118115
const CompileOptions& options) override {
119-
HloModuleGroup module_group(std::move(hlo_module));
116+
HloModuleGroupProto proto;
117+
proto.set_name(hlo_module->name());
118+
*proto.add_hlo_modules() = hlo_module->ToProto();
119+
120120
XLA_HloModuleGroup se_module_group;
121-
se_module_group.proto =
122-
stream_executor::tpu::SerializeProto(module_group.ToProto());
121+
se_module_group.proto = stream_executor::tpu::SerializeProto(proto);
123122
se_module_group.module_config = new XLA_HloModuleConfig[1];
124-
se_module_group.module_config[0] =
125-
ApiConverter::ToC(module_group.module(0).config());
123+
se_module_group.module_config[0] = ApiConverter::ToC(hlo_module->config());
126124

127125
auto cleanup_config = absl::MakeCleanup([&se_module_group]() {
128126
ApiConverter::Destroy(&se_module_group.module_config[0]);

0 commit comments

Comments
 (0)