Skip to content

Commit b30a60d

Browse files
Merge pull request #1376 from JamesG9802/FixTensorBackwardCall
Fixing Tensor.backward's function signature
2 parents 97b9921 + 7aefafd commit b30a60d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

RELEASENOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Releases, starting with 9/2/2021, are listed with the most recent release at the
44

55
# NuGet Version 0.103.1
66

7+
__Breaking Changes__:
8+
#1376 `torch.Tensor.backward`'s function signature has been updated to match PyTorch's implementation. Previously, passing `create_graph` or `retain_graph` by position would work like PyTorch's `torch.Tensor.backward`, but not if passing by name (`create_graph`'s value was swapped with `retain_graph`). This has been corrected; however, this means any code that passes `create_graph` or `retain_graph` by name needs to be updated to reflect the intended functionality.<br/>
9+
710
__Bug Fixes__:
811

912
#1383 `torch.linalg.vector_norm`: Make `ord`-argument optional, as specified in docs<br/>

src/TorchSharp/Tensor/Tensor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,8 @@ public bool is_sparse {
697697
}
698698
}
699699

700-
public void backward(IList<Tensor>? grad_tensors = null, bool create_graph = false, bool retain_graph = false, IList<Tensor>? inputs = null) =>
701-
torch.autograd.backward(new[] { this }, grad_tensors, create_graph, retain_graph, inputs);
700+
public void backward(IList<Tensor>? grad_tensors = null, bool retain_graph = false, bool create_graph = false, IList<Tensor>? inputs = null) =>
701+
torch.autograd.backward(new[] { this }, grad_tensors, retain_graph, create_graph, inputs);
702702

703703
/// <summary>
704704
/// Creates a tensor by loading it from a file.

0 commit comments

Comments
 (0)