Skip to content

Commit

Permalink
Bump the dotnet group in /docs/core/whats-new/snippets/dotnet-9/cshar…
Browse files Browse the repository at this point in the history
…p with 3 updates (#43069)

* Bump the dotnet group

Bumps the dotnet group in /docs/core/whats-new/snippets/dotnet-9/csharp with 3 updates: [Azure.Storage.Blobs](https://github.com/Azure/azure-sdk-for-net), [System.Net.ServerSentEvents](https://github.com/dotnet/runtime) and [System.Numerics.Tensors](https://github.com/dotnet/runtime).


Updates `Azure.Storage.Blobs` from 12.22.0-beta.1 to 12.22.2
- [Release notes](https://github.com/Azure/azure-sdk-for-net/releases)
- [Commits](Azure/azure-sdk-for-net@Azure.Storage.Blobs_12.22.0-beta.1...Azure.Storage.Blobs_12.22.2)

Updates `System.Net.ServerSentEvents` from 9.0.0-preview.6.24327.7 to 9.0.0-rc.2.24473.5
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](dotnet/runtime@9.0.0-preview.6.24327.7...v9.0.0-rc.2.24473.5)

Updates `System.Numerics.Tensors` from 9.0.0-preview.5.24306.7 to 9.0.0-rc.2.24473.5
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](dotnet/runtime@v9.0.0-preview.5.24306.7...v9.0.0-rc.2.24473.5)

---
updated-dependencies:
- dependency-name: Azure.Storage.Blobs
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: dotnet
- dependency-name: System.Net.ServerSentEvents
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: dotnet
- dependency-name: System.Numerics.Tensors
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: dotnet
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix build errors

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Genevieve Warren <[email protected]>
  • Loading branch information
dependabot[bot] and gewarren authored Oct 16, 2024
1 parent 5809992 commit a9d6095
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ charset = utf-8-bom
# Analyzers
dotnet_analyzer_diagnostic.category-Security.severity = error
dotnet_code_quality.ca1802.api_surface = private, internal
# SYSLIB5001: Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
dotnet_diagnostic.SYSLIB5001.severity = suggestion

# Miscellaneous style rules
dotnet_sort_system_directives_first = true
Expand Down
3 changes: 2 additions & 1 deletion docs/core/whats-new/snippets/dotnet-9/csharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
//Channels.RunIt();
//RegularExpressions.RunIt();
//Collections.RunIt();
Diagnostics.RunIt();
//Diagnostics.RunIt();
Tensors.RunIt();
6 changes: 3 additions & 3 deletions docs/core/whats-new/snippets/dotnet-9/csharp/Project.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.22.0-beta.1" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.22.2" />
<PackageReference Include="Microsoft.ML.Tokenizers" Version="0.21.1" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Net.ServerSentEvents" Version="9.0.0-preview.6.24327.7" />
<PackageReference Include="System.Numerics.Tensors" Version="9.0.0-preview.5.24306.7" />
<PackageReference Include="System.Net.ServerSentEvents" Version="9.0.0-rc.2.24473.5" />
<PackageReference Include="System.Numerics.Tensors" Version="9.0.0-rc.2.24473.5" />
</ItemGroup>

<ItemGroup>
Expand Down
19 changes: 9 additions & 10 deletions docs/core/whats-new/snippets/dotnet-9/csharp/Tensors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,44 @@ public static void RunIt()
{
// <SnippetTensor>
// Create a tensor (1 x 3).
var t0 = Tensor.Create([1, 2, 3], [1, 3]); // [[1, 2, 3]]
Tensor<int> t0 = Tensor.Create([1, 2, 3], [1, 3]); // [[1, 2, 3]]

// Reshape tensor (3 x 1).
var t1 = t0.Reshape(3, 1); // [[1], [2], [3]]
Tensor<int> t1 = t0.Reshape(3, 1); // [[1], [2], [3]]

// Slice tensor (2 x 1).
var t2 = t1.Slice(1.., ..); // [[2], [3]]
Tensor<int> t2 = t1.Slice(1.., ..); // [[2], [3]]

// Broadcast tensor (3 x 1) -> (3 x 3).
// [
// [ 1, 1, 1],
// [ 2, 2, 2],
// [ 3, 3, 3]
// ]
var t3 = Tensor.Broadcast(t1, [3, 3]);
var t3 = Tensor.Broadcast<int>(t1, [3, 3]);

// Math operations.
var t4 = Tensor.Add(t0, 1); // [[2, 3, 4]]
var t5 = Tensor.Add(t0, t0); // [[2, 4, 6]]
var t5 = Tensor.Add(t0.AsReadOnlyTensorSpan(), t0); // [[2, 4, 6]]
var t6 = Tensor.Subtract(t0, 1); // [[0, 1, 2]]
var t7 = Tensor.Subtract(t0, t0); // [[0, 0, 0]]
var t7 = Tensor.Subtract(t0.AsReadOnlyTensorSpan(), t0); // [[0, 0, 0]]
var t8 = Tensor.Multiply(t0, 2); // [[2, 4, 6]]
var t9 = Tensor.Multiply(t0, t0); // [[1, 4, 9]]
var t9 = Tensor.Multiply(t0.AsReadOnlyTensorSpan(), t0); // [[1, 4, 9]]
var t10 = Tensor.Divide(t0, 2); // [[0.5, 1, 1.5]]
var t11 = Tensor.Divide(t0, t0); // [[1, 1, 1]]
var t11 = Tensor.Divide(t0.AsReadOnlyTensorSpan(), t0); // [[1, 1, 1]]
// </SnippetTensor>

// <SnippetCosineSimilarity>
ReadOnlySpan<float> vector1 = [1, 2, 3];
ReadOnlySpan<float> vector2 = [4, 5, 6];
Console.WriteLine(TensorPrimitives.CosineSimilarity(vector1, vector2));

// Prints 0.9746318

ReadOnlySpan<double> vector3 = [1, 2, 3];
ReadOnlySpan<double> vector4 = [4, 5, 6];
Console.WriteLine(TensorPrimitives.CosineSimilarity(vector3, vector4));

// Prints 0.9746318461970762

// </SnippetCosineSimilarity>
}
}

0 comments on commit a9d6095

Please sign in to comment.