Example #1
0
        internal static XArray FromRef(XArrayRef tensorRef)
        {
            long[] shape_data = new long[tensorRef.dimCount];
            Marshal.Copy(tensorRef.sizes, shape_data, 0, shape_data.Length);
            XArray result = new XArray(shape_data, tensorRef.elementType);

            result.NativePtr = tensorRef.buffer;

            return(result);
        }
Example #2
0
        internal XArrayRef AllocTensorRef(XArray tensor)
        {
            var tensorRef = new XArrayRef();

            tensorRef.buffer      = GetBufferStart(tensor);
            tensorRef.dimCount    = tensor.Sizes.Length;
            tensorRef.sizes       = AllocArray(tensor.Sizes);
            tensorRef.strides     = AllocArray(tensor.strides);
            tensorRef.elementType = tensor.DataType;
            return(tensorRef);
        }
Example #3
0
 /// <summary>
 /// Frees the tensor reference.
 /// </summary>
 /// <param name="tensorRef">The tensor reference.</param>
 internal void FreeTensorRef(XArrayRef tensorRef)
 {
     Marshal.FreeHGlobal(tensorRef.sizes);
     Marshal.FreeHGlobal(tensorRef.strides);
 }