sdcpp

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GGMLTypeF16     = GGMLType(C.GGML_TYPE_F16)
	GGMLTypeF32     = GGMLType(C.GGML_TYPE_F32)
	GGMLTypeDefault = GGMLType(C.GGML_TYPE_COUNT)
)
View Source
const (
	SD_TYPE_F32     = C.SD_TYPE_F32
	SD_TYPE_F16     = C.SD_TYPE_F16
	SD_TYPE_Q4_0    = C.SD_TYPE_Q4_0
	SD_TYPE_Q4_1    = C.SD_TYPE_Q4_1
	SD_TYPE_Q5_0    = C.SD_TYPE_Q5_0
	SD_TYPE_Q5_1    = C.SD_TYPE_Q5_1
	SD_TYPE_Q8_0    = C.SD_TYPE_Q8_0
	SD_TYPE_Q8_1    = C.SD_TYPE_Q8_1
	SD_TYPE_Q2_K    = C.SD_TYPE_Q2_K
	SD_TYPE_Q3_K    = C.SD_TYPE_Q3_K
	SD_TYPE_Q4_K    = C.SD_TYPE_Q4_K
	SD_TYPE_Q5_K    = C.SD_TYPE_Q5_K
	SD_TYPE_Q6_K    = C.SD_TYPE_Q6_K
	SD_TYPE_Q8_K    = C.SD_TYPE_Q8_K
	SD_TYPE_IQ2_XXS = C.SD_TYPE_IQ2_XXS
	SD_TYPE_I8      = C.SD_TYPE_I8
	SD_TYPE_I16     = C.SD_TYPE_I16
	SD_TYPE_I32     = C.SD_TYPE_I32
	SD_TYPE_COUNT   = C.SD_TYPE_COUNT
)
View Source
const (
	STD_DEFAULT_RNG = C.STD_DEFAULT_RNG
	CUDA_RNG        = C.CUDA_RNG
)
View Source
const (
	DEFAULT     = C.DEFAULT
	DISCRETE    = C.DISCRETE
	KARRAS      = C.KARRAS
	N_SCHEDULES = C.N_SCHEDULES
)
View Source
const (
	EULER_A   = C.EULER_A
	EULER     = C.EULER
	HEUN      = C.HEUN
	DPM2      = C.DPM2
	DPMPP2S_A = C.DPMPP2S_A
	DPMPP2M   = C.DPMPP2M
	DPMPP2Mv2 = C.DPMPP2Mv2
	LCM       = C.LCM
)

Variables

This section is empty.

Functions

func Free

func Free[T any](p *T)

func FreeSlice

func FreeSlice[T any](p []T)

func Free_sd_ctx

func Free_sd_ctx(p *Ctx)

func MaybeFreeCond

func MaybeFreeCond(ctx *Ctx)

func MaybeFreeDiff

func MaybeFreeDiff(ctx *Ctx)

func MaybeFreeFirst

func MaybeFreeFirst(ctx *Ctx)

func SD_get_system_info

func SD_get_system_info() string

func SD_image_to_tensor

func SD_image_to_tensor(out *Tensor, img *image.NRGBA)

func SD_tensor_to_image

func SD_tensor_to_image(input *Tensor) *image.NRGBA

Types

type Ctx

type Ctx = C.sd_ctx_t

func New_sd_ctx

func New_sd_ctx(
	modelPath, vaePath, taesdPath, ctrlNetPath, loraPath, embedDir string,
	vaeDecOnly, vaeTiling, freeParamsImmediately bool,
	threads int, typ SD_type_t, rnd RNG_type_t, sched Schedule_t,
	keepCtrlCPU bool,
) *Ctx

type GGMLBackend

type GGMLBackend interface {
	IsCPU() bool
}

func GGMLNewCPU

func GGMLNewCPU() GGMLBackend

type GGMLContext

type GGMLContext C.struct_ggml_context

func GGMLInit

func GGMLInit(params GGMLInitParams) (*GGMLContext, error)

