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/bridge/omega-bridge/examples/deepinfer/flops_pairs.om # 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 / bridge / omega-bridge / examples / deepinfer / flops_pairs.om` 41 lines ยท 1684 bytes Raw Blame History 1 note flops_pairs.om: DeepInfer FlopsEstimator::floor_prefix, capped_prefix and pairs in Omega 2 note (deepseek-ai/DeepInfer `553741557a57df44a46fb3ab72b6aafeaf945337` csrc/engine/flops_estimator.hpp 3 note lines 237-257, Apache-2.0). Each step is the C++ expression's step in the same order, so a 4 note step that leaves long traps 1 exactly where the C++ would be undefined behaviour. div truncates 5 note toward zero like C++ /. Valid domain (the callers clamp with std::max(0, ...)): n >= 0, 6 note ratio > 0, cap >= 0, 0 <= begin <= end; outside it a requires clause traps 9 instead of 7 note returning a value. Bound through tools/native as omega2_floor_prefix, omega2_capped_prefix and 8 note omega2_pairs (examples/deepinfer/README.md). 9 om2 10 note sum floor(t / ratio), t = 1 .. n 11 export fn floor_prefix n long ratio long to long 12 requires ge n 0 13 requires gt ratio 0 14 blocks = div n ratio 15 a = mul blocks add n 1 16 b = div mul mul ratio blocks add blocks 1 2 17 ret sub a b 18 end 19 note sum min(floor(t / ratio), cap), t = 1 .. n 20 export fn capped_prefix n long ratio long cap long to long 21 requires ge n 0 22 requires gt ratio 0 23 requires ge cap 0 24 stop = mul ratio cap 25 if lt n stop 26 stop = n 27 end 28 ret add floor_prefix stop ratio mul sub n stop cap 29 end 30 note query-key pairs for positions [begin, finish) by prefix differences; cap 0 means uncapped 31 note (C++ names the second parameter end, which is an Omega keyword) 32 export fn pairs begin long finish long ratio long cap long to long 33 requires ge begin 0 34 requires le begin finish 35 requires gt ratio 0 36 requires ge cap 0 37 if eq cap 0 38 ret sub floor_prefix finish ratio floor_prefix begin ratio 39 end 40 ret sub capped_prefix finish ratio cap capped_prefix begin ratio cap 41 end