From 47e80cddd07a17679e105f1ad7e08921e71b8b8d Mon Sep 17 00:00:00 2001 From: Eli Belash Date: Tue, 27 Aug 2019 23:02:55 +0300 Subject: [PATCH] Status: Changed exception of Check(bool) to TensorflowException --- src/TensorFlowNET.Core/Status/Status.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/TensorFlowNET.Core/Status/Status.cs b/src/TensorFlowNET.Core/Status/Status.cs index 7d029e79..ce561f75 100644 --- a/src/TensorFlowNET.Core/Status/Status.cs +++ b/src/TensorFlowNET.Core/Status/Status.cs @@ -16,6 +16,7 @@ using System; using System.Runtime.CompilerServices; +using static Tensorflow.c_api; namespace Tensorflow { @@ -28,27 +29,28 @@ namespace Tensorflow /// /// Error message /// - public string Message => c_api.StringPiece(c_api.TF_Message(_handle)); + public string Message => c_api.StringPiece(TF_Message(_handle)); /// /// Error code /// - public TF_Code Code => c_api.TF_GetCode(_handle); + public TF_Code Code => TF_GetCode(_handle); public Status() { - _handle = c_api.TF_NewStatus(); + _handle = TF_NewStatus(); } public void SetStatus(TF_Code code, string msg) { - c_api.TF_SetStatus(_handle, code, msg); + TF_SetStatus(_handle, code, msg); } /// /// Check status /// Throw exception with error message if code != TF_OK /// + /// When the returned check is not TF_Code.TF_OK [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Check(bool throwException = false) { @@ -56,9 +58,7 @@ namespace Tensorflow { Console.WriteLine(Message); if (throwException) - { - throw new Exception(Message); - } + throw new TensorflowException(Message); } } @@ -68,6 +68,6 @@ namespace Tensorflow } protected override void DisposeUnmanagedResources(IntPtr handle) - => c_api.TF_DeleteStatus(handle); + => TF_DeleteStatus(handle); } } \ No newline at end of file