interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / src / tensor / omega_tensor_reduce_seam.c

45 lines · 1679 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0
2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "omega_tensor_reduce_seam.h"
18
19#include <stdlib.h>
20#include <string.h>
21
22#include "omega_numeric.h"
23
24#include "omega_numeric_reduce.h"
25
26_Static_assert(sizeof(OMEGA_REDUCE_DECLARED_ORDER) == sizeof(OMEGA_TENSOR_REDUCE_DECLARED_ORDER),
27 "tensor reduce order must equal the E1 reduction order");
28
29int omega_tensor_seam_reduce_cpu(OmegaTensorReduceOp op, const float *x, size_t n, float *out) {
30 if (strcmp(OMEGA_REDUCE_DECLARED_ORDER, OMEGA_TENSOR_REDUCE_DECLARED_ORDER) != 0)
31 return OMEGA_NUMERIC_ERR_BAD_ARGS;
32 OmegaReduceOp r;
33 switch (op) {
34 case OMEGA_TR_SUM: r = OMEGA_RED_SUM; break;
35 case OMEGA_TR_MAX: r = OMEGA_RED_MAX; break;
36 case OMEGA_TR_MIN: r = OMEGA_RED_MIN; break;
37 case OMEGA_TR_MEAN: r = OMEGA_RED_MEAN; break;
38 default: return OMEGA_NUMERIC_ERR_BAD_ARGS;
39 }
40 if (n == 0) return OMEGA_NUMERIC_ERR_BAD_ARGS;
41 return omega_reduce_cpu(r, x, n, out);
42}
43
44const char *omega_tensor_seam_reduce_source(void) { return "E1_WP_D_OMEGA_REDUCE_CPU"; }
45