Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions bayesflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ def setup():
torch.autograd.set_grad_enabled(False)

logging.warning(
"\n"
"When using torch backend, we need to disable autograd by default to avoid excessive memory usage. Use\n"
"\n"
"with torch.enable_grad():\n"
" ...\n"
"\n"
"in contexts where you need gradients (e.g. custom training loops)."
)

Expand Down
4 changes: 3 additions & 1 deletion bayesflow/utils/tensor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ def searchsorted(sorted_sequence: Tensor, values: Tensor, side: str = "left") ->

out_int32 = len(sorted_sequence) <= np.iinfo(np.int32).max

indices = torch.searchsorted(sorted_sequence, values, side=side, out_int32=out_int32)
indices = torch.searchsorted(
sorted_sequence.contiguous(), values.contiguous(), side=side, out_int32=out_int32
)

return indices
case _:
Expand Down
Loading