Beispiel #1
0
        /// <summary>
        /// Allocs the tensor reference.
        /// </summary>
        /// <param name="tensor">The tensor.</param>
        /// <returns>TensorRef64.</returns>
        public static TensorRef64 AllocTensorRef(NDArray tensor)
        {
            var tensorRef = new TensorRef64();

            tensorRef.buffer      = CpuNativeHelpers.GetBufferStart(tensor);
            tensorRef.dimCount    = tensor.Shape.Length;
            tensorRef.sizes       = AllocArray(tensor.Shape);
            tensorRef.strides     = AllocArray(tensor.Strides);
            tensorRef.elementType = (CpuDType)tensor.ElementType;
            return(tensorRef);
        }
Beispiel #2
0
 /// <summary>
 /// Frees the tensor reference.
 /// </summary>
 /// <param name="tensorRef">The tensor reference.</param>
 public static void FreeTensorRef(TensorRef64 tensorRef)
 {
     Marshal.FreeHGlobal(tensorRef.sizes);
     Marshal.FreeHGlobal(tensorRef.strides);
 }