/// <summary> /// Return the numeric (double) based training parameter. /// </summary> /// <param name="key">Specifies the key of the value to get.</param> /// <returns>The double based value is returned.</returns> public double GetTrainingParameter(OrtTrainingNumericParameter key) { string str = null; var allocator = OrtAllocator.DefaultInstance; IntPtr valHandle = IntPtr.Zero; NativeApiStatus.VerifySuccess(NativeMethodsTraining.OrtGetNumericParameter(_nativeHandle, key, allocator.Pointer, out valHandle)); using (var ortAllocation = new OrtMemoryAllocation(allocator, valHandle, 0)) { str = NativeOnnxValueHelper.StringFromNativeUtf8(valHandle); } return(double.Parse(str)); }
/// <summary> /// Returns the OrtValue at a given index as well as its name. /// </summary> /// <param name="nIdx">Specifies the index to get.</param> /// <param name="strName">Returns the name of the OrtValue.</param> /// <returns>The OrtValue at the index is returned.</returns> public OrtValue GetAt(int nIdx, out string strName) { IntPtr valData; var allocator = OrtAllocator.DefaultInstance; IntPtr valName; NativeApiStatus.VerifySuccess(NativeMethodsTraining.OrtGetAt(_nativeHandle, nIdx, out valData, allocator.Pointer, out valName)); using (var ortAllocation = new OrtMemoryAllocation(allocator, valName, 0)) { strName = NativeOnnxValueHelper.StringFromNativeUtf8(valName); } return(new OrtValue(valData, false)); }