ggml_apply: Apply a Layer Object to a Tensor Node

View source: R/nn_functional.R

ggml_applyR Documentation

Apply a Layer Object to a Tensor Node

Description

Applies a ggml_layer object (created with ggml_dense(), ggml_lstm(), etc.) to a ggml_tensor_node. Applying the same layer object to multiple tensor nodes produces shared weights – the identity of the layer object (layer$layer_id) is used as the sharing key, not its name.

Usage

ggml_apply(tensor, layer)

Arguments

tensor

A ggml_tensor_node (e.g. from ggml_input()).

layer

A ggml_layer object.

Value

A new ggml_tensor_node.

Examples


encoder <- ggml_dense(64L, activation = "relu")
x1 <- ggml_input(shape = 32L)
x2 <- ggml_input(shape = 32L)
out1 <- x1 |> ggml_apply(encoder)
out2 <- x2 |> ggml_apply(encoder)  # shared weights
model <- ggml_model(inputs = list(x1, x2),
                    outputs = list(out1, out2))


ggmlR documentation built on July 14, 2026, 1:08 a.m.