private void UploadIfDirty()
 {
     if (m_CacheIsDirty && m_TensorOnDevice != null)
     {
         m_TensorOnDevice.Upload(m_Cache, shape);
     }
     m_CacheIsDirty = false;
 }
 /// <summary>
 /// Create a Tensor with specified `shape`, an array of data `srcData` and an optional debug `name`.
 /// `srcData` must be of size `shape.length`.
 /// </summary>
 public Tensor(TensorShape shape, float[] srcData, string name = "")
 {
     this.name        = name;
     this.shape       = shape;
     m_TensorOnDevice = new ArrayTensorData(shape);
     Assert.IsTrue(srcData.Length == length);
     m_TensorOnDevice.Upload(srcData, shape, 0);
     m_TensorAllocator = null;
     m_Cache           = null;
     m_CacheIsDirty    = false;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create a Tensor of shape `s`, an array of data `srcData` and an optional name `n`
 /// `srcData` should be of size `s.length`.
 /// </summary>
 public Tensor(TensorShape s, float[] srcData, string n = "")
 {
     //;;UnityEngine.Debug.Log("Tensor::Tensor " + n + " " + s + " []-> " + srcData);
     name             = n;
     shape            = s;
     m_TensorOnDevice = new ArrayTensorData(shape);
     m_TensorOnDevice.Upload(srcData, 0, Math.Min(length, srcData.Length));
     m_TensorAllocator = null;
     m_Cache           = null;
     m_CacheIsDirty    = false;
 }