| ggml_scale_bias | R Documentation |
Creates a graph node computing s * a + b for scalar s and
b. Unlike ggml_add1() with ggml_new_f32(), this adds a
constant without materialising a data-carrying tensor, so it is usable while
building a graph in a no_alloc context.
ggml_scale_bias(ctx, a, s, b)
ctx |
GGML context |
a |
Input tensor |
s |
Scale factor (numeric scalar) |
b |
Bias added after scaling (numeric scalar) |
Tensor representing s * a + b
ctx <- ggml_init(16 * 1024 * 1024)
a <- ggml_new_tensor_1d(ctx, GGML_TYPE_F32, 4)
ggml_set_f32(a, c(1, 2, 3, 4))
result <- ggml_scale_bias(ctx, a, 2.0, 1.0)
graph <- ggml_build_forward_expand(ctx, result)
ggml_graph_compute(ctx, graph)
output <- ggml_get_f32(result) # [3, 5, 7, 9]
ggml_free(ctx)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.