com.github.asus4.onnxruntime 0.1.14 → 0.2.0

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.
Files changed (42) hide show
  1. package/Plugins/Android/onnxruntime-android.aar +0 -0
  2. package/Plugins/Linux/x64/libonnxruntime.so +0 -0
  3. package/Plugins/Windows/x64/onnxruntime.dll +0 -0
  4. package/Plugins/iOS~/onnxruntime.xcframework/Info.plist +6 -6
  5. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/coreml_provider_factory.h +4 -1
  6. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/onnxruntime_c_api.h +134 -19
  7. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/onnxruntime_cxx_api.h +18 -3
  8. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/onnxruntime_cxx_inline.h +68 -15
  9. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/onnxruntime_lite_custom_op.h +1119 -0
  10. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/onnxruntime_run_options_config_keys.h +19 -0
  11. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Headers/onnxruntime_session_options_config_keys.h +32 -9
  12. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/Info.plist +2 -2
  13. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/onnxruntime +0 -0
  14. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/coreml_provider_factory.h +4 -1
  15. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/onnxruntime_c_api.h +134 -19
  16. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/onnxruntime_cxx_api.h +18 -3
  17. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/onnxruntime_cxx_inline.h +68 -15
  18. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/onnxruntime_lite_custom_op.h +1119 -0
  19. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/onnxruntime_run_options_config_keys.h +19 -0
  20. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Headers/onnxruntime_session_options_config_keys.h +32 -9
  21. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/Info.plist +2 -2
  22. package/Plugins/iOS~/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.framework/onnxruntime +0 -0
  23. package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/{Headers → Versions/A/Headers}/coreml_provider_factory.h +4 -1
  24. package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/{Headers → Versions/A/Headers}/onnxruntime_c_api.h +134 -19
  25. package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/{Headers → Versions/A/Headers}/onnxruntime_cxx_api.h +18 -3
  26. package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/{Headers → Versions/A/Headers}/onnxruntime_cxx_inline.h +68 -15
  27. package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/Versions/A/Headers/onnxruntime_lite_custom_op.h +1119 -0
  28. package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/{Headers → Versions/A/Headers}/onnxruntime_run_options_config_keys.h +19 -0
  29. package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/{Headers → Versions/A/Headers}/onnxruntime_session_options_config_keys.h +32 -9
  30. package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/{Info.plist → Versions/A/Resources/Info.plist} +2 -2
  31. package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/{onnxruntime → Versions/A/onnxruntime} +0 -0
  32. package/Plugins/macOS/libonnxruntime.dylib +0 -0
  33. package/README.md +8 -8
  34. package/Runtime/AssemblyInfo.shared.cs +1 -11
  35. package/Runtime/NativeMethods.shared.cs +37 -2
  36. package/Runtime/OrtValue.shared.cs +38 -38
  37. package/Runtime/SessionOptions.shared.cs +14 -0
  38. package/Runtime/Training/NativeTrainingMethods.shared.cs +20 -2
  39. package/Runtime/Training/TrainingSession.shared.cs +107 -0
  40. package/package.json +1 -1
  41. /package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/{Headers → Versions/A/Headers}/cpu_provider_factory.h +0 -0
  42. /package/Plugins/iOS~/onnxruntime.xcframework/macos-arm64_x86_64/onnxruntime.framework/{Headers → Versions/A/Headers}/onnxruntime_float16.h +0 -0
@@ -282,6 +282,48 @@ namespace Microsoft.ML.OnnxRuntime
282
282
  }
283
283
  }
284
284
 
285
+ /// <summary>
286
+ /// This function performs a training step that computes the outputs of the training model and the gradients
287
+ /// of the trainable parameters for the given OrtValue inputs. The train step is performed based on the training model
288
+ /// that was provided to the training session.
289
+ /// The TrainStep method is equivalent of running forward propagation and backward propagation in a single
290
+ /// step.
291
+ /// The gradients computed are stored inside the training session state so they can be later consumed
292
+ /// by the OptimizerStep function.
293
+ /// The gradients can be lazily reset by invoking the LazyResetGrad function.
294
+ /// Example usage:
295
+ /// <code>
296
+ /// using OrtValue x = OrtValue.CreateTensorValueFromMemory(...);
297
+ /// using OrtValue label = OrtValue.CreateTensorValueFromMemory(...);
298
+ /// List<OrtValue> inputValues = new List<OrtValue> { x, label };
299
+ /// using (var loss = trainingSession.TrainStep(inputValues))
300
+ /// {
301
+ /// // process output values
302
+ /// }
303
+ /// </code>
304
+ /// </summary>
305
+ /// <param name="inputValues">Specify a collection of <see cref="OrtValue"/> that indicates the input values to the training model.</param>
306
+ /// <returns>Output Tensors in a Collection of NamedOnnxValue. User must dispose the output.</returns>
307
+ public IDisposableReadOnlyCollection<OrtValue> TrainStep(IReadOnlyCollection<OrtValue> inputValues)
308
+ {
309
+ IntPtr[] inputValuesArray = GetOrtValuesHandles(inputValues);
310
+ IntPtr[] outputValuesArray = new IntPtr[(int)_trainOutputCount];
311
+
312
+ NativeApiStatus.VerifySuccess(NativeTrainingMethods.OrtTrainStep(_nativeHandle, IntPtr.Zero, (UIntPtr)inputValues.Count,
313
+ inputValuesArray, (UIntPtr)_trainOutputCount, outputValuesArray));
314
+
315
+
316
+ var disposableHandles = new DisposableOrtValueHandleArray(outputValuesArray);
317
+ try
318
+ {
319
+ return CreateDisposableResult(disposableHandles);
320
+ }
321
+ finally
322
+ {
323
+ disposableHandles.Dispose();
324
+ }
325
+ }
326
+
285
327
  /// <summary>
