Skip to content

Commit 3ef5c3f

Browse files
authored
test: Fix test_tensor_used_multiple_times warning (#403)
* Before this, we had `UserWarning: Converting a tensor with requires_grad=True to a scalar may lead to unexpected behavior`.
1 parent 2bd50a2 commit 3ef5c3f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/unit/autojac/test_backward.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ def test_tensor_used_multiple_times(chunk_size: int | None):
233233

234234
expected_jacobian = tensor_(
235235
[
236-
[2.0 * 3.0 * a**2],
237-
[2.0 * 4.0 * a**3],
236+
[2.0 * 3.0 * (a**2).item()],
237+
[2.0 * 4.0 * (a**3).item()],
238238
],
239239
)
240240

0 commit comments

Comments
 (0)