Documentation
¶
Overview ¶
Package numpy allows one to read/write tensors to Python's NumPy npy and npz file formats.
Experimental: this package (numpy) is fresh from the oven and not well tested. Please open an issue if you find any bugs.
Index ¶
- func FortranToCLayout(dtypeSize int, dims []int, fortranData []byte, cData []byte) error
- func FromNpyFile(filePath string) (*tensors.Tensor, error)
- func FromNpyReader(r io.Reader) (*tensors.Tensor, error)
- func FromNpzFile(filePath string) (map[string]*tensors.Tensor, error)
- func FromNpzReader(r io.ReaderAt, size int64) (map[string]*tensors.Tensor, error)
- func ToNpyFile(tensor *tensors.Tensor, filePath string) error
- func ToNpyWriter(tensor *tensors.Tensor, w io.Writer) error
- func ToNpzFile(tensorsMap map[string]*tensors.Tensor, filePath string) error
- func ToNpzWriter(tensorsMap map[string]*tensors.Tensor, w io.Writer) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FortranToCLayout ¶ added in v0.20.1
func FromNpyFile ¶
FromNpyFile reads a .npy file and returns a tensors.Tensor.
func FromNpyReader ¶
FromNpyReader reads a .npy file from an io.Reader and returns a tensors.Tensor.
func FromNpzFile ¶
FromNpzFile reads a .npz file and returns a map of tensor names to tensors.Tensor.
func FromNpzReader ¶
FromNpzReader reads a .npz file from an io.ReaderAt and size, returning a map of tensor names to tensors.Tensor. .npz files are zip archives, so we need io.ReaderAt.
func ToNpyWriter ¶
ToNpyWriter serializes a tensors.Tensor to an io.Writer in .npy format.
func ToNpzWriter ¶
ToNpzWriter serializes a map of tensors to an io.Writer as a .npz archive. Note: Creating a valid zip archive generally requires io.WriterAt for the central directory, which is written at the end. A simple io.Writer is not enough for zip.NewWriter directly if the output needs to be streamed without seeking (e.g., network stream). However, zip.Writer itself buffers and then writes. If 'w' is an os.File, it works. For a generic io.Writer that doesn't support Seek, this would be more complex, potentially requiring writing the entire NPZ to a bytes.Buffer first, then to the writer.
Types ¶
This section is empty.