ggml_cast: Cast a Tensor to Another Type

View source: R/operations.R

ggml_castR Documentation

Cast a Tensor to Another Type

Description

Returns a tensor with the same shape as a but of the given type. Unlike ggml_cpy there is no need to allocate the destination tensor first. Some ggml operations require a specific type – for example ggml_conv_1d builds its im2col in F16 and so needs an F16 kernel – and this is the direct way to supply one.

Usage

ggml_cast(ctx, a, type)

Arguments

ctx

GGML context

a

Source tensor

type

Target type constant (e.g. GGML_TYPE_F16)

Value

Tensor of the requested type with a's shape

See Also

ggml_cast_numeric, ggml_cpy

Examples


ctx <- ggml_init(16 * 1024 * 1024)
a <- ggml_new_tensor_1d(ctx, GGML_TYPE_F32, 100)
a16 <- ggml_cast(ctx, a, GGML_TYPE_F16)
ggml_free(ctx)


ggmlR documentation built on Oct. 23, 2026, 1:07 a.m.