Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/ng/bench/kernels/linear.c # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / ng / bench / kernels / linear.c` 32 lines ยท 1365 bytes Raw Blame History 1 /* linear.c -- REFERENCE TWIN ONLY (gcc oracle) of linear.om: omega-bridge pytorch/kernels/linear.om 2 (o[M,N] = c[N] + a[M,K] @ w[N,K]^T, each sum in double from the bias, rounded once to float) at 3 M 64, K 256, N 256, with the same inputs, 40 passes and the same checksum line. */ 4 #include 5 #include 6 #include 7 #define M 64 8 #define K 256 9 #define N 256 10 static float c[N], a[M * K], w[N * K], o[M * N]; 11 static double lindot(uint64_t i, uint64_t j) { 12 double s = (double)c[j]; 13 uint64_t ia = i * K, iw = j * K; 14 for (uint64_t k = 0; k < K; k++) { s += (double)a[ia] * (double)w[iw]; ia++; iw++; } 15 return s; 16 } 17 static void linear(void) { 18 for (uint64_t i = 0; i < M; i++) for (uint64_t j = 0; j < N; j++) o[i * N + j] = (float)lindot(i, j); 19 } 20 int main(void) { 21 for (uint64_t i = 0; i < N; i++) c[i] = (float)((int64_t)((i * 5) % 11) - 5) / 4.0f; 22 for (uint64_t i = 0; i < M * K; i++) a[i] = (float)((int64_t)((i * 7) % 13) - 6) / 8.0f; 23 for (uint64_t i = 0; i < N * K; i++) w[i] = (float)((int64_t)((i * 3) % 17) - 8) / 16.0f; 24 uint64_t s = 0; 25 for (uint64_t r = 0; r < 40; r++) { 26 c[r % 256] += 1.0f; 27 linear(); 28 for (uint64_t i = 0; i < M * N; i++) { uint32_t b; memcpy(&b, &o[i], 4); s += (uint64_t)b * (i + 1); } 29 } 30 printf("%llu\n", (unsigned long long)s); 31 return 0; 32 }