public unsafe static DLManagedTensor FromBlob<T>(T* data, Int32 ndim, Int64* shape, Int64* strides = null) where T : unmanaged { var dl_managed_tensor = new DLManagedTensor(); dl_managed_tensor.dl_tensor.data = (IntPtr)data; dl_managed_tensor.dl_tensor.ctx.device_type = DLDeviceType.kDLCPU; dl_managed_tensor.dl_tensor.ndim = ndim; dl_managed_tensor.dl_tensor.dtype = DLDataType.From<T>(); dl_managed_tensor.dl_tensor.shape = (IntPtr)shape; dl_managed_tensor.dl_tensor.strides = (IntPtr)strides; dl_managed_tensor.dl_tensor.byte_offset = 0; dl_managed_tensor.deleter = EmptyDeleter; return dl_managed_tensor; }
public bool CheckType<T, TT>() where T: unmanaged where TT: unmanaged { var T_dtype = DLDataType.From<T>(); var TT_dtype = DLDataType.From<TT>(); return dtype.type_code == T_dtype.type_code && dtype.bits == TT_dtype.bits && dtype.lanes == TT_dtype.lanes; }