com.github.asus4.onnxruntime 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Plugins/Android/onnxruntime-android.aar +0 -0
- package/Plugins/Linux/x64/libonnxruntime.so +0 -0
- package/Plugins/Windows/x64/onnxruntime.dll +0 -0
- package/Plugins/iOS~/onnxruntime.xcframework/Info.plist +8 -8
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/coreml_provider_factory.h +6 -1
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/onnxruntime_c_api.h +92 -7
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/onnxruntime_cxx_api.h +48 -0
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/onnxruntime_cxx_inline.h +42 -0
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/onnxruntime_float16.h +0 -5
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/onnxruntime_session_options_config_keys.h +10 -0
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Info.plist +2 -2
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/onnxruntime +0 -0
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/coreml_provider_factory.h +6 -1
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/onnxruntime_c_api.h +92 -7
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/onnxruntime_cxx_api.h +48 -0
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/onnxruntime_cxx_inline.h +42 -0
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/onnxruntime_float16.h +0 -5
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/onnxruntime_session_options_config_keys.h +10 -0
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Info.plist +2 -2
- package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/onnxruntime +0 -0
- package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/Versions/A/Headers/coreml_provider_factory.h +6 -1
- package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/Versions/A/Headers/onnxruntime_c_api.h +92 -7
- package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/Versions/A/Headers/onnxruntime_cxx_api.h +48 -0
- package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/Versions/A/Headers/onnxruntime_cxx_inline.h +42 -0
- package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/Versions/A/Headers/onnxruntime_float16.h +0 -5
- package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/Versions/A/Headers/onnxruntime_session_options_config_keys.h +10 -0
- package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/Versions/A/Resources/Info.plist +2 -2
- package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/Versions/A/onnxruntime +0 -0
- package/Plugins/macOS/libonnxruntime.dylib +0 -0
- package/README.md +5 -5
- package/Runtime/AssemblyInfo.shared.cs +1 -2
- package/Runtime/DisposableNamedOnnxValue.shared.cs +4 -4
- package/Runtime/FixedBufferOnnxValue.shared.cs +2 -2
- package/Runtime/InferenceSession.shared.cs +2 -3
- package/Runtime/ManagedProjections.shared.cs +1 -1
- package/Runtime/NamedOnnxValue.shared.cs +6 -17
- package/Runtime/NativeMethods.shared.cs +87 -10
- package/Runtime/NativeOnnxValueHelper.shared.cs +1 -1
- package/Runtime/OrtEnv.shared.cs +1 -1
- package/Runtime/OrtFloat16.shared.cs +42 -39
- package/Runtime/OrtIoBinding.shared.cs +1 -1
- package/Runtime/OrtLoraAdapter.shared.cs +81 -0
- package/Runtime/OrtLoraAdapter.shared.cs.meta +11 -0
- package/Runtime/OrtValue.shared.cs +3 -3
- package/Runtime/OrtValueTensor.shared.cs +1 -1
- package/Runtime/ProviderOptions.shared.cs +8 -5
- package/Runtime/RunOptions.shared.cs +12 -0
- package/Runtime/SessionOptions.shared.cs +5 -5
- package/Runtime/Tensors/ArrayTensorExtensions.shared.cs +1 -1
- package/Runtime/Training/NativeTrainingMethods.shared.cs +1 -1
- package/Runtime/Training/TrainingSession.shared.cs +2 -2
- package/package.json +1 -1
|
@@ -60,9 +60,9 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
60
60
|
/// <summary>
|
|
61
61
|
/// Extracts single precision number bit representation as uint
|
|
62
62
|
/// so its bits can be manipulated.
|
|
63
|
-
///
|
|
63
|
+
///
|
|
64
64
|
/// This API is the reverse of UInt32BitsToSingle().
|
|
65
|
-
///
|
|
65
|
+
///
|
|
66
66
|
/// </summary>
|
|
67
67
|
/// <param name="single">float value</param>
|
|
68
68
|
/// <returns></returns>
|
|
@@ -79,11 +79,11 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
79
79
|
/// <summary>
|
|
80
80
|
/// Needed because BitConverter impl is not available until
|
|
81
81
|
/// later versions. This API is the reverse of SingleToUInt32Bits().
|
|
82
|
-
///
|
|
82
|
+
///
|
|
83
83
|
/// For the exact bit representation of float see IEEE 754 standard for single precision.
|
|
84
|
-
///
|
|
84
|
+
///
|
|
85
85
|
/// </summary>
|
|
86
|
-
/// <param name="singleBits">bit representation of float either obtained from
|
|
86
|
+
/// <param name="singleBits">bit representation of float either obtained from
|
|
87
87
|
/// SingleToUInt32Bits or assembled using bitwise operators</param>
|
|
88
88
|
/// <returns></returns>
|
|
89
89
|
internal static float UInt32BitsToSingle(uint singleBits)
|
|
@@ -99,7 +99,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
99
99
|
/// <summary>
|
|
100
100
|
/// Converts single precision bits representation which can be obtained using
|
|
101
101
|
/// SingleToUInt32Bits() or manually constructed according to IEEE 754 standard.
|
|
102
|
-
///
|
|
102
|
+
///
|
|
103
103
|
/// </summary>
|
|
104
104
|
/// <param name="singleBits">bits representation of a single precision number (float)</param>
|
|
105
105
|
/// <returns></returns>
|
|
@@ -134,11 +134,11 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
/// <summary>
|
|
137
|
-
/// Creates float NaN with the given sign and fp16 significand shifted
|
|
137
|
+
/// Creates float NaN with the given sign and fp16 significand shifted << 54
|
|
138
138
|
/// </summary>
|
|
139
139
|
/// <param name="sign">true for negative</param>
|
|
140
140
|
/// <param name="significand">should be shifted 54 bits left before calling the function
|
|
141
|
-
/// so only 8 bits of
|
|
141
|
+
/// so only 8 bits of significand remains</param>
|
|
142
142
|
/// <returns></returns>
|
|
143
143
|
internal static float CreateSingleNaN(bool sign, ulong significand)
|
|
144
144
|
{
|
|
@@ -177,8 +177,8 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
177
177
|
/// do not have to be copied to be passed to native memory but simply pinned and read by native code. Thus,
|
|
178
178
|
/// one can create a Tensor on top of an array of these structures and feed it directly to Onnxruntime library.
|
|
179
179
|
/// Binary wise, it is the same as ushort[] (uint16_t in C++). However, we would like a separate type for type dispatching.
|
|
180
|
-
///
|
|
181
|
-
/// The implementation is derived from
|
|
180
|
+
///
|
|
181
|
+
/// The implementation is derived from
|
|
182
182
|
/// https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Half.cs,7895d5942d33f974
|
|
183
183
|
/// </summary>
|
|
184
184
|
[StructLayout(LayoutKind.Sequential)]
|
|
@@ -215,6 +215,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
215
215
|
|
|
216
216
|
private const ushort OneBits = 0x3C00;
|
|
217
217
|
|
|
218
|
+
// Minimum positive normalized value. It is corresponding to numeric_limits<float16>::min() in C++.
|
|
218
219
|
private const ushort EpsilonBits = 0x0400;
|
|
219
220
|
|
|
220
221
|
private const ushort PositiveInfinityBits = 0x7C00;
|
|
@@ -238,7 +239,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
238
239
|
/// <summary>
|
|
239
240
|
/// Float16 Epsilon value
|
|
240
241
|
/// </summary>
|
|
241
|
-
public static Float16 Epsilon => new Float16(EpsilonBits); //
|
|
242
|
+
public static Float16 Epsilon => new Float16(EpsilonBits); // 0.00006103515625
|
|
242
243
|
|
|
243
244
|
/// <summary>
|
|
244
245
|
/// Float16 Pi value
|
|
@@ -248,17 +249,17 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
248
249
|
/// <summary>
|
|
249
250
|
/// Float16 Positive Infinity value
|
|
250
251
|
/// </summary>
|
|
251
|
-
public static Float16 PositiveInfinity => new Float16(PositiveInfinityBits);
|
|
252
|
+
public static Float16 PositiveInfinity => new Float16(PositiveInfinityBits);
|
|
252
253
|
|
|
253
254
|
/// <summary>
|
|
254
255
|
/// Float16 Negative Infinity value
|
|
255
256
|
/// </summary>
|
|
256
|
-
public static Float16 NegativeInfinity => new Float16(NegativeInfinityBits);
|
|
257
|
+
public static Float16 NegativeInfinity => new Float16(NegativeInfinityBits);
|
|
257
258
|
|
|
258
259
|
/// <summary>
|
|
259
260
|
/// Float16 NaN
|
|
260
261
|
/// </summary>
|
|
261
|
-
public static Float16 NaN => new Float16(NegativeQNaNBits); //
|
|
262
|
+
public static Float16 NaN => new Float16(NegativeQNaNBits); // Same as System.Half.NaN
|
|
262
263
|
|
|
263
264
|
/// <summary>
|
|
264
265
|
/// Float16 Zero value
|
|
@@ -276,14 +277,14 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
276
277
|
public static Float16 NegativeZero => new Float16(NegativeZeroBits); // -0.0
|
|
277
278
|
|
|
278
279
|
/// <summary>
|
|
279
|
-
/// Float16
|
|
280
|
+
/// Float16 Lowest value
|
|
280
281
|
/// </summary>
|
|
281
|
-
public static Float16 MinValue => new Float16(MinValueBits); //
|
|
282
|
+
public static Float16 MinValue => new Float16(MinValueBits); // -65504.0
|
|
282
283
|
|
|
283
284
|
/// <summary>
|
|
284
285
|
/// Float16 Max value
|
|
285
286
|
/// </summary>
|
|
286
|
-
public static Float16 MaxValue => new Float16(MaxValueBits); //
|
|
287
|
+
public static Float16 MaxValue => new Float16(MaxValueBits); // 65504.0
|
|
287
288
|
|
|
288
289
|
/// <summary>
|
|
289
290
|
/// float16 representation bits
|
|
@@ -348,7 +349,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
348
349
|
|
|
349
350
|
/// <summary>
|
|
350
351
|
/// Compares values of two Float16
|
|
351
|
-
///
|
|
352
|
+
///
|
|
352
353
|
/// </summary>
|
|
353
354
|
/// <param name="left">left hand side</param>
|
|
354
355
|
/// <param name="right">right hand side</param>
|
|
@@ -376,7 +377,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
376
377
|
|
|
377
378
|
/// <summary>
|
|
378
379
|
/// Compares values of two Float16
|
|
379
|
-
///
|
|
380
|
+
///
|
|
380
381
|
/// </summary>
|
|
381
382
|
/// <param name="left">left hand side</param>
|
|
382
383
|
/// <param name="right">right hand side</param>
|
|
@@ -388,7 +389,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
388
389
|
|
|
389
390
|
/// <summary>
|
|
390
391
|
/// Compares values of two Float16
|
|
391
|
-
///
|
|
392
|
+
///
|
|
392
393
|
/// </summary>
|
|
393
394
|
/// <param name="left">left hand side</param>
|
|
394
395
|
/// <param name="right">right hand side</param>
|
|
@@ -416,12 +417,11 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
416
417
|
|
|
417
418
|
/// <summary>
|
|
418
419
|
/// Compares values of two Float16
|
|
419
|
-
///
|
|
420
420
|
/// </summary>
|
|
421
421
|
/// <param name="left">left hand side</param>
|
|
422
422
|
/// <param name="right">right hand side</param>
|
|
423
423
|
/// <returns>returns true if left is greater or equal than right according to IEEE</returns>
|
|
424
|
-
/// <inheritdoc
|
|
424
|
+
/// <inheritdoc />
|
|
425
425
|
public static bool operator >=(Float16 left, Float16 right)
|
|
426
426
|
{
|
|
427
427
|
return right <= left;
|
|
@@ -430,7 +430,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
430
430
|
/// <summary>
|
|
431
431
|
/// Compares values of two Float16 for binary equality.
|
|
432
432
|
/// If either of the values is NaN, this will return false.
|
|
433
|
-
///
|
|
433
|
+
///
|
|
434
434
|
/// </summary>
|
|
435
435
|
/// <param name="left">left hand side</param>
|
|
436
436
|
/// <param name="right">right hand side</param>
|
|
@@ -480,7 +480,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
480
480
|
/// <summary>
|
|
481
481
|
/// Determines whether the specified value is NaN.
|
|
482
482
|
/// </summary>
|
|
483
|
-
///
|
|
483
|
+
///
|
|
484
484
|
/// <param name="value">Float16 instance</param>
|
|
485
485
|
/// <returns>true if the value is not a number</returns>
|
|
486
486
|
public static bool IsNaN(Float16 value)
|
|
@@ -492,7 +492,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
492
492
|
/// Determines whether the specified value is negative.
|
|
493
493
|
/// </summary>
|
|
494
494
|
/// <param name="value">Float16 instance</param>
|
|
495
|
-
/// <returns>true if the value is negative</returns
|
|
495
|
+
/// <returns>true if the value is negative</returns>
|
|
496
496
|
public static bool IsNegative(Float16 value)
|
|
497
497
|
{
|
|
498
498
|
return (short)(value.value) < 0;
|
|
@@ -501,7 +501,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
501
501
|
/// <summary>
|
|
502
502
|
/// Determines whether the specified value is negative infinity.
|
|
503
503
|
/// </summary>
|
|
504
|
-
///
|
|
504
|
+
///
|
|
505
505
|
/// <param name="value">Float16 instance</param>
|
|
506
506
|
/// <returns>true if the value is negative infinity</returns>
|
|
507
507
|
public static bool IsNegativeInfinity(Float16 value)
|
|
@@ -550,7 +550,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
550
550
|
/// <summary>
|
|
551
551
|
/// Compares this object to another object, returning an integer that indicates the relationship.
|
|
552
552
|
/// </summary>
|
|
553
|
-
///
|
|
553
|
+
///
|
|
554
554
|
/// <param name="obj">Object to compare to</param>
|
|
555
555
|
/// <returns>A value less than zero if this is less than <paramref name="obj"/>,
|
|
556
556
|
/// zero if this is equal to <paramref name="obj"/>, or a value greater than zero
|
|
@@ -571,7 +571,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
571
571
|
/// </summary>
|
|
572
572
|
/// <param name="other">Object to compare to</param>
|
|
573
573
|
/// <returns>A value less than zero if this is less than <paramref name="other"/>,
|
|
574
|
-
/// zero if this is equal to <paramref name="other"/>,
|
|
574
|
+
/// zero if this is equal to <paramref name="other"/>,
|
|
575
575
|
/// or a value greater than zero if this is greater than <paramref name="other"/>.</returns>
|
|
576
576
|
public int CompareTo(Float16 other)
|
|
577
577
|
{
|
|
@@ -865,10 +865,13 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
865
865
|
private const ushort PositiveQNaNBits = 0x7FC1;
|
|
866
866
|
private const ushort NegativeQNaNBits = 0xFFC1;
|
|
867
867
|
|
|
868
|
+
// Lowest finite value. It is corresponding to numeric_limits<BFloat16>::lowest() in C++.
|
|
868
869
|
private const ushort MinValueBits = 0xFF7F; // 1b0_11111110_1111111
|
|
870
|
+
|
|
869
871
|
private const ushort MaxValueBits = 0x7F7F; // 0b0_11111110_1111111
|
|
870
872
|
|
|
871
|
-
|
|
873
|
+
// Minimum positive normalized value. It is corresponding to numeric_limits<BFloat16>::min() in C++.
|
|
874
|
+
private const ushort EpsilonBits = 0x0080;
|
|
872
875
|
|
|
873
876
|
private const ushort PiBits = 0x4049; // 0b0_10000000_1001001
|
|
874
877
|
|
|
@@ -900,7 +903,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
900
903
|
/// <summary>
|
|
901
904
|
/// BFloat16 NaN
|
|
902
905
|
/// </summary>
|
|
903
|
-
public static BFloat16 NaN => new BFloat16(NegativeQNaNBits);
|
|
906
|
+
public static BFloat16 NaN => new BFloat16(NegativeQNaNBits); // .Net has no BFloat16. Follow Float16 style.
|
|
904
907
|
|
|
905
908
|
/// <summary>
|
|
906
909
|
/// BFloat16 Positive Zero
|
|
@@ -920,13 +923,13 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
920
923
|
/// <summary>
|
|
921
924
|
/// BFloat16 Min value
|
|
922
925
|
/// </summary>
|
|
923
|
-
public static BFloat16 MinValue => new BFloat16(MinValueBits); //
|
|
926
|
+
public static BFloat16 MinValue => new BFloat16(MinValueBits); // -3.38953139e38
|
|
924
927
|
|
|
925
928
|
/// <summary>
|
|
926
929
|
/// BFloat16 Max value
|
|
927
930
|
/// </summary>
|
|
928
931
|
|
|
929
|
-
public static BFloat16 MaxValue => new BFloat16(MaxValueBits); //
|
|
932
|
+
public static BFloat16 MaxValue => new BFloat16(MaxValueBits); // 3.38953139e38
|
|
930
933
|
|
|
931
934
|
/// <summary>
|
|
932
935
|
/// bfloat16 representation bits
|
|
@@ -1052,7 +1055,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
1052
1055
|
/// <summary>
|
|
1053
1056
|
/// Compares values of two BFloat16 for binary equality.
|
|
1054
1057
|
/// If either of the values is NaN, this will return false.
|
|
1055
|
-
///
|
|
1058
|
+
///
|
|
1056
1059
|
/// </summary>
|
|
1057
1060
|
/// <param name="left">left hand side</param>
|
|
1058
1061
|
/// <param name="right">right hand side</param>
|
|
@@ -1103,7 +1106,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
1103
1106
|
/// <summary>
|
|
1104
1107
|
/// Determines whether the specified value is NaN.
|
|
1105
1108
|
/// </summary>
|
|
1106
|
-
///
|
|
1109
|
+
///
|
|
1107
1110
|
/// <param name="value">BFloat16 instance</param>
|
|
1108
1111
|
/// <returns>true if the value is not a number</returns>
|
|
1109
1112
|
public static bool IsNaN(BFloat16 value)
|
|
@@ -1115,7 +1118,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
1115
1118
|
/// Determines whether the specified value is negative.
|
|
1116
1119
|
/// </summary>
|
|
1117
1120
|
/// <param name="value">BFloat16 instance</param>
|
|
1118
|
-
/// <returns>true if the value is negative</returns
|
|
1121
|
+
/// <returns>true if the value is negative</returns>
|
|
1119
1122
|
public static bool IsNegative(BFloat16 value)
|
|
1120
1123
|
{
|
|
1121
1124
|
return (short)(value.value) < 0;
|
|
@@ -1124,7 +1127,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
1124
1127
|
/// <summary>
|
|
1125
1128
|
/// Determines whether the specified value is negative infinity.
|
|
1126
1129
|
/// </summary>
|
|
1127
|
-
///
|
|
1130
|
+
///
|
|
1128
1131
|
/// <param name="value">BFloat16 instance</param>
|
|
1129
1132
|
/// <returns>true if the value is negative infinity</returns>
|
|
1130
1133
|
public static bool IsNegativeInfinity(BFloat16 value)
|
|
@@ -1171,7 +1174,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
1171
1174
|
/// <summary>
|
|
1172
1175
|
/// Compares this object to another object, returning an integer that indicates the relationship.
|
|
1173
1176
|
/// </summary>
|
|
1174
|
-
///
|
|
1177
|
+
///
|
|
1175
1178
|
/// <param name="obj">Object to compare to</param>
|
|
1176
1179
|
/// <returns>A value less than zero if this is less than <paramref name="obj"/>,
|
|
1177
1180
|
/// zero if this is equal to <paramref name="obj"/>, or a value greater than zero
|
|
@@ -1192,7 +1195,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
1192
1195
|
/// </summary>
|
|
1193
1196
|
/// <param name="other">Object to compare to</param>
|
|
1194
1197
|
/// <returns>A value less than zero if this is less than <paramref name="other"/>,
|
|
1195
|
-
/// zero if this is equal to <paramref name="other"/>,
|
|
1198
|
+
/// zero if this is equal to <paramref name="other"/>,
|
|
1196
1199
|
/// or a value greater than zero if this is greater than <paramref name="other"/>.</returns>
|
|
1197
1200
|
public int CompareTo(BFloat16 other)
|
|
1198
1201
|
{
|
|
@@ -1369,4 +1372,4 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
1369
1372
|
|
|
1370
1373
|
#endregion
|
|
1371
1374
|
}
|
|
1372
|
-
}
|
|
1375
|
+
}
|
|
@@ -313,7 +313,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
313
313
|
/// <summary>
|
|
314
314
|
/// This fetches bound outputs after running the model with RunWithBinding()
|
|
315
315
|
/// </summary>
|
|
316
|
-
/// <returns>IDisposableReadOnlyCollection
|
|
316
|
+
/// <returns>IDisposableReadOnlyCollection{OrtValue}</returns>
|
|
317
317
|
public IDisposableReadOnlyCollection<OrtValue> GetOutputValues()
|
|
318
318
|
{
|
|
319
319
|
var ortValues = GetOutputOrtValues();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
using System;
|
|
4
|
+
using System.Runtime.InteropServices;
|
|
5
|
+
|
|
6
|
+
namespace Microsoft.ML.OnnxRuntime
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
/// Represents Lora Adapter in memory
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class OrtLoraAdapter : SafeHandle
|
|
12
|
+
{
|
|
13
|
+
/// <summary>
|
|
14
|
+
/// Creates an instance of OrtLoraAdapter from file.
|
|
15
|
+
/// The adapter file is memory mapped. If allocator parameter
|
|
16
|
+
/// is provided, then lora parameters are copied to the memory
|
|
17
|
+
/// allocated by the specified allocator.
|
|
18
|
+
/// </summary>
|
|
19
|
+
/// <param name="adapterPath">path to the adapter file</param>
|
|
20
|
+
/// <param name="ortAllocator">optional allocator, can be null, must be a device allocator</param>
|
|
21
|
+
/// <returns>New instance of LoraAdapter</returns>
|
|
22
|
+
public static OrtLoraAdapter Create(string adapterPath, OrtAllocator ortAllocator)
|
|
23
|
+
{
|
|
24
|
+
var platformPath = NativeOnnxValueHelper.GetPlatformSerializedString(adapterPath);
|
|
25
|
+
var allocatorHandle = (ortAllocator != null) ? ortAllocator.Pointer : IntPtr.Zero;
|
|
26
|
+
NativeApiStatus.VerifySuccess(NativeMethods.CreateLoraAdapter(platformPath, allocatorHandle,
|
|
27
|
+
out IntPtr adapterHandle));
|
|
28
|
+
return new OrtLoraAdapter(adapterHandle);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
/// Creates an instance of OrtLoraAdapter from an array of bytes. The API
|
|
33
|
+
/// makes a copy of the bytes internally.
|
|
34
|
+
/// </summary>
|
|
35
|
+
/// <param name="bytes">array of bytes containing valid LoraAdapter format</param>
|
|
36
|
+
/// <param name="ortAllocator">optional device allocator or null</param>
|
|
37
|
+
/// <returns>new instance of LoraAdapter</returns>
|
|
38
|
+
public static OrtLoraAdapter Create(byte[] bytes, OrtAllocator ortAllocator)
|
|
39
|
+
{
|
|
40
|
+
var allocatorHandle = (ortAllocator != null) ? ortAllocator.Pointer : IntPtr.Zero;
|
|
41
|
+
NativeApiStatus.VerifySuccess(NativeMethods.CreateLoraAdapterFromArray(bytes,
|
|
42
|
+
new UIntPtr((uint)bytes.Length), allocatorHandle, out IntPtr adapterHandle));
|
|
43
|
+
return new OrtLoraAdapter(adapterHandle);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
internal OrtLoraAdapter(IntPtr adapter)
|
|
47
|
+
: base(adapter, true)
|
|
48
|
+
{
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
internal IntPtr Handle
|
|
52
|
+
{
|
|
53
|
+
get
|
|
54
|
+
{
|
|
55
|
+
return handle;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#region SafeHandle
|
|
60
|
+
|
|
61
|
+
/// <summary>
|
|
62
|
+
/// Overrides SafeHandle.IsInvalid
|
|
63
|
+
/// </summary>
|
|
64
|
+
/// <value>returns true if handle is equal to Zero</value>
|
|
65
|
+
public override bool IsInvalid { get { return handle == IntPtr.Zero; } }
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
/// Overrides SafeHandle.ReleaseHandle() to properly dispose of
|
|
69
|
+
/// the native instance of OrtLoraAdapter
|
|
70
|
+
/// </summary>
|
|
71
|
+
/// <returns>always returns true</returns>
|
|
72
|
+
protected override bool ReleaseHandle()
|
|
73
|
+
{
|
|
74
|
+
NativeMethods.ReleaseLoraAdapter(handle);
|
|
75
|
+
handle = IntPtr.Zero;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
#endregion
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -236,12 +236,12 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
236
236
|
|
|
237
237
|
/// <summary>
|
|
238
238
|
/// Fetch string tensor element buffer pointer at the specified index,
|
|
239
|
-
/// convert/copy to UTF-16 char[] and return a ReadOnlyMemory
|
|
239
|
+
/// convert/copy to UTF-16 char[] and return a ReadOnlyMemory{char} instance.
|
|
240
240
|
///
|
|
241
241
|
/// Obtain TensorTypeAndShape to get shape and element count.
|
|
242
242
|
/// </summary>
|
|
243
243
|
/// <param name="index">flat string tensor element index</param>
|
|
244
|
-
/// <returns>ReadOnlyMemory
|
|
244
|
+
/// <returns>ReadOnlyMemory{char} backed by a managed char[]. Its lifespan is not
|
|
245
245
|
/// tied to the native buffer of OrtValue.</returns>
|
|
246
246
|
public ReadOnlyMemory<char> GetStringElementAsMemory(int index)
|
|
247
247
|
{
|
|
@@ -845,7 +845,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
845
845
|
/// Note, this is different from creating an OrtValue from other primitive data types
|
|
846
846
|
/// where memory is pinned (if necessary) and the OrtValue points to that chunk of memory.
|
|
847
847
|
/// </summary>
|
|
848
|
-
/// <param name="tensor">Tensor
|
|
848
|
+
/// <param name="tensor">Tensor{string}</param>
|
|
849
849
|
/// <returns>A disposable OrtValue instance</returns>
|
|
850
850
|
/// <exception cref="OnnxRuntimeException"></exception>
|
|
851
851
|
public static OrtValue CreateFromStringTensor(Tensor<string> tensor)
|
|
@@ -85,7 +85,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
85
85
|
/// This helper class owns the underlying OrtValue that is assumed to be a Tensor,
|
|
86
86
|
/// it does not support any other ortValues and caches Tensor properties.
|
|
87
87
|
///
|
|
88
|
-
/// It is easy to expose as a Tensor
|
|
88
|
+
/// It is easy to expose as a Tensor{T} as DenseTensor can take Memory Mapping from
|
|
89
89
|
/// this.
|
|
90
90
|
///
|
|
91
91
|
/// This class is disposable because of the MemoryManager inheritance. Because this class
|
|
@@ -318,9 +318,9 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
/// <summary>
|
|
321
|
-
/// CoreML flags for use with SessionOptions
|
|
321
|
+
/// CoreML flags for use with SessionOptions.
|
|
322
|
+
/// See https://github.com/microsoft/onnxruntime/blob/main/include/onnxruntime/core/providers/coreml/coreml_provider_factory.h
|
|
322
323
|
/// </summary>
|
|
323
|
-
/// <see cref="https://github.com/microsoft/onnxruntime/blob/main/include/onnxruntime/core/providers/coreml/coreml_provider_factory.h"/>
|
|
324
324
|
[Flags]
|
|
325
325
|
public enum CoreMLFlags : uint
|
|
326
326
|
{
|
|
@@ -328,13 +328,16 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
328
328
|
COREML_FLAG_USE_CPU_ONLY = 0x001,
|
|
329
329
|
COREML_FLAG_ENABLE_ON_SUBGRAPH = 0x002,
|
|
330
330
|
COREML_FLAG_ONLY_ENABLE_DEVICE_WITH_ANE = 0x004,
|
|
331
|
-
|
|
331
|
+
COREML_FLAG_ONLY_ALLOW_STATIC_INPUT_SHAPES = 0x008,
|
|
332
|
+
COREML_FLAG_CREATE_MLPROGRAM = 0x010,
|
|
333
|
+
COREML_FLAG_USE_CPU_AND_GPU = 0x020,
|
|
334
|
+
COREML_FLAG_LAST = COREML_FLAG_USE_CPU_AND_GPU,
|
|
332
335
|
}
|
|
333
336
|
|
|
334
337
|
/// <summary>
|
|
335
|
-
/// NNAPI flags for use with SessionOptions
|
|
338
|
+
/// NNAPI flags for use with SessionOptions.
|
|
339
|
+
/// See https://github.com/microsoft/onnxruntime/blob/main/include/onnxruntime/core/providers/nnapi/nnapi_provider_factory.h
|
|
336
340
|
/// </summary>
|
|
337
|
-
/// <see cref="https://github.com/microsoft/onnxruntime/blob/main/include/onnxruntime/core/providers/nnapi/nnapi_provider_factory.h"/>
|
|
338
341
|
[Flags]
|
|
339
342
|
public enum NnapiFlags
|
|
340
343
|
{
|
|
@@ -129,6 +129,18 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
129
129
|
NativeApiStatus.VerifySuccess(NativeMethods.OrtAddRunConfigEntry(handle, utf8Key, utf8Value));
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
/// <summary>
|
|
133
|
+
/// Appends the specified lora adapter to the list of active lora adapters
|
|
134
|
+
/// for this RunOptions instance. All run calls with this instant will
|
|
135
|
+
/// make use of the activated Lora Adapters. An adapter is considered active
|
|
136
|
+
/// if it is added to RunOptions that are used during Run() calls.
|
|
137
|
+
/// </summary>
|
|
138
|
+
/// <param name="loraAdapter">Lora adapter instance</param>
|
|
139
|
+
public void AddActiveLoraAdapter(OrtLoraAdapter loraAdapter)
|
|
140
|
+
{
|
|
141
|
+
NativeApiStatus.VerifySuccess(NativeMethods.OrtRunOptionsAddActiveLoraAdapter(handle, loraAdapter.Handle));
|
|
142
|
+
}
|
|
143
|
+
|
|
132
144
|
#region SafeHandle
|
|
133
145
|
/// <summary>
|
|
134
146
|
/// Overrides SafeHandle.ReleaseHandle() to properly dispose of
|
|
@@ -780,8 +780,8 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
780
780
|
private int _logVerbosityLevel = 0;
|
|
781
781
|
|
|
782
782
|
/// <summary>
|
|
783
|
-
|
|
784
|
-
|
|
783
|
+
/// Sets the number of threads used to parallelize the execution within nodes
|
|
784
|
+
/// A value of 0 means ORT will pick a default
|
|
785
785
|
/// </summary>
|
|
786
786
|
/// <value>returns _intraOpNumThreads value</value>
|
|
787
787
|
public int IntraOpNumThreads
|
|
@@ -799,9 +799,9 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
799
799
|
private int _intraOpNumThreads = 0; // set to what is set in C++ SessionOptions by default;
|
|
800
800
|
|
|
801
801
|
/// <summary>
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
802
|
+
/// Sets the number of threads used to parallelize the execution of the graph (across nodes)
|
|
803
|
+
/// If sequential execution is enabled this value is ignored
|
|
804
|
+
/// A value of 0 means ORT will pick a default
|
|
805
805
|
/// </summary>
|
|
806
806
|
/// <value>returns _interOpNumThreads value</value>
|
|
807
807
|
public int InterOpNumThreads
|
|
@@ -15,7 +15,7 @@ using System;
|
|
|
15
15
|
namespace Microsoft.ML.OnnxRuntime.Tensors
|
|
16
16
|
{
|
|
17
17
|
/// <summary>
|
|
18
|
-
/// A static class that houses static DenseTensor
|
|
18
|
+
/// A static class that houses static DenseTensor{T} extension methods
|
|
19
19
|
/// </summary>
|
|
20
20
|
public static class ArrayTensorExtensions
|
|
21
21
|
{
|
|
@@ -76,7 +76,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
76
76
|
DOrtGetApi OrtGetApi = (DOrtGetApi)Marshal.GetDelegateForFunctionPointer(NativeMethods.OrtGetApiBase().GetApi, typeof(DOrtGetApi));
|
|
77
77
|
#endif
|
|
78
78
|
|
|
79
|
-
const uint ORT_API_VERSION =
|
|
79
|
+
const uint ORT_API_VERSION = 20;
|
|
80
80
|
#if NETSTANDARD2_0
|
|
81
81
|
IntPtr ortApiPtr = OrtGetApi(ORT_API_VERSION);
|
|
82
82
|
api_ = (OrtApi)Marshal.PtrToStructure(ortApiPtr, typeof(OrtApi));
|
|
@@ -295,7 +295,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
295
295
|
/// <code>
|
|
296
296
|
/// using OrtValue x = OrtValue.CreateTensorValueFromMemory(...);
|
|
297
297
|
/// using OrtValue label = OrtValue.CreateTensorValueFromMemory(...);
|
|
298
|
-
/// List
|
|
298
|
+
/// List{OrtValue} inputValues = new List{OrtValue} { x, label };
|
|
299
299
|
/// using (var loss = trainingSession.TrainStep(inputValues))
|
|
300
300
|
/// {
|
|
301
301
|
/// // process output values
|
|
@@ -420,7 +420,7 @@ namespace Microsoft.ML.OnnxRuntime
|
|
|
420
420
|
/// <code>
|
|
421
421
|
/// using OrtValue x = OrtValue.CreateTensorValueFromMemory(...);
|
|
422
422
|
/// using OrtValue label = OrtValue.CreateTensorValueFromMemory(...);
|
|
423
|
-
/// List
|
|
423
|
+
/// List{OrtValue} inputValues = new List{OrtValue} { x, label };
|
|
424
424
|
/// using (var loss = trainingSession.EvalSteps(inputValues))
|
|
425
425
|
/// {
|
|
426
426
|
/// // process output values
|