MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / sam3_layer_norm_2d

Function sam3_layer_norm_2d

sam3.cpp:1053–1065  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1051}
1052
1053static struct ggml_tensor* sam3_layer_norm_2d(struct ggml_context* ctx,
1054 struct ggml_tensor* x,
1055 struct ggml_tensor* w,
1056 struct ggml_tensor* b) {
1057 // x is [C, H, W, B] in ggml layout — norm over C dimension (dim 0)
1058 x = ggml_norm(ctx, x, 1e-6f);
1059 // w, b are [C, 1, 1] — broadcast multiply/add
1060 x = ggml_mul_inplace(ctx, x, w);
1061 if (b) {
1062 x = ggml_add_inplace(ctx, x, b);
1063 }
1064 return x;
1065}
1066
1067// Read tensor data from backend into a float buffer, handling F32, F16, and
1068// quantized types. n = number of float elements to produce.

Callers 4

sam3_cxblock_forwardFunction · 0.85
sam3_build_sam_dec_graphFunction · 0.85
sam3_encode_memoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected