Skip to content
Open
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
6 changes: 4 additions & 2 deletions torchdiffeq/_impl/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def _assert_one_dimensional(name, t):


def _assert_increasing(name, t):
assert (t[1:] > t[:-1]).all(), '{} must be strictly increasing or decreasing'.format(name)
cond = (t[1:] > t[:-1]).all().item()
torch._check(cond, f"{name} must be strictly increasing or decreasing")


def _assert_floating(name, t):
Expand Down Expand Up @@ -380,7 +381,8 @@ def _check_timelike(name, timelike, can_grad):
if not can_grad:
assert not timelike.requires_grad, "{} cannot require gradient".format(name)
diff = timelike[1:] > timelike[:-1]
assert diff.all() or (~diff).all(), '{} must be strictly increasing or decreasing'.format(name)
cond = torch.logical_or(diff.all(), (~diff).all()).item()
torch._check(cond, f"{name} must be strictly increasing or decreasing")


def _flip_option(options, option_name):
Expand Down
3 changes: 2 additions & 1 deletion torchdiffeq/_impl/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def _step_func(self, func, t0, dt, t1, y0):

def integrate(self, t):
time_grid = self.grid_constructor(self.func, self.y0, t)
assert time_grid[0] == t[0] and time_grid[-1] == t[-1]
torch._check((time_grid[0] == t[0]).item())
torch._check((time_grid[-1] == t[-1]).item())

solution = torch.empty(len(t), *self.y0.shape, dtype=self.y0.dtype, device=self.y0.device)
solution[0] = self.y0
Expand Down