converter

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertSafetensorsToGGUF added in v0.7.0

func ConvertSafetensorsToGGUF(inputDir, outputPath, arch string) error

ConvertSafetensorsToGGUF reads a HuggingFace model directory containing config.json and model.safetensors, maps tensor names and metadata using the existing GGUF mapping functions, and writes a GGUF file.

func ONNXToZMF

func ONNXToZMF(model *onnx.ModelProto) (*zmf.Model, error)

ONNXToZMF converts an ONNX model to the ZMF format.

func ONNXToZMFWithPath

func ONNXToZMFWithPath(model *onnx.ModelProto, modelPath string) (*zmf.Model, error)

ONNXToZMFWithPath converts an ONNX model to the ZMF format with support for external data files.

Types

type SafetensorsDtype added in v0.7.0

type SafetensorsDtype string

SafetensorsDtype represents a data type in the safetensors format.

const (
	DtypeF32  SafetensorsDtype = "F32"
	DtypeF16  SafetensorsDtype = "F16"
	DtypeBF16 SafetensorsDtype = "BF16"
)

type SafetensorsFile added in v0.7.0

type SafetensorsFile struct {
	Tensors    map[string]SafetensorsTensorInfo
	DataOffset int64 // byte offset where tensor data begins in the file
	// contains filtered or unexported fields
}

SafetensorsFile holds parsed safetensors header and a reader for tensor data.

func OpenSafetensors added in v0.7.0

func OpenSafetensors(path string) (*SafetensorsFile, error)

OpenSafetensors parses a safetensors file and returns its metadata. The caller must call Close() when done.

func (*SafetensorsFile) Close added in v0.7.0

func (sf *SafetensorsFile) Close() error

Close releases the underlying file.

func (*SafetensorsFile) ReadTensorData added in v0.7.0

func (sf *SafetensorsFile) ReadTensorData(name string) ([]byte, error)

ReadTensorData reads the raw bytes for the named tensor.

type SafetensorsTensorInfo added in v0.7.0

type SafetensorsTensorInfo struct {
	Dtype       SafetensorsDtype `json:"dtype"`
	Shape       []uint64         `json:"shape"`
	DataOffsets [2]uint64        `json:"data_offsets"`
}

SafetensorsTensorInfo describes a single tensor in the safetensors header.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL