Skip to content

Commit d9efac5

Browse files
authored
fix: Tensor not detached in debug mode (ecmwf#279)
## Description Output tensor was not detached when printing it or writing it to a trace file, side effect of ecmwf#263. ***As a contributor to the Anemoi framework, please ensure that your changes include unit tests, updates to any affected dependencies and documentation, and have been tested in a parallel setting (i.e., with multiple GPUs). As a reviewer, you are also responsible for verifying these aspects and requesting changes if they are not adequately addressed. For guidelines about those please refer to https://anemoi.readthedocs.io/en/latest/*** By opening this pull request, I affirm that all authors agree to the [Contributor License Agreement.](https://github.com/ecmwf/codex/blob/main/Legal/contributor_license_agreement.md)
1 parent 4262a74 commit d9efac5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/anemoi/inference/runner.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,15 @@ def forecast(
642642
new_state["fields"][self.checkpoint.output_tensor_index_to_variable[i]] = output[:, i]
643643

644644
if (s == 0 and self.verbosity > 0) or self.verbosity > 1:
645-
self._print_output_tensor("Output tensor", output)
645+
self._print_output_tensor("Output tensor", output.cpu().numpy())
646646

647647
if self.trace:
648648
self.trace.write_output_tensor(
649-
date, s, output, self.checkpoint.output_tensor_index_to_variable, self.checkpoint.timestep
649+
date,
650+
s,
651+
output.cpu().numpy(),
652+
self.checkpoint.output_tensor_index_to_variable,
653+
self.checkpoint.timestep,
650654
)
651655

652656
yield new_state

0 commit comments

Comments
 (0)