/// <summary> /// Ctor /// </summary> /// <param name="name">Name of the output value</param> /// <param name="value">Managed object created to represent output value, such as DenseTensor<T> /// List or Dictionary /// </param> /// <param name="onnxValueType">Use this to decide what you want to call to fetch data, AsTensor(), AsDictionary() /// or AsEnumerable()</param> /// <param name="elementType">Tensor element type if value type is a Tensor</param> /// <param name="ortValueHolder">Object that holds native resources. /// Typically, this is an output OrtValue that holds native memory where Tensor is mapped but may also be /// other things that would need to be disposed by this instance depending on how IOrtValueOwner is implemented.</param> private DisposableNamedOnnxValue(string name, Object value, OnnxValueType onnxValueType, TensorElementType elementType, IOrtValueOwner ortValueHolder) : base(name, value) { _ortValueHolder = ortValueHolder; ValueType = onnxValueType; ElementType = elementType; }
/// <summary> /// IDisposable implementation /// </summary> /// <param name="disposing">true if invoked by Dispose()</param> protected virtual void Dispose(bool disposing) { if (_disposed) { return; } // dispose managed state (managed objects). if (disposing) { // _ortValueHolder can be null when no native memory is involved if (_ortValueHolder != null) { _ortValueHolder.Dispose(); _ortValueHolder = null; } } _disposed = true; }