Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Reduce mem footprint of get_latent_representation #84

Merged
merged 3 commits into from
Feb 14, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/scvi_v2/_model.py
100755 → 100644
canergen marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,15 @@ def get_latent_representation(
for array_dict in tqdm(scdl):
outputs = jit_inference_fn(self.module.rngs, array_dict)

us.append(outputs["u"])
zs.append(outputs["z"])
if give_z:
zs.append(jax.device_get(outputs["z"]))
else:
us.append(jax.device_get(outputs["u"]))

u = np.array(jax.device_get(jnp.concatenate(us, axis=0)))
z = np.array(jax.device_get(jnp.concatenate(zs, axis=0)))
return z if give_z else u
if give_z:
return np.array(jnp.concatenate(zs, axis=0))
else:
return np.array(jnp.concatenate(us, axis=0))

def compute_local_statistics(
self,
Expand Down
Loading