From 740c562ca3278566c65b3d3ad98fbb55df7967f1 Mon Sep 17 00:00:00 2001 From: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com> Date: Fri, 8 May 2026 02:57:19 -0700 Subject: [PATCH] Import tensors and add methods to sbox (#6450) * Import tensors and add methods to sbox * might be a good idea to expose pseudo-ctors also nuke spans as tey're too much to review rn * nuke buffers * nuke unconsumable types * hilarious --------- Co-authored-by: Pieter-Jan Briers --- Directory.Packages.props | 1 + .../NumericsHelpers/AddBenchmark.cs | 20 +++++++++++++------ Robust.Benchmarks/Robust.Benchmarks.csproj | 2 ++ Robust.Shared/ContentPack/Sandbox.yml | 2 ++ Robust.Shared/Robust.Shared.csproj | 1 + 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 20962c6c74..514e430eaa 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -74,6 +74,7 @@ + diff --git a/Robust.Benchmarks/NumericsHelpers/AddBenchmark.cs b/Robust.Benchmarks/NumericsHelpers/AddBenchmark.cs index 100ad64942..6be5f3de6a 100644 --- a/Robust.Benchmarks/NumericsHelpers/AddBenchmark.cs +++ b/Robust.Benchmarks/NumericsHelpers/AddBenchmark.cs @@ -1,17 +1,19 @@ -using BenchmarkDotNet.Attributes; +using System.Numerics.Tensors; +using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Configs; using Robust.Shared.Analyzers; namespace Robust.Benchmarks.NumericsHelpers; [Virtual] +[GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByMethod)] +[MemoryDiagnoser] +[DisassemblyDiagnoser] public class AddBenchmark { - [Params(32, 128)] + [Params(32, 128, 256, 512, 1024, 2048, 4096, 8192, 16384)] public int N { get; set; } - [Params(1,2)] - public int T { get; set; } - private float[] _inputA = default!; private float[] _inputB = default!; private float[] _output = default!; @@ -25,8 +27,14 @@ public class AddBenchmark } [Benchmark] - public void Bench() + public void BenchNumericsHelpers() { Shared.Maths.NumericsHelpers.Add(_inputA, _inputB, _output); } + + [Benchmark] + public void BenchTensor() + { + TensorPrimitives.Add(_inputA, _inputB, _output); + } } diff --git a/Robust.Benchmarks/Robust.Benchmarks.csproj b/Robust.Benchmarks/Robust.Benchmarks.csproj index 7e114649cc..f47c475bc9 100644 --- a/Robust.Benchmarks/Robust.Benchmarks.csproj +++ b/Robust.Benchmarks/Robust.Benchmarks.csproj @@ -22,6 +22,8 @@ + + diff --git a/Robust.Shared/ContentPack/Sandbox.yml b/Robust.Shared/ContentPack/Sandbox.yml index ed1982870b..04088b22f6 100644 --- a/Robust.Shared/ContentPack/Sandbox.yml +++ b/Robust.Shared/ContentPack/Sandbox.yml @@ -687,6 +687,8 @@ Types: IUnaryNegationOperators`2: { All: True } IUnaryPlusOperators`2: { All: True } IUnsignedNumber`1: { All: True } + System.Numerics.Tensors: + TensorPrimitives: { All: True } System.Reflection: Assembly: Methods: diff --git a/Robust.Shared/Robust.Shared.csproj b/Robust.Shared/Robust.Shared.csproj index 424cc81c66..cdd7bf9746 100644 --- a/Robust.Shared/Robust.Shared.csproj +++ b/Robust.Shared/Robust.Shared.csproj @@ -13,6 +13,7 @@ +