Used source generator in sample projects
このコミットが含まれているのは:
1 親
b31ec9f959
コミット
9fde5210c1
7ファイル変更
+50
-86
検索条件に一致するファイルはありません
@@ -11,6 +11,11 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
|
||||
<ProjectReference
|
||||
Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
|
||||
OutputItemType="Analyzer"
|
||||
ReferenceOutputAssembly="false"
|
||||
PrivateAssets="contentfiles;build"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -6,7 +6,7 @@ namespace ComputeSharp.Benchmark
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains primitives to run certain operations of a neural network
|
||||
/// </summary>
|
||||
internal static class Dnn
|
||||
internal static partial class Dnn
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes the forward pass on a fully connected layer on the CPU
|
||||
@@ -72,36 +72,17 @@ namespace ComputeSharp.Benchmark
|
||||
/// <summary>
|
||||
/// Kernel for <see cref="FullyConnectedForwardGpu"/>
|
||||
/// </summary>
|
||||
private readonly struct FullyConnectedForwardKernel : IComputeShader
|
||||
[AutoConstructor]
|
||||
private readonly partial struct FullyConnectedForwardKernel : IComputeShader
|
||||
{
|
||||
private readonly int n;
|
||||
private readonly int m;
|
||||
private readonly int p;
|
||||
|
||||
private readonly ReadOnlyBuffer<float> x;
|
||||
private readonly ReadOnlyBuffer<float> w;
|
||||
private readonly ReadOnlyBuffer<float> b;
|
||||
private readonly ReadWriteBuffer<float> y;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FullyConnectedForwardKernel(
|
||||
int n,
|
||||
int m,
|
||||
int p,
|
||||
ReadOnlyBuffer<float> x,
|
||||
ReadOnlyBuffer<float> w,
|
||||
ReadOnlyBuffer<float> b,
|
||||
ReadWriteBuffer<float> y)
|
||||
{
|
||||
this.n = n;
|
||||
this.m = m;
|
||||
this.p = p;
|
||||
this.x = x;
|
||||
this.w = w;
|
||||
this.b = b;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Execute(ThreadIds ids)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
|
||||
<ProjectReference
|
||||
Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
|
||||
OutputItemType="Analyzer"
|
||||
ReferenceOutputAssembly="false"
|
||||
PrivateAssets="contentfiles;build"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -18,7 +18,7 @@ namespace ComputeSharp.BokehBlur.Processors
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixel">The pixel format</typeparam>
|
||||
/// <remarks>This processor is based on the code from Mike Pound, see <a href="https://github.com/mikepound/convolve">github.com/mikepound/convolve</a></remarks>
|
||||
public sealed class HlslBokehBlurProcessor<TPixel> : ImageProcessor<TPixel>
|
||||
public sealed partial class HlslBokehBlurProcessor<TPixel> : ImageProcessor<TPixel>
|
||||
where TPixel : unmanaged, IPixel<TPixel>
|
||||
{
|
||||
/// <summary>
|
||||
@@ -301,22 +301,23 @@ namespace ComputeSharp.BokehBlur.Processors
|
||||
int height = Source.Height;
|
||||
int width = Source.Width;
|
||||
|
||||
Gpu.Default.For(width, height, new VerticalConvolutionProcessor
|
||||
{
|
||||
width = width,
|
||||
maxY = height - 1,
|
||||
maxX = width - 1,
|
||||
kernelLength = kernel.Length,
|
||||
source = source,
|
||||
target = target,
|
||||
kernel = kernel
|
||||
});
|
||||
VerticalConvolutionProcessor shader = new(
|
||||
width,
|
||||
maxY: height - 1,
|
||||
maxX: width - 1,
|
||||
kernelLength: kernel.Size,
|
||||
source,
|
||||
target,
|
||||
kernel);
|
||||
|
||||
Gpu.Default.For(width, height, in shader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kernel for <see cref="ApplyVerticalConvolution"/>
|
||||
/// </summary>
|
||||
private struct VerticalConvolutionProcessor : IComputeShader
|
||||
[AutoConstructor]
|
||||
private partial struct VerticalConvolutionProcessor : IComputeShader
|
||||
{
|
||||
public int width;
|
||||
public int maxY;
|
||||
@@ -371,24 +372,25 @@ namespace ComputeSharp.BokehBlur.Processors
|
||||
int height = Source.Height;
|
||||
int width = Source.Width;
|
||||
|
||||
Gpu.Default.For(width, height, new HorizontalConvolutionAndAccumulatePartialsProcessor
|
||||
{
|
||||
width = width,
|
||||
maxY = height - 1,
|
||||
maxX = width - 1,
|
||||
kernelLength = kernel.Length,
|
||||
z = z,
|
||||
w = w,
|
||||
source = source,
|
||||
target = target,
|
||||
kernel = kernel
|
||||
});
|
||||
HorizontalConvolutionAndAccumulatePartialsProcessor shader = new(
|
||||
width,
|
||||
maxY: height - 1,
|
||||
maxX: width - 1,
|
||||
kernelLength: kernel.Size,
|
||||
z,
|
||||
w,
|
||||
source,
|
||||
target,
|
||||
kernel);
|
||||
|
||||
Gpu.Default.For(width, height, in shader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kernel for <see cref="ApplyHorizontalConvolutionAndAccumulatePartials"/>
|
||||
/// </summary>
|
||||
private struct HorizontalConvolutionAndAccumulatePartialsProcessor : IComputeShader
|
||||
[AutoConstructor]
|
||||
private partial struct HorizontalConvolutionAndAccumulatePartialsProcessor : IComputeShader
|
||||
{
|
||||
public int width;
|
||||
public int maxY;
|
||||
@@ -450,7 +452,8 @@ namespace ComputeSharp.BokehBlur.Processors
|
||||
/// <summary>
|
||||
/// The processor for <see cref="GetExposedVector4Buffer"/>
|
||||
/// </summary>
|
||||
private readonly struct GetExposedVector4BufferProcessor : IRowOperation
|
||||
[AutoConstructor]
|
||||
private readonly partial struct GetExposedVector4BufferProcessor : IRowOperation
|
||||
{
|
||||
private readonly int width;
|
||||
private readonly float exp;
|
||||
@@ -459,21 +462,6 @@ namespace ComputeSharp.BokehBlur.Processors
|
||||
private readonly Memory<Vector4> target;
|
||||
private readonly Configuration configuration;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public GetExposedVector4BufferProcessor(
|
||||
int width,
|
||||
float exp,
|
||||
Memory<TPixel> source,
|
||||
Memory<Vector4> target,
|
||||
Configuration configuration)
|
||||
{
|
||||
this.width = width;
|
||||
this.exp = exp;
|
||||
this.source = source;
|
||||
this.target = target;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Invoke(int y)
|
||||
{
|
||||
@@ -514,7 +502,8 @@ namespace ComputeSharp.BokehBlur.Processors
|
||||
/// <summary>
|
||||
/// The processor for <see cref="ApplyInverseGammaExposure"/>
|
||||
/// </summary>
|
||||
private readonly struct ApplyInverseGammaExposureProcessor : IRowOperation
|
||||
[AutoConstructor]
|
||||
private readonly partial struct ApplyInverseGammaExposureProcessor : IRowOperation
|
||||
{
|
||||
private readonly int width;
|
||||
private readonly float exp;
|
||||
@@ -523,21 +512,6 @@ namespace ComputeSharp.BokehBlur.Processors
|
||||
private readonly Memory<TPixel> target;
|
||||
private readonly Configuration configuration;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ApplyInverseGammaExposureProcessor(
|
||||
int width,
|
||||
float exp,
|
||||
Memory<Vector4> source,
|
||||
Memory<TPixel> target,
|
||||
Configuration configuration)
|
||||
{
|
||||
this.width = width;
|
||||
this.exp = exp;
|
||||
this.source = source;
|
||||
this.target = target;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Invoke(int y)
|
||||
{
|
||||
|
||||
@@ -3,11 +3,15 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
|
||||
<LangVersion>preview</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
|
||||
<ProjectReference
|
||||
Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
|
||||
OutputItemType="Analyzer"
|
||||
ReferenceOutputAssembly="false"
|
||||
PrivateAssets="contentfiles;build"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -5,7 +5,7 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ComputeSharp.Sample
|
||||
{
|
||||
class Program
|
||||
partial class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputeSharp.Shaders\ComputeSharp.Shaders.csproj" />
|
||||
<ProjectReference
|
||||
Include="..\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
|
||||
OutputItemType="Analyzer"
|
||||
ReferenceOutputAssembly="false"
|
||||
PrivateAssets="contentfiles;build"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする