forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackendFactory.cs
More file actions
31 lines (28 loc) · 871 Bytes
/
BackendFactory.cs
File metadata and controls
31 lines (28 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Diagnostics;
namespace NumSharp.Backends
{
public class BackendFactory
{
[DebuggerNonUserCode]
public static TensorEngine GetEngine(BackendType backendType = BackendType.Default)
{
switch (backendType)
{
case BackendType.Default:
return EngineCache<DefaultEngine>.Value;
default:
throw new ArgumentOutOfRangeException(nameof(backendType), backendType, null);
}
}
[DebuggerNonUserCode]
public static TensorEngine GetEngine<T>() where T : TensorEngine, new()
{
return EngineCache<T>.Value;
}
private static class EngineCache<T> where T : TensorEngine, new()
{
public static readonly T Value = new T();
}
}
}