Build props refactoring, enabled TreatWarningsAsErrors
このコミットが含まれているのは:
1 親
38084c7548
コミット
2992825e4c
11ファイル変更
+65
-60
検索条件に一致するファイルはありません
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Engines;
|
||||
|
||||
@@ -35,42 +34,42 @@ namespace ComputeSharp.Benchmark.Blas
|
||||
/// <summary>
|
||||
/// The input tensor.
|
||||
/// </summary>
|
||||
private float[] X;
|
||||
private float[]? X;
|
||||
|
||||
/// <summary>
|
||||
/// The weights tensor.
|
||||
/// </summary>
|
||||
private float[] W;
|
||||
private float[]? W;
|
||||
|
||||
/// <summary>
|
||||
/// The bias tensor.
|
||||
/// </summary>
|
||||
private float[] B;
|
||||
private float[]? B;
|
||||
|
||||
/// <summary>
|
||||
/// The result tensor.
|
||||
/// </summary>
|
||||
private float[] Y;
|
||||
private float[]? Y;
|
||||
|
||||
/// <summary>
|
||||
/// The input tensor (GPU).
|
||||
/// </summary>
|
||||
private ReadOnlyBuffer<float> BufferX;
|
||||
private ReadOnlyBuffer<float>? BufferX;
|
||||
|
||||
/// <summary>
|
||||
/// The weights tensor (GPU).
|
||||
/// </summary>
|
||||
private ReadOnlyBuffer<float> BufferW;
|
||||
private ReadOnlyBuffer<float>? BufferW;
|
||||
|
||||
/// <summary>
|
||||
/// The bias tensor (GPU).
|
||||
/// </summary>
|
||||
private ReadOnlyBuffer<float> BufferB;
|
||||
private ReadOnlyBuffer<float>? BufferB;
|
||||
|
||||
/// <summary>
|
||||
/// The result tensor (GPU).
|
||||
/// </summary>
|
||||
private ReadWriteBuffer<float> BufferY;
|
||||
private ReadWriteBuffer<float>? BufferY;
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="System.Random"/> instance to initialize the tensors.
|
||||
@@ -87,10 +86,10 @@ namespace ComputeSharp.Benchmark.Blas
|
||||
float[] CreateRandomArray(int size)
|
||||
{
|
||||
float[] array = ArrayPool<float>.Shared.Rent(size);
|
||||
ref float r = ref array[0];
|
||||
for (int i = 0; i < size; i++)
|
||||
|
||||
foreach (ref float x in array.AsSpan())
|
||||
{
|
||||
Unsafe.Add(ref r, i) = (float)Random.NextDouble();
|
||||
x = (float)Random.NextDouble();
|
||||
}
|
||||
|
||||
return array;
|
||||
@@ -115,15 +114,15 @@ namespace ComputeSharp.Benchmark.Blas
|
||||
[GlobalCleanup]
|
||||
public void Dispose()
|
||||
{
|
||||
ArrayPool<float>.Shared.Return(X);
|
||||
ArrayPool<float>.Shared.Return(W);
|
||||
ArrayPool<float>.Shared.Return(B);
|
||||
ArrayPool<float>.Shared.Return(Y);
|
||||
ArrayPool<float>.Shared.Return(X!);
|
||||
ArrayPool<float>.Shared.Return(W!);
|
||||
ArrayPool<float>.Shared.Return(B!);
|
||||
ArrayPool<float>.Shared.Return(Y!);
|
||||
|
||||
BufferX.Dispose();
|
||||
BufferW.Dispose();
|
||||
BufferB.Dispose();
|
||||
BufferY.Dispose();
|
||||
BufferX!.Dispose();
|
||||
BufferW!.Dispose();
|
||||
BufferB!.Dispose();
|
||||
BufferY!.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -132,7 +131,7 @@ namespace ComputeSharp.Benchmark.Blas
|
||||
[Benchmark(Baseline = true)]
|
||||
public void Cpu()
|
||||
{
|
||||
BlasHelpers.FullyConnectedForwardCpu(C, N, M, P, X, W, B, Y);
|
||||
BlasHelpers.FullyConnectedForwardCpu(C, N, M, P, X!, W!, B!, Y!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -141,7 +140,7 @@ namespace ComputeSharp.Benchmark.Blas
|
||||
[Benchmark]
|
||||
public void GpuWithNoTemporaryBuffers()
|
||||
{
|
||||
BlasHelpers.FullyConnectedForwardGpu(Gpu.Default, C, N, M, P, BufferX, BufferW, BufferB, BufferY);
|
||||
BlasHelpers.FullyConnectedForwardGpu(Gpu.Default, C, N, M, P, BufferX!, BufferW!, BufferB!, BufferY!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -150,10 +149,10 @@ namespace ComputeSharp.Benchmark.Blas
|
||||
[Benchmark]
|
||||
public void GpuWithTemporaryBuffers()
|
||||
{
|
||||
using ReadOnlyBuffer<float> x = Gpu.Default.AllocateReadOnlyBuffer(X);
|
||||
using ReadOnlyBuffer<float> w = Gpu.Default.AllocateReadOnlyBuffer(W);
|
||||
using ReadOnlyBuffer<float> b = Gpu.Default.AllocateReadOnlyBuffer(B);
|
||||
using ReadWriteBuffer<float> y = Gpu.Default.AllocateReadWriteBuffer<float>(Y.Length);
|
||||
using ReadOnlyBuffer<float> x = Gpu.Default.AllocateReadOnlyBuffer(X!);
|
||||
using ReadOnlyBuffer<float> w = Gpu.Default.AllocateReadOnlyBuffer(W!);
|
||||
using ReadOnlyBuffer<float> b = Gpu.Default.AllocateReadOnlyBuffer(B!);
|
||||
using ReadWriteBuffer<float> y = Gpu.Default.AllocateReadWriteBuffer<float>(Y!.Length);
|
||||
|
||||
BlasHelpers.FullyConnectedForwardGpu(Gpu.Default, C, N, M, P, x, w, b, y);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ComputeSharp.Benchmark.Imaging
|
||||
/// <summary>
|
||||
/// The loaded image.
|
||||
/// </summary>
|
||||
private Image<ImageSharpRgba32> image;
|
||||
private Image<ImageSharpRgba32>? image;
|
||||
|
||||
/// <summary>
|
||||
/// Initial setup for a benchmarking session.
|
||||
@@ -31,7 +31,7 @@ namespace ComputeSharp.Benchmark.Imaging
|
||||
[GlobalSetup]
|
||||
public void Setup()
|
||||
{
|
||||
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Imaging", "city.jpg");
|
||||
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging", "city.jpg");
|
||||
|
||||
this.image = Image.Load<ImageSharpRgba32>(path);
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace ComputeSharp.Benchmark.Imaging
|
||||
[GlobalCleanup]
|
||||
public void Dispose()
|
||||
{
|
||||
this.image.Dispose();
|
||||
this.image!.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -55,7 +55,7 @@ namespace ComputeSharp.Benchmark.Imaging
|
||||
[BenchmarkCategory("BOKEH")]
|
||||
public void Bokeh_Cpu()
|
||||
{
|
||||
this.image.Mutate(c => c.ApplyProcessor(new BokehBlurProcessor(80, 2, 3)));
|
||||
this.image!.Mutate(c => c.ApplyProcessor(new BokehBlurProcessor(80, 2, 3)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -65,7 +65,7 @@ namespace ComputeSharp.Benchmark.Imaging
|
||||
[BenchmarkCategory("BOKEH")]
|
||||
public void Bokeh_Gpu()
|
||||
{
|
||||
this.image.Mutate(c => c.ApplyProcessor(new HlslBokehBlurProcessor(80, 2)));
|
||||
this.image!.Mutate(c => c.ApplyProcessor(new HlslBokehBlurProcessor(80, 2)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -75,7 +75,7 @@ namespace ComputeSharp.Benchmark.Imaging
|
||||
[BenchmarkCategory("GAUSSIAN")]
|
||||
public void Gaussian_Cpu()
|
||||
{
|
||||
this.image.Mutate(c => c.ApplyProcessor(new GaussianBlurProcessor(80)));
|
||||
this.image!.Mutate(c => c.ApplyProcessor(new GaussianBlurProcessor(80)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -85,7 +85,7 @@ namespace ComputeSharp.Benchmark.Imaging
|
||||
[BenchmarkCategory("GAUSSIAN")]
|
||||
public void Gaussian_Gpu()
|
||||
{
|
||||
this.image.Mutate(c => c.ApplyProcessor(new HlslGaussianBlurProcessor(80)));
|
||||
this.image!.Mutate(c => c.ApplyProcessor(new HlslGaussianBlurProcessor(80)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp.ImageProcessing
|
||||
static void Main()
|
||||
{
|
||||
Console.WriteLine(">> Loading image");
|
||||
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "city.jpg");
|
||||
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "city.jpg");
|
||||
using Image<ImageSharpRgba32> image = Image.Load<ImageSharpRgba32>(path);
|
||||
|
||||
// Apply a series of processors and save the results
|
||||
@@ -29,7 +29,7 @@ namespace ComputeSharp.ImageProcessing
|
||||
|
||||
Console.WriteLine($">> Saving {effect.Name} to disk");
|
||||
string targetPath = Path.Combine(
|
||||
Path.GetRelativePath(Path.GetDirectoryName(path), @"..\..\..\"),
|
||||
Path.GetRelativePath(Path.GetDirectoryName(path)!, @"..\..\..\"),
|
||||
$"{Path.GetFileNameWithoutExtension(path)}_{effect.Name}{Path.GetExtension(path)}");
|
||||
copy.Save(targetPath);
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする