Skip to content

Commit

Permalink
hlo_runner_pjrt: Have PjRtWrappedExecutable own the underlying execut…
Browse files Browse the repository at this point in the history
…able.

Avoids a memory leak in various unit tests currently masked by not actually
looking for leaks.

PiperOrigin-RevId: 679721068
  • Loading branch information
pizzud authored and Google-ML-Automation committed Sep 27, 2024
1 parent 175328a commit b1bec33
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions xla/service/hlo_runner_pjrt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ class PjRtWrappedExecutable : public Executable {
HloExecutionProfile* hlo_execution_profile) override;

PjRtLoadedExecutable* GetPjRtLoadedExecutable() const {
return pjrt_loaded_executable_;
return pjrt_loaded_executable_.get();
}

private:
PjRtLoadedExecutable* pjrt_loaded_executable_;
std::unique_ptr<PjRtLoadedExecutable> pjrt_loaded_executable_;
};

absl::StatusOr<ExecutionOutput> PjRtWrappedExecutable::ExecuteAsyncOnStream(
Expand Down Expand Up @@ -373,9 +373,7 @@ absl::StatusOr<std::unique_ptr<Executable>> HloRunnerPjRt::CreateExecutable(
std::move(pjrt_executable->GetHloModules().value()[0])),
pjrt_executable.release());

std::unique_ptr<Executable> exec =
static_cast<std::unique_ptr<Executable>>(executable.release());
return exec;
return executable;
}

absl::StatusOr<std::vector<Literal>> HloRunnerPjRt::ExecuteReplicated(
Expand Down

0 comments on commit b1bec33

Please sign in to comment.