private void errorFn(IntPtr colVal) { if (OnErrorFunction == null) { return; } List <DisposableNamedOnnxValue> rgVal = new List <DisposableNamedOnnxValue>(); List <string> rgNames = new List <string>(); OrtValueCollection col = new OrtValueCollection(colVal); int nCount = col.Count; for (int i = 0; i < nCount; i++) { string strName; OrtValue val = col.GetAt(i, out strName); rgVal.Add(DisposableNamedOnnxValue.CreateTensorFromOnnxValue(strName, val)); } OnErrorFunction(this, new ErrorFunctionArgs(rgVal)); // Clean-up the data used during this batch. foreach (IDisposable iDispose in m_rgCleanUpList) { iDispose.Dispose(); } m_rgCleanUpList.Clear(); }
private List<KeyValuePair<string, List<int>>> getTensorDefs(OrtValueCollection col) { List<KeyValuePair<string, List<int>>> rgDefs = new List<KeyValuePair<string, List<int>>>(); int nCount = col.Count; for (int i = 0; i < nCount; i++) { string strName; OrtValue val = col.GetAt(i, out strName); DisposableNamedOnnxValue shape = DisposableNamedOnnxValue.CreateTensorFromOnnxValue(strName, val); Tensor<long> shapet = shape.AsTensor<Int64>(); List<int> rgShape = new List<int>(); for (int j = 0; j < shapet.dimensions[0]; j++) { long nDim = shapet.GetValue(j); rgShape.Add((int)nDim); } rgDefs.Add(new KeyValuePair<string, List<int>>(strName, rgShape)); } return rgDefs; }