Learn R Programming

ggmlR (version 0.6.1)

ggml_count_equal: Count Equal Elements (Graph)

Description

Creates a graph node that counts equal elements between two tensors. Useful for accuracy computation.

Usage

ggml_count_equal(ctx, a, b)

Value

Tensor containing the count of equal elements

Arguments

ctx

GGML context

a

First tensor

b

Second tensor (same shape as a)

See Also

Other tensor_layout: ggml_are_same_stride(), ggml_can_repeat(), ggml_is_contiguous_0(), ggml_is_contiguous_1(), ggml_is_contiguous_2(), ggml_is_contiguous_channels(), ggml_is_contiguous_rows(), ggml_is_contiguously_allocated()

Examples

Run this code
# \donttest{
ctx <- ggml_init(16 * 1024 * 1024)
pred <- ggml_new_tensor_1d(ctx, GGML_TYPE_I32, 100)
labels <- ggml_new_tensor_1d(ctx, GGML_TYPE_I32, 100)
# ... set values ...
correct <- ggml_count_equal(ctx, pred, labels)
graph <- ggml_build_forward_expand(ctx, correct)
ggml_graph_compute(ctx, graph)
# correct now contains count of matching elements
ggml_free(ctx)
# }

Run the code above in your browser using DataLab