286
328
  /// Convert native OrtValue handles to OrtValue instances
287
329
  /// in an exceptions safe manner.
@@ -370,6 +412,42 @@ namespace Microsoft.ML.OnnxRuntime
370
412
  inputValuesArray, (UIntPtr)outputValues.Count, outputValuesArray));
371
413
  }
372
414
 
415
+ /// <summary>
416
+ /// This function performs an eval step that computes the outputs of the eval model for the given inputs.
417
+ /// Inputs are expected to be of type OrtValue. The eval step is performed based on the eval model that was
418
+ /// provided to the training session.
419
+ /// Example usage:
420
+ /// <code>
421
+ /// using OrtValue x = OrtValue.CreateTensorValueFromMemory(...);
422
+ /// using OrtValue label = OrtValue.CreateTensorValueFromMemory(...);
423
+ /// List<OrtValue> inputValues = new List<OrtValue> { x, label };
424
+ /// using (var loss = trainingSession.EvalSteps(inputValues))
425
+ /// {
426
+ /// // process output values
427
+ /// }
428
+ /// </code>
429
+ /// </summary>
430
+ /// <param name="inputValues">Specify a collection of <see cref="OrtValue"/> that indicates the input values to the eval model.</param>
431
+ public IDisposableReadOnlyCollection<OrtValue> EvalStep(IReadOnlyCollection<OrtValue> inputValues)
432
+ {
433
+ IntPtr[] inputValuesArray = GetOrtValuesHandles(inputValues);
434
+ IntPtr[] outputValuesArray = new IntPtr[(int)_evalOutputCount];
435
+
436
+ NativeApiStatus.VerifySuccess(NativeTrainingMethods.OrtEvalStep(_nativeHandle, IntPtr.Zero, (UIntPtr)inputValues.Count,
437
+ inputValuesArray, (UIntPtr)_evalOutputCount, outputValuesArray));
438
+
439
+
440
+ var disposableHandles = new DisposableOrtValueHandleArray(outputValuesArray);
441
+ try
442
+ {
443
+ return CreateDisposableResult(disposableHandles);
444
+ }
445
+ finally
446
+ {
447
+ disposableHandles.Dispose();
448
+ }
449
+ }
450
+
373
451
 
374
452
  /// <summary>
375
453
  /// Sets the learning rate for this training session.
@@ -702,6 +780,35 @@ namespace Microsoft.ML.OnnxRuntime
702
780
  return valuesArray;
703
781
  }
704
782
 
783
+ private IntPtr[] GetOrtValuesHandles(IReadOnlyCollection<OrtValue> inputValues)
784
+ {
785
+ var valuesArray = new IntPtr[inputValues.Count];
786
+ for (int index = 0; index < inputValues.Count; ++index)
787
+ {
788
+ valuesArray[index] = inputValues.ElementAt(index).Handle;
789
+ }
790
+ return valuesArray;
791
+ }
792
+
793
+ private static IDisposableReadOnlyCollection<OrtValue> CreateDisposableResult(DisposableOrtValueHandleArray disposableHandles)
794
+ {
795
+ var outputValues = new DisposableList<OrtValue>(disposableHandles.Span.Length);
796
+ try
797
+ {
798
+ for (int i = 0; i < disposableHandles.Span.Length; i++)
799
+ {
800
+ outputValues.Add(new OrtValue(disposableHandles.Span[i]));
801
+ disposableHandles.Span[i] = IntPtr.Zero;
802
+ }
803
+ return outputValues;
804
+ }
805
+ catch (Exception)
806
+ {
807
+ outputValues.Dispose();
808
+ throw;
809
+ }
810
+ }
811
+
705
812
  private IntPtr[] ConvertNamesToUtf8(IReadOnlyCollection<string> names, DisposableList<IDisposable> cleanupList)
706
813
  {
707
814
  cleanupList.Capacity += names.Count;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.github.asus4.onnxruntime",
3
- "version": "0.1.14",
3
+ "version": "0.2.0",
4
4
  "displayName": "ONNX Runtime",
5
5
  "description": "ONNX Runtime Plugin for Unity",
6
6
  "keywords": [