| 1051 | } |
| 1052 | |
| 1053 | static 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. |
no outgoing calls
no test coverage detected