Skip to content

Commit 55cbaa1

Browse files
SebastianAmentfacebook-github-bot
authored andcommitted
Smaller to syntax in SobolQMCNormalSampler (#1580)
Summary: Pull Request resolved: #1580 `to` only allocates new tensors if they don't satisfy the `dtype` and `device` classes, so there is no a downside to calling `to` outside of the `if` statements. See the [docs here](https://pytorch.org/docs/stable/generated/torch.Tensor.to.html). Reviewed By: Balandat Differential Revision: D42163726 fbshipit-source-id: c69fb78e5d04fcb369bbd5c9c1a6d33f01bb525e
1 parent 8f58784 commit 55cbaa1

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

botorch/sampling/normal.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,4 @@ def _construct_base_samples(self, posterior: Posterior) -> None:
200200
)
201201
base_samples = base_samples.view(target_shape)
202202
self.register_buffer("base_samples", base_samples)
203-
if self.base_samples.device != posterior.device:
204-
self.to(device=posterior.device) # pragma: nocover
205-
if self.base_samples.dtype != posterior.dtype:
206-
self.to(dtype=posterior.dtype)
203+
self.to(device=posterior.device, dtype=posterior.dtype)

0 commit comments

Comments
 (0)