Skip to content

torch.linalg.vector_norm : Set ord default as specified in docs #1383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
12 changes: 9 additions & 3 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Releases, starting with 9/2/2021, are listed with the most recent release at the top.

# NuGet Version 0.103.1

__Bug Fixes__:

#1383 `torch.linalg.vector_norm`: Make `ord`-argument optional, as specified in docs

# NuGet Version 0.103.0

Move to libtorch 2.4.0.
Expand Down Expand Up @@ -115,8 +121,8 @@ Any code that checks whether a device is 'CUDA' and does something rather than c

__API Changes__:

#652: Apple Silicon support .<br/>
#1219: Added support for loading and saving tensors that are >2GB.<br/>
#652: Apple Silicon support .<br/>
#1219: Added support for loading and saving tensors that are >2GB.<br/>

__Bug Fixes__:

Expand Down Expand Up @@ -930,7 +936,7 @@ Added '_' to the torch.nn.init functions. They overwrite the input tensor, so th

__Fixed Bugs:__

#399 Data<T>() returns span that must be indexed using strides.
#399 Data<T>() returns span that must be indexed using strides.

This was a major bug, affecting any code that pulled data out of a tensor view.

Expand Down
2 changes: 1 addition & 1 deletion src/TorchSharp/LinearAlgebra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ public static Tensor tensorsolve(Tensor A, Tensor B, long[] dims)
/// <param name="dims">Dimensions over which to compute the norm.</param>
/// <param name="keepdim">If set to true, the reduced dimensions are retained in the result as dimensions with size one. </param>
/// <returns></returns>
public static Tensor vector_norm(Tensor input, double ord, long[]? dims = null, bool keepdim = false)
public static Tensor vector_norm(Tensor input, double ord = 2d, long[]? dims = null, bool keepdim = false)
{
unsafe {
fixed (long* pdims = dims) {
Expand Down
6 changes: 6 additions & 0 deletions test/TorchSharpTest/LinearAlgebra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,12 @@ public void VectorNormTest()

Assert.Equal(5.4344883f, b.item<float>());
Assert.Equal(5.4344883f, c.item<float>());

var d = linalg.vector_norm(a, ord: 2);
var e = linalg.vector_norm(a);

Assert.Equal(7.7459669f, d.item<float>());
Assert.Equal(7.7459669f, e.item<float>());
}
}

Expand Down