Skip to content
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

Add Windows ML native APIs #144

Merged
merged 4 commits into from
Nov 11, 2020
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
16 changes: 16 additions & 0 deletions TerraFX.Interop.Windows.sln
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "windows.ui.xaml.hosting.des
generation\um\windows.ui.xaml.hosting.desktopwindowxamlsource\um-windows.ui.xaml.hosting.desktopwindowxamlsource.h = generation\um\windows.ui.xaml.hosting.desktopwindowxamlsource\um-windows.ui.xaml.hosting.desktopwindowxamlsource.h
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MLOperatorAuthor", "MLOperatorAuthor", "{E2054468-470F-46E2-AEF9-4FC6A41228EA}"
ProjectSection(SolutionItems) = preProject
generation\um\MLOperatorAuthor\generate.rsp = generation\um\MLOperatorAuthor\generate.rsp
generation\um\MLOperatorAuthor\header.txt = generation\um\MLOperatorAuthor\header.txt
generation\um\MLOperatorAuthor\um-MLOperatorAuthor.h = generation\um\MLOperatorAuthor\um-MLOperatorAuthor.h
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "windows.ai.machinelearning.native", "windows.ai.machinelearning.native", "{CBCCB0D7-2657-42CB-8819-0AD46B1C6346}"
ProjectSection(SolutionItems) = preProject
generation\um\windows.ai.machinelearning.native\generate.rsp = generation\um\windows.ai.machinelearning.native\generate.rsp
generation\um\windows.ai.machinelearning.native\header.txt = generation\um\windows.ai.machinelearning.native\header.txt
generation\um\windows.ai.machinelearning.native\um-windows.ai.machinelearning.native.h = generation\um\windows.ai.machinelearning.native\um-windows.ai.machinelearning.native.h
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1734,6 +1748,8 @@ Global
{95CB59A8-9E9C-483B-B5A7-0A19EE6B8734} = {67311E5E-FA9C-43A6-B431-9EF10047A0CE}
{8132BF5E-738F-458B-9778-23C3737547C6} = {D9638FEE-50A4-44FF-B1F6-72E59548490B}
{AD0959E5-765F-4670-BD34-3D03C72813C7} = {67311E5E-FA9C-43A6-B431-9EF10047A0CE}
{E2054468-470F-46E2-AEF9-4FC6A41228EA} = {67311E5E-FA9C-43A6-B431-9EF10047A0CE}
{CBCCB0D7-2657-42CB-8819-0AD46B1C6346} = {67311E5E-FA9C-43A6-B431-9EF10047A0CE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2FE36DF8-2D9C-4F20-8787-45DC74B57461}
Expand Down
17 changes: 17 additions & 0 deletions generation/um/MLOperatorAuthor/generate.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@../../settings.rsp
@../../remap.rsp
--exclude
MLOperatorEdgeTypeConstrant
--file
um-MLOperatorAuthor.h
--output
../../../sources/Interop/Windows/um/MLOperatorAuthor
--test-output
../../../tests/Interop/Windows/um/MLOperatorAuthor
--traverse
C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/um/MLOperatorAuthor.h
--with-attribute
MLOperatorKernelOptions=Flags
MLOperatorParameterOptions=Flags
--with-librarypath
*=Windows.AI.MachineLearning.dll
4 changes: 4 additions & 0 deletions generation/um/MLOperatorAuthor/header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

// Ported from um/MLOperatorAuthor.h in the Windows SDK for Windows 10.0.19041.0
// Original source is Copyright © Microsoft. All rights reserved.
2 changes: 2 additions & 0 deletions generation/um/MLOperatorAuthor/um-MLOperatorAuthor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include <Windows.h>
#include <MLOperatorAuthor.h>
10 changes: 10 additions & 0 deletions generation/um/windows.ai.machinelearning.native/generate.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@../../settings.rsp
@../../remap.rsp
--file
um-windows.ai.machinelearning.native.h
--output
../../../sources/Interop/Windows/um/windows.ai.machinelearning.native
--test-output
../../../tests/Interop/Windows/um/windows.ai.machinelearning.native
--traverse
C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/um/windows.ai.machinelearning.native.h
4 changes: 4 additions & 0 deletions generation/um/windows.ai.machinelearning.native/header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

// Ported from um/windows.ai.machinelearning.native.h in the Windows SDK for Windows 10.0.19041.0
// Original source is Copyright © Microsoft. All rights reserved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include <Windows.h>
#include <windows.ai.machinelearning.native.h>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

