/// <summary>
        /// Create a copy of the current Tensor, actively syncing there data in a blocking way.
        /// </summary>
        public Tensor DeepCopy()
        {
            // @TODO: use Tensor allocator
            var copy = new Tensor(shape, $"clone of {name}");

            if (m_TensorOnDevice is ICloneable)
            {
                UploadIfDirty();
                var copyOfTensorData = (m_TensorOnDevice as ICloneable).Clone() as ITensorData;
                copy.PinToDeviceAndDownloadFromIt(copyOfTensorData);
            }
            else
            {
                PrepareCacheForAccess();
                copy.PrepareCacheForAccess();
                Array.Copy(m_Cache, 0, copy.m_Cache, 0, length);
            }

            return(copy);
        }
Ejemplo n.º 2
0
 public virtual void FlushSchedule(bool blocking)
 {
     // force execution of scheduled ops by requesting results of the intermedite tensor from the device
     m_SyncTensor.PrepareCacheForAccess(blocking);
 }