/// <summary> /// Queries the InferenceEngine for the value of a variable in the graph given its name. /// Only works with int32 Tensors with zero dimensions containing a unique element. /// If the node was not found or could not be retrieved, the value -1 will be returned. /// </summary> /// <param name="name">The name of the Tensor variable</param> /// <returns>The value of the scalar variable in the model. (-1 if not found)</returns> private int GetIntScalar(string name) { var outputs = new Tensor[] { new Tensor() { Name = name, ValueType = Tensor.TensorType.Integer, Shape = new long[] { }, Data = new long[1] }, }; try { _engine.ExecuteGraph(new Tensor[0], outputs); } catch { return(-1); } return((outputs[0].Data as int[])[0]); }
/// <summary> /// Queries the InferenceEngine for the value of a variable in the graph given its name. /// Only works with int32 Tensors with zero dimensions containing a unique element. /// If the node was not found or could not be retrieved, the value -1 will be returned. /// </summary> /// <param name="name">The name of the Tensor variable</param> /// <returns>The value of the scalar variable in the model. (-1 if not found)</returns> private int GetIntScalar(string name) { var outputs = new TensorProxy[] { new TensorProxy() { Name = name, ValueType = TensorProxy.TensorType.Integer, Shape = new long[] { }, Data = new Tensor(1, 1) }, }; try { _engine.ExecuteGraph(new TensorProxy[0], outputs); } catch (Exception ex) { UnityEngine.Debug.LogError($"Failed to execute GetIntScalar()\n{ex}"); return(-1); } return((int)outputs[0].Data[0]); }