Skip to content

Commit

Permalink
Add device parameter to fitter.editor
Browse files Browse the repository at this point in the history
  • Loading branch information
norabelrose committed Jan 10, 2024
1 parent b7896b5 commit 9b18b3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions concept_erasure/quadratic.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,13 @@ def update_single(self, x: Tensor, z: int) -> "QuadraticFitter":

return self

def editor(self) -> QuadraticEditor:
def editor(self, device: str | None = None) -> QuadraticEditor:
"""Quadratic editor for the concept."""
sigma = self.sigma_xx
return QuadraticEditor(self.mean_x, ot_map(sigma[:, None], sigma))
device = device or sigma.device

T = ot_map(sigma[:, None], sigma).to(device)
return QuadraticEditor(self.mean_x.to(device), T)

@cached_property
def eraser(self) -> QuadraticEraser:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license = {text = "MIT License"}
dependencies = [
"torch",
]
version = "0.2.3"
version = "0.2.4"

[project.optional-dependencies]
dev = [
Expand Down

0 comments on commit 9b18b3d

Please sign in to comment.