Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
 
namespace Microsoft.ML.OnnxRuntime
{
    using System;
    using System.Runtime.InteropServices;
 
    /// <summary>
    /// Represents the type of hardware device.
    /// Matches OrtHardwareDeviceType in the ORT C API.
    /// </summary>
    public enum OrtHardwareDeviceType
    {
        CPU = 0,
        GPU = 1,
        NPU = 2,
    }
 
    /// <summary>
    /// Represents a hardware device that is available on the current system.
    /// </summary>
    public class OrtHardwareDevice
    {
 
        /// <summary>
        /// Construct an OrtHardwareDevice for a native OrtHardwareDevice instance.
        /// </summary>
        /// <param name="deviceHandle">Native OrtHardwareDevice handle.</param>
        internal OrtHardwareDevice(IntPtr deviceHandle)            
        {
            _handle = deviceHandle;
        }
 
        /// <summary>
        /// Get the type of hardware device.
        /// </summary>
        public OrtHardwareDeviceType Type
        {
            get
            {
                return (OrtHardwareDeviceType)NativeMethods.OrtHardwareDevice_Type(_handle);
            }
        }
 
        /// <summary>
        /// Get the vendor ID of the hardware device if known.
        /// </summary>
        /// <remarks>
        /// For PCIe devices the vendor ID is the PCIe vendor ID. See https://pcisig.com/membership/member-companies.
        /// </remarks>
        public uint VendorId
        {
            get
            {
                return NativeMethods.OrtHardwareDevice_VendorId(_handle);
            }
        }
 
        /// <summary>
        /// The vendor (manufacturer) of the hardware device.
        /// </summary>
        public string Vendor
        {
            get
            {
                IntPtr vendorPtr = NativeMethods.OrtHardwareDevice_Vendor(_handle);
                return NativeOnnxValueHelper.StringFromNativeUtf8(vendorPtr);
            }
        }
 
        /// <summary>
        /// Get the device ID of the hardware device if known.
        /// </summary>
        /// <remarks>
        /// This is the identifier of the device model. 
        /// PCIe device IDs can be looked up at https://www.pcilookup.com/ when combined with the VendorId.
        /// It is NOT a unique identifier for the device in the current system.
        /// </remarks>
        public uint DeviceId
        {
            get
            {
                return NativeMethods.OrtHardwareDevice_DeviceId(_handle);
            }
        }
 
        /// <summary>
        /// Get device metadata.
        /// This may include information such as whether a GPU is discrete or integrated.
        /// The available metadata will differ by platform and device type.
        /// </summary>
        public OrtKeyValuePairs Metadata
        {
            get
            {
                return new OrtKeyValuePairs(NativeMethods.OrtHardwareDevice_Metadata(_handle));
            }
        }
 
        private readonly IntPtr _handle;
 
        /// <summary>
        /// Gets the native handle for internal use.
        /// </summary>
        internal IntPtr Handle => _handle;
    }
}