protected void DisposeAllocatedBuffer(ITensorData buffer) { for (int i = m_AllocatedBuffers.Count - 1; i >= 0; i--) { if (m_AllocatedBuffers[i].buffer == buffer) { m_AllocatedBuffers.RemoveAt(i); } } buffer.Dispose(); }
private void PinToDevice(ITensorData onDevice, bool disposeUnpinned = true) { Assert.IsTrue(onDevice?.GetMaxCount() >= length || onDevice == null); if (m_TensorAllocator != null) { m_TensorAllocator.Repin(this, onDevice, m_TensorOnDevice, disposeUnpinned); } else if (disposeUnpinned) { m_TensorOnDevice?.Dispose(); } m_TensorOnDevice = onDevice; }
/// <summary> /// Dispose Tensor and associated memories. /// </summary> public virtual void Dispose() { m_Disposing = true; if (m_TensorAllocator != null) { m_TensorAllocator.Release(this, true); } else if (m_TensorOnDevice != null) { //;;UnityEngine.D.Log("DISPOSE " + name + " " + shape + " @ " + m_TensorOnDevice.GetType().Name); m_TensorOnDevice.Dispose(); } m_Cache = null; m_CacheIsDirty = false; m_TensorOnDevice = null; m_TensorAllocator = null; m_Disposing = false; }