Learn R Programming

ggmlR (version 0.8.4)

ggml_cast: 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)

Value

Tensor of the requested type with a's shape

Arguments

ctx

GGML context

a

Source tensor

type

Target type constant (e.g. GGML_TYPE_F16)

See Also

ggml_cast_numeric, ggml_cpy

Examples

Run this code
# \donttest{
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)
# }

Run the code above in your browser using DataLab