-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Microsoft/sync_internal_master
Sync with internal master.
- Loading branch information
Showing
65 changed files
with
2,460 additions
and
1,345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
csharp/src/Microsoft.ML.OnnxRuntime/ExecutionProviderFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Microsoft.ML.OnnxRuntime | ||
{ | ||
|
||
internal class CpuExecutionProviderFactory: NativeOnnxObjectHandle | ||
{ | ||
protected static readonly Lazy<CpuExecutionProviderFactory> _default = new Lazy<CpuExecutionProviderFactory>(() => new CpuExecutionProviderFactory()); | ||
|
||
public CpuExecutionProviderFactory(bool useArena=true) | ||
:base(IntPtr.Zero) | ||
{ | ||
int useArenaInt = useArena ? 1 : 0; | ||
try | ||
{ | ||
NativeApiStatus.VerifySuccess(NativeMethods.ONNXRuntimeCreateCpuExecutionProviderFactory(useArenaInt, out handle)); | ||
} | ||
catch(OnnxRuntimeException e) | ||
{ | ||
if (IsInvalid) | ||
{ | ||
ReleaseHandle(); | ||
handle = IntPtr.Zero; | ||
} | ||
throw e; | ||
} | ||
} | ||
|
||
public static CpuExecutionProviderFactory Default | ||
{ | ||
get | ||
{ | ||
return _default.Value; | ||
} | ||
} | ||
} | ||
|
||
internal class MklDnnExecutionProviderFactory : NativeOnnxObjectHandle | ||
{ | ||
protected static readonly Lazy<MklDnnExecutionProviderFactory> _default = new Lazy<MklDnnExecutionProviderFactory>(() => new MklDnnExecutionProviderFactory()); | ||
|
||
public MklDnnExecutionProviderFactory(bool useArena = true) | ||
:base(IntPtr.Zero) | ||
{ | ||
int useArenaInt = useArena ? 1 : 0; | ||
try | ||
{ | ||
NativeApiStatus.VerifySuccess(NativeMethods.ONNXRuntimeCreateMkldnnExecutionProviderFactory(useArenaInt, out handle)); | ||
} | ||
catch (OnnxRuntimeException e) | ||
{ | ||
if (IsInvalid) | ||
{ | ||
ReleaseHandle(); | ||
handle = IntPtr.Zero; | ||
} | ||
throw e; | ||
} | ||
} | ||
|
||
public static MklDnnExecutionProviderFactory Default | ||
{ | ||
get | ||
{ | ||
return _default.Value; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
} |
Oops, something went wrong.