File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1330,6 +1330,23 @@ inline void VlogMaxIsa(absl::string_view max_cpu_isa) {
13301330 }
13311331}
13321332
1333+ // We keep HloProto in the CpuExecutable, but we don't need to keep literals
1334+ // payload in it as we use it only for debugging and memory analysis.
1335+ static void StripPayloadFromLiteralProto (HloProto& proto) {
1336+ auto * module = proto.mutable_hlo_module ();
1337+ for (auto & computation : *module ->mutable_computations ()) {
1338+ for (auto & instruction : *computation.mutable_instructions ()) {
1339+ // We only keep literal shape to correctly estimate memory usage of the
1340+ // HLO module, but we don't need the actual literal data.
1341+ if (instruction.has_literal ()) {
1342+ LiteralProto literal;
1343+ *literal.mutable_shape () = instruction.literal ().shape ();
1344+ *instruction.mutable_literal () = std::move (literal);
1345+ }
1346+ }
1347+ }
1348+ }
1349+
13331350absl::StatusOr<std::unique_ptr<CpuExecutable>>
13341351CpuCompiler::CompileLegacyCpuExecutable (std::unique_ptr<HloModule> module ) {
13351352 TraceMe trace ([&] {
@@ -1452,6 +1469,7 @@ CpuCompiler::CompileLegacyCpuExecutable(std::unique_ptr<HloModule> module) {
14521469 *hlo_proto->mutable_hlo_module () = cpu_executable->module ().ToProto ();
14531470 *hlo_proto->mutable_buffer_assignment () =
14541471 cpu_executable->buffer_assignment ().ToProto ();
1472+ StripPayloadFromLiteralProto (*hlo_proto);
14551473 cpu_executable->set_hlo_proto (std::move (hlo_proto));
14561474 return cpu_executable;
14571475 };
You can’t perform that action at this time.
0 commit comments