func (*GGMLContext) C

func (ctx *GGMLContext) C() *C.struct_ggml_context

func (*GGMLContext) Free

func (ctx *GGMLContext) Free()

type GGMLInitParams

type GGMLInitParams struct {
	MemSize   uintptr
	MemBuffer unsafe.Pointer
	NoAlloc   bool
}

type GGMLType

type GGMLType int

func (GGMLType) BlockSize

func (t GGMLType) BlockSize() int64

func (GGMLType) C

func (t GGMLType) C() C.enum_ggml_type

func (GGMLType) Size

func (t GGMLType) Size() int64

type RNG_type_t

type RNG_type_t = C.enum_rng_type_t

type SD_image_t

type SD_image_t C.sd_image_t

func Txt2Img

func Txt2Img(
	ctx *Ctx, prompt, negative string, clipSkip int, cfgScale float32, w, h int,
	sample Sample_method_t, steps int, seed int64, batchCount int,
	controlCond *SD_image_t, controlStrength float32,
) []SD_image_t

func (*SD_image_t) Channels

func (img *SD_image_t) Channels() int

func (*SD_image_t) Data

func (img *SD_image_t) Data() []byte

func (*SD_image_t) Size

func (img *SD_image_t) Size() (w, h int)

type SD_type_t

type SD_type_t = C.enum_sd_type_t

type Sample_method_t

type Sample_method_t = C.enum_sample_method_t

type Schedule_t

type Schedule_t = C.enum_schedule_t

type Tensor

type Tensor struct {
	// contains filtered or unexported fields
}

Tensor is a n-dimensional tensor.

func DecodeFirstStage

func DecodeFirstStage(ctx *Ctx, gctx *GGMLContext, t *Tensor) *Tensor

func GetLearnedCondition

func GetLearnedCondition(ctx *Ctx, gctx *GGMLContext, prompt string, clipSkip int, width, height int) (c, cvec *Tensor)

func GetLearnedConditionNeg

func GetLearnedConditionNeg(ctx *Ctx, gctx *GGMLContext, prompt string, clipSkip int, width, height int) (c, cvec *Tensor)

func NewTensor1D

func NewTensor1D(ctx *GGMLContext, typ GGMLType, ne0 int) *Tensor

func NewTensor2D

func NewTensor2D(ctx *GGMLContext, typ GGMLType, ne0, ne1 int) *Tensor

func NewTensor3D

func NewTensor3D(ctx *GGMLContext, typ GGMLType, ne0, ne1, ne2 int) *Tensor

func NewTensor4D

func NewTensor4D(ctx *GGMLContext, typ GGMLType, ne0, ne1, ne2, ne3 int) *Tensor

func Sample

func Sample(
	ctx *Ctx, gctx *GGMLContext, xt, noise *Tensor,
	c, cvec, uc, ucvec, hint *Tensor,
	seed int64, method Sample_method_t, steps int, cfgScale, controlStrength float32,
) *Tensor

func (*Tensor) C

func (t *Tensor) C() *C.struct_ggml_tensor

func (*Tensor) Get1DF32

func (t *Tensor) Get1DF32(l int) float32

func (*Tensor) Get2DF32

func (t *Tensor) Get2DF32(l, k int) float32

func (*Tensor) Get3DF32

func (t *Tensor) Get3DF32(l, k, j int) float32

func (*Tensor) Get4DF32

func (t *Tensor) Get4DF32(l, k, j, i int) float32

func (*Tensor) Set1DF32

func (t *Tensor) Set1DF32(val float32, l int)

func (*Tensor) Set2DF32

func (t *Tensor) Set2DF32(val float32, l, k int)

func (*Tensor) Set3DF32

func (t *Tensor) Set3DF32(val float32, l, k, j int)

func (*Tensor) Set4DF32

func (t *Tensor) Set4DF32(val float32, l, k, j, i int)

func (*Tensor) Type

func (t *Tensor) Type() GGMLType

Jump to

Keyboard shortcuts

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