// Ported from um/MLOperatorAuthor.h in the Windows SDK for Windows 10.0.19041.0
// Original source is Copyright © Microsoft. All rights reserved.

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace TerraFX.Interop
{
[Guid("4B1B1759-EC40-466C-AAB4-BEB5347FD24C")]
[NativeTypeName("struct IMLOperatorAttributes : IUnknown")]
public unsafe partial struct IMLOperatorAttributes
{
public void** lpVtbl;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("HRESULT")]
public int QueryInterface([NativeTypeName("const IID &")] Guid* riid, [NativeTypeName("void **")] void** ppvObject)
{
return ((delegate* unmanaged<IMLOperatorAttributes*, Guid*, void**, int>)(lpVtbl[0]))((IMLOperatorAttributes*)Unsafe.AsPointer(ref this), riid, ppvObject);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("ULONG")]
public uint AddRef()
{
return ((delegate* unmanaged<IMLOperatorAttributes*, uint>)(lpVtbl[1]))((IMLOperatorAttributes*)Unsafe.AsPointer(ref this));
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("ULONG")]
public uint Release()
{
return ((delegate* unmanaged<IMLOperatorAttributes*, uint>)(lpVtbl[2]))((IMLOperatorAttributes*)Unsafe.AsPointer(ref this));
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("HRESULT")]
public int GetAttributeElementCount([NativeTypeName("const char *")] sbyte* name, MLOperatorAttributeType type, [NativeTypeName("uint32_t *")] uint* elementCount)
{
return ((delegate* unmanaged<IMLOperatorAttributes*, sbyte*, MLOperatorAttributeType, uint*, int>)(lpVtbl[3]))((IMLOperatorAttributes*)Unsafe.AsPointer(ref this), name, type, elementCount);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("HRESULT")]
public int GetAttribute([NativeTypeName("const char *")] sbyte* name, MLOperatorAttributeType type, [NativeTypeName("uint32_t")] uint elementCount, [NativeTypeName("size_t")] nuint elementByteSize, [NativeTypeName("void *")] void* value)
{
return ((delegate* unmanaged<IMLOperatorAttributes*, sbyte*, MLOperatorAttributeType, uint, nuint, void*, int>)(lpVtbl[4]))((IMLOperatorAttributes*)Unsafe.AsPointer(ref this), name, type, elementCount, elementByteSize, value);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("HRESULT")]
public int GetStringAttributeElementLength([NativeTypeName("const char *")] sbyte* name, [NativeTypeName("uint32_t")] uint elementIndex, [NativeTypeName("uint32_t *")] uint* attributeElementByteSize)
{
return ((delegate* unmanaged<IMLOperatorAttributes*, sbyte*, uint, uint*, int>)(lpVtbl[5]))((IMLOperatorAttributes*)Unsafe.AsPointer(ref this), name, elementIndex, attributeElementByteSize);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("HRESULT")]
public int GetStringAttributeElement([NativeTypeName("const char *")] sbyte* name, [NativeTypeName("uint32_t")] uint elementIndex, [NativeTypeName("uint32_t")] uint attributeElementByteSize, [NativeTypeName("char *")] sbyte* attributeElement)
{
return ((delegate* unmanaged<IMLOperatorAttributes*, sbyte*, uint, uint, sbyte*, int>)(lpVtbl[6]))((IMLOperatorAttributes*)Unsafe.AsPointer(ref this), name, elementIndex, attributeElementByteSize, attributeElement);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

// Ported from um/MLOperatorAuthor.h in the Windows SDK for Windows 10.0.19041.0
// Original source is Copyright © Microsoft. All rights reserved.

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace TerraFX.Interop
{
[Guid("11C4B4A0-B467-4EAA-A1A6-B961D8D0ED79")]
[NativeTypeName("struct IMLOperatorKernel : IUnknown")]
public unsafe partial struct IMLOperatorKernel
{
public void** lpVtbl;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("HRESULT")]
public int QueryInterface([NativeTypeName("const IID &")] Guid* riid, [NativeTypeName("void **")] void** ppvObject)
{
return ((delegate* unmanaged<IMLOperatorKernel*, Guid*, void**, int>)(lpVtbl[0]))((IMLOperatorKernel*)Unsafe.AsPointer(ref this), riid, ppvObject);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("ULONG")]
public uint AddRef()
{
return ((delegate* unmanaged<IMLOperatorKernel*, uint>)(lpVtbl[1]))((IMLOperatorKernel*)Unsafe.AsPointer(ref this));
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("ULONG")]
public uint Release()
{
return ((delegate* unmanaged<IMLOperatorKernel*, uint>)(lpVtbl[2]))((IMLOperatorKernel*)Unsafe.AsPointer(ref this));
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("HRESULT")]
public int Compute([NativeTypeName("IMLOperatorKernelContext *")] IMLOperatorKernelContext* context)
{
return ((delegate* unmanaged<IMLOperatorKernel*, IMLOperatorKernelContext*, int>)(lpVtbl[3]))((IMLOperatorKernel*)Unsafe.AsPointer(ref this), context);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

// Ported from um/MLOperatorAuthor.h in the Windows SDK for Windows 10.0.19041.0
// Original source is Copyright © Microsoft. All rights reserved.

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace TerraFX.Interop
{
[Guid("82536A28-F022-4769-9D3F-8B278F84C0C3")]
[NativeTypeName("struct IMLOperatorKernelContext : IUnknown")]
public unsafe partial struct IMLOperatorKernelContext
{
public void** lpVtbl;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("HRESULT")]
public int QueryInterface([NativeTypeName("const IID &")] Guid* riid, [NativeTypeName("void **")] void** ppvObject)
{
return ((delegate* unmanaged<IMLOperatorKernelContext*, Guid*, void**, int>)(lpVtbl[0]))((IMLOperatorKernelContext*)Unsafe.AsPointer(ref this), riid, ppvObject);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("ULONG")]
public uint AddRef()
{
return ((delegate* unmanaged<IMLOperatorKernelContext*, uint>)(lpVtbl[1]))((IMLOperatorKernelContext*)Unsafe.AsPointer(ref this));
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("ULONG")]
public uint Release()
{
return ((delegate* unmanaged<IMLOperatorKernelContext*, uint>)(lpVtbl[2]))((IMLOperatorKernelContext*)Unsafe.AsPointer(ref this));
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("HRESULT")]
public int GetInputTensor([NativeTypeName("uint32_t")] uint inputIndex, [NativeTypeName("IMLOperatorTensor **")] IMLOperatorTensor** tensor)
{
return ((delegate* unmanaged<IMLOperatorKernelContext*, uint, IMLOperatorTensor**, int>)(lpVtbl[3]))((IMLOperatorKernelContext*)Unsafe.AsPointer(ref this), inputIndex, tensor);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("HRESULT")]
public int GetOutputTensor([NativeTypeName("uint32_t")] uint outputIndex, [NativeTypeName("IMLOperatorTensor **")] IMLOperatorTensor** tensor)
{
return ((delegate* unmanaged<IMLOperatorKernelContext*, uint, IMLOperatorTensor**, int>)(lpVtbl[4]))((IMLOperatorKernelContext*)Unsafe.AsPointer(ref this), outputIndex, tensor);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("HRESULT")]
public int GetOutputTensor([NativeTypeName("uint32_t")] uint outputIndex, [NativeTypeName("uint32_t")] uint dimensionCount, [NativeTypeName("const uint32_t *")] uint* dimensionSizes, [NativeTypeName("IMLOperatorTensor **")] IMLOperatorTensor** tensor)
{
return ((delegate* unmanaged<IMLOperatorKernelContext*, uint, uint, uint*, IMLOperatorTensor**, int>)(lpVtbl[5]))((IMLOperatorKernelContext*)Unsafe.AsPointer(ref this), outputIndex, dimensionCount, dimensionSizes, tensor);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NativeTypeName("HRESULT")]
public int AllocateTemporaryData([NativeTypeName("size_t")] nuint size, [NativeTypeName("IUnknown **")] IUnknown** data)
{
return ((delegate* unmanaged<IMLOperatorKernelContext*, nuint, IUnknown**, int>)(lpVtbl[6]))((IMLOperatorKernelContext*)Unsafe.AsPointer(ref this), size, data);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void GetExecutionInterface([NativeTypeName("IUnknown **")] IUnknown** executionObject)
{
((delegate* unmanaged<IMLOperatorKernelContext*, IUnknown**, void>)(lpVtbl[7]))((IMLOperatorKernelContext*)Unsafe.AsPointer(ref this), executionObject);
}
}
}
Loading