From 53b8ce77ad87a02d097e5d79556deb9886a481ae Mon Sep 17 00:00:00 2001 From: Abhishek Shivakumar Date: Thu, 19 Nov 2026 23:57:37 +0000 Subject: [PATCH 1/2] Share one squared-distance primitive across estimators (#498) Audit: 127 squared-difference loops, 234 scalar dot loops, 93 sums, 16 RBF exponentials and 20 row-partition functions in lib/scikit, almost all inline. The scan is benchmarks/audit_hot_primitives.py. sqdist_f32 and sqdist_f32_acc_f64 now carry the row-to-row distance that KMeans, KernelRidge, KernelSVC, GaussianProcess, TSNE, SpectralClustering, LabelSpreading and the kernel approximations wrote inline in three loop forms, and dot_product delegates to array_dot. The primitive is a while loop with a constant step, which LLVM vectorizes, and runs at 0.4 to 0.7 of the time of the old loops. The 19 headline rows score the same. On a target with fused multiply-add the vectorized loop rounds the last bit differently from the old for loop at -O3. At -O0 and on x86-64 without FMA the results are identical. --- .github/workflows/flow.yml | 7 +- benchmarks/HOT_PRIMITIVE_AUDIT.md | 16 + benchmarks/README.md | 22 + benchmarks/audit_hot_primitives.py | 182 ++ benchmarks/bench_primitives.flow | 149 + benchmarks/check_primitive_bench.py | 72 + benchmarks/hot_primitive_audit.json | 3892 ++++++++++++++++++++++++++ lib/scikit/cluster.flow | 14 +- lib/scikit/gaussian_process.flow | 18 +- lib/scikit/kernel_approximation.flow | 6 +- lib/scikit/kernel_ridge.flow | 6 +- lib/scikit/manifold.flow | 6 +- lib/scikit/matrix.flow | 39 +- lib/scikit/semi_supervised.flow | 8 +- lib/scikit/svm.flow | 14 +- tests/test_shared_primitives.flow | 157 ++ 16 files changed, 4542 insertions(+), 66 deletions(-) create mode 100644 benchmarks/HOT_PRIMITIVE_AUDIT.md create mode 100644 benchmarks/audit_hot_primitives.py create mode 100644 benchmarks/bench_primitives.flow create mode 100644 benchmarks/check_primitive_bench.py create mode 100644 benchmarks/hot_primitive_audit.json create mode 100644 tests/test_shared_primitives.flow diff --git a/.github/workflows/flow.yml b/.github/workflows/flow.yml index 450199d..74f9f3c 100644 --- a/.github/workflows/flow.yml +++ b/.github/workflows/flow.yml @@ -66,6 +66,8 @@ jobs: benchmarks/test_config_equivalence.py \ benchmarks/test_disparity_regression_policy.py \ benchmarks/publish_headline_v2.py \ + benchmarks/audit_hot_primitives.py \ + benchmarks/check_primitive_bench.py \ benchmarks/validate_execution_substrate.py python - <<'PY' import json @@ -145,7 +147,10 @@ jobs: FLOW_OPT_LEVEL: "3" FLOW_LDFLAGS: "-lm -lopenblas lib/scikit/flow_time.c lib/scikit/flow_parallel.c" FLOW_HEADLINE_COMMAND: ${{ github.workspace }}/.flow-toolchain/flow run benchmarks/bench_flow_v2.flow - run: python benchmarks/run_headline.py --repeats 5 + run: | + python benchmarks/run_headline.py --repeats 5 + ${{ github.workspace }}/.flow-toolchain/flow run benchmarks/bench_primitives.flow > /tmp/primitives.txt + python benchmarks/check_primitive_bench.py /tmp/primitives.txt - uses: actions/upload-artifact@v4 with: diff --git a/benchmarks/HOT_PRIMITIVE_AUDIT.md b/benchmarks/HOT_PRIMITIVE_AUDIT.md new file mode 100644 index 0000000..f2b1c0f --- /dev/null +++ b/benchmarks/HOT_PRIMITIVE_AUDIT.md @@ -0,0 +1,16 @@ +# Hot primitive audit + +Generated by `benchmarks/audit_hot_primitives.py`. A static scan of `lib/scikit` for hot-loop shapes. +A site is `shared` when its function calls a shared primitive and `inline` otherwise. + +Defined primitives: `array_dot`, `blas_dot`, `blas_dot_strided_f64`, `blas_matvec`, `cblas_ddot`, `cblas_dgemm`, `cblas_sdot`, `cblas_sgemm`, `dot_product`, `sqdist_f32`, `sqdist_f32_acc_f64` + +Call sites per primitive: `array_dot` 1, `blas_dot` 11, `blas_dot_strided_f64` 3, `blas_matvec` 13, `cblas_ddot` 1, `cblas_dgemm` 2, `cblas_sdot` 1, `cblas_sgemm` 15, `dot_product` 4, `sqdist_f32` 10, `sqdist_f32_acc_f64` 1 + +| Category | Primitive definitions | Shared call sites | Inline sites | Functions with inline sites | +|---|---:|---:|---:|---| +| squared-distance | 2 | 0 | 116 | `_bic_kmeans`, `_bic_piecewise_error`, `_euclidean_dist_row`, `_fs_anova_f_scores`, `_kernel_compute`, `_kmeans_assign`, `_kmeans_lloyd_scratch`, `_kmeans_nearest_centroid`, `_kmeans_run`, `_kmeans_sk_pp_init`, `_mse`, `_mtl_columns` and 81 more | +| dot | 1 | 14 | 233 | `_build_regressor_tree`, `_centered_dot`, `_gp_linear_kernel`, `_gram_schmidt`, `_ipca_top_eigenvectors`, `_kernel_compute`, `_kernel_func`, `_kernel_svc_smo_precomputed`, `_kmeans_sk_pp_init`, `_kr_dot_f64`, `_mcd_distances`, `_omp_sparse_coding_update` and 147 more | +| sum-reduction | 0 | 0 | 93 | `_array_sum_f32`, `_bic_bistochastic`, `_build_classifier_tree`, `_build_classifier_tree_rf`, `_build_regressor_tree`, `_col_means`, `_find_best_hist_split`, `_fs_anova_f_scores`, `_kmeans_assign`, `_kmeans_sk_pp_init`, `_mean_val`, `_mse` and 60 more | +| rbf | 0 | 0 | 16 | `_beta_func`, `_build_affinity`, `_build_rbf_affinity`, `_gp_rbf_kernel`, `_kernel_compute`, `_kernel_func`, `_rbf_exp`, `_rbf_exp_f64`, `_svm_kernel_vec`, `gaussian_process_classifier_fit`, `gaussian_process_classifier_predict`, `kernel_compute` and 3 more | +| row-partition | 0 | 0 | 20 | `_find_best_hist_split`, `_hist_tree_add_split`, `_split_samples`, `_tree_split_goes_left`, `bootstrap_oob_get_split`, `bootstrap_oob_init`, `group_kfold_split`, `group_shuffle_split_get_split`, `group_shuffle_split_init`, `leave_one_group_out_split`, `leave_p_group_out_split`, `leave_p_out_get_split` and 8 more | diff --git a/benchmarks/README.md b/benchmarks/README.md index ee0a185..1a6f991 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -303,6 +303,28 @@ of it found a heap-buffer-overflow in `_solve_lstsq_qr`, which assumed a design has at least as many rows as columns; RANSAC reaches it by fitting 5 sampled rows against the 10 features of diabetes. +## Shared hot primitives + +[`audit_hot_primitives.py`](audit_hot_primitives.py) scans `lib/scikit` for hot-loop shapes +(squared differences, dot products, sums, RBF exponentials, row partitioning) and records which +sites call a shared primitive. The result is in [`hot_primitive_audit.json`](hot_primitive_audit.json) +and [`HOT_PRIMITIVE_AUDIT.md`](HOT_PRIMITIVE_AUDIT.md). `--check` fails when it is stale. The scan +matches loop shapes by text, so it counts squared-error and variance sums with the distance loops. + +`sqdist_f32` and `sqdist_f32_acc_f64` in `lib/scikit/matrix.flow` hold the row-to-row squared +distance that KMeans, KernelRidge, KernelSVC, GaussianProcess, TSNE, SpectralClustering, +LabelSpreading and the kernel approximations used to carry inline. `tests/test_shared_primitives.flow` +compares them with the loops they replaced, bit for bit. `bench_primitives.flow` times them against +both inline forms in one process, and `check_primitive_bench.py` fails when the primitive is more +than 10% slower than either form or when the checksums differ. + +The loop form decides the rounding on a target with fused multiply-add. Flow emits `for` loops with +a runtime stride, which LLVM does not vectorize, so the compiler fuses `s + d * d` into one +instruction. A `while` loop with a constant step is vectorized, and the compiler then does the +subtraction and multiplication in vector lanes and adds the products one at a time, unfused. On +arm64 at `-O3` the two forms differ in the last bit of some sums. On x86-64 without FMA, the CI +target, and at `-O0` on both, they are identical. + ## Pages publication [`publish_headline_v2.py`](publish_headline_v2.py) validates the committed canonical benchmark and architecture map, then copies the JSON artifacts into `docs/` for the static site. The public benchmark and architecture pages render those artifacts directly instead of embedding hand-maintained timing claims. diff --git a/benchmarks/audit_hot_primitives.py b/benchmarks/audit_hot_primitives.py new file mode 100644 index 0000000..8e2c246 --- /dev/null +++ b/benchmarks/audit_hot_primitives.py @@ -0,0 +1,182 @@ +#!/usr/bin/env python3 +"""Inventory the hot-loop call sites in lib/scikit and which ones use a shared primitive. + +Scans every function body in lib/scikit/*.flow (datasets_real.flow, which is +data, is skipped) for these loop shapes: + + squared-distance acc = acc + d * d, with d defined as a difference + dot acc = acc + x[..] * y[..] in a scalar loop + sum-reduction acc = acc + x[..] in a scalar loop + rbf exp() applied to gamma or length scale times a distance + row-partition functions that gather, split, sample or select rows + +A site is "shared" when its function is itself a shared primitive or calls one +(sqdist_f32, array_dot, blas_dot, cblas_sdot and the like). Everything else is +"inline". Static scan only, so the output is deterministic. `--check` fails +when the committed audit differs from a fresh scan. + +This finds loop shapes by text. It does not prove two loops have the same +semantics, so each consolidation still needs the bit-exactness check in +tests/test_shared_primitives.flow. +""" +from __future__ import annotations + +import argparse +import json +import re +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +LIB = ROOT / "lib" / "scikit" +SKIP = {"datasets_real.flow"} + +SHARED_PRIMITIVES = { + "sqdist_f32": "squared-distance", + "sqdist_f32_acc_f64": "squared-distance", + "array_dot": "dot", + "dot_product": "dot", + "blas_dot": "dot", + "cblas_sdot": "dot", + "cblas_ddot": "dot", + "blas_dot_strided_f64": "dot", + "blas_matvec": "dot", + "cblas_sgemm": "dot", + "cblas_dgemm": "dot", +} +# Functions that define the primitives; their own loop is the implementation. +PRIMITIVE_DEFINITIONS = {"sqdist_f32", "sqdist_f32_acc_f64", "array_dot", "blas_dot", "blas_dot_strided_f64"} + +FUNC = re.compile(r"^\s*(?:export\s+)?function\s+([A-Za-z_0-9]+)\s*\(") +ACC_SQ = re.compile(r"^\s*([A-Za-z_]\w*)\s*=\s*\1\s*\+\s*([A-Za-z_]\w*)\s*\*\s*\2\s*$") +ACC_PROD = re.compile(r"^\s*([A-Za-z_]\w*)\s*=\s*\1\s*\+\s*(.+?\S)\s*\*\s*(.+\S)\s*$") +ACC_SUM = re.compile(r"^\s*([A-Za-z_]\w*)\s*=\s*\1\s*\+\s*([A-Za-z_]\w*\[[^\]]+\]|matrix_at\([^)]*\))\s*$") +DIFF = re.compile(r"^\s*let\s+(?:mut\s+)?([A-Za-z_]\w*)\s*:\s*f(?:32|64)\s*=\s*.*\s-\s.*$") +RBF = re.compile(r"\bexp\(.*(gamma|length_scale|neg_gamma)", re.I) +PARTITION_NAME = re.compile(r"(split|partition|gather|take_rows|select_rows|subset|bootstrap|subsample|sample_rows)", re.I) +INDEXED = re.compile(r"\[[^\]]+\]|matrix_at\(") + + +def functions(text: str): + """Yield (name, start_line, [(line_no, line), ...]) for each function.""" + lines = text.splitlines() + starts = [(i, FUNC.match(ln).group(1)) for i, ln in enumerate(lines) if FUNC.match(ln)] + for k, (i, name) in enumerate(starts): + end = starts[k + 1][0] if k + 1 < len(starts) else len(lines) + yield name, i + 1, [(j + 1, lines[j]) for j in range(i, end)] + + +def scan_function(name: str, body: list[tuple[int, str]]) -> list[dict]: + sites: list[dict] = [] + calls = {p for p in SHARED_PRIMITIVES if re.search(rf"\b{p}\s*\(", "\n".join(b for _, b in body[1:]))} + shared_calls = {SHARED_PRIMITIVES[p] for p in calls} + diffs: dict[str, int] = {} + for no, line in body: + stripped = line.split("#", 1)[0] + m = DIFF.match(stripped) + if m: + diffs[m.group(1)] = no + sq = ACC_SQ.match(stripped) + if sq and sq.group(2) in diffs and no - diffs[sq.group(2)] <= 4: + sites.append({"line": no, "category": "squared-distance"}) + continue + pr = ACC_PROD.match(stripped) + if pr and INDEXED.search(pr.group(2)) and INDEXED.search(pr.group(3)): + sites.append({"line": no, "category": "dot"}) + continue + if ACC_SUM.match(stripped): + sites.append({"line": no, "category": "sum-reduction"}) + continue + if RBF.search(stripped): + sites.append({"line": no, "category": "rbf"}) + if PARTITION_NAME.search(name): + sites.append({"line": body[0][0], "category": "row-partition"}) + for s in sites: + if name in PRIMITIVE_DEFINITIONS and s["category"] == SHARED_PRIMITIVES.get(name): + s["status"] = "primitive" + elif s["category"] in shared_calls: + s["status"] = "shared" + else: + s["status"] = "inline" + return sites + + +def audit() -> dict: + rows = [] + for path in sorted(LIB.glob("*.flow")): + if path.name in SKIP: + continue + text = path.read_text() + for name, _start, body in functions(text): + for s in scan_function(name, body): + rows.append({"file": f"lib/scikit/{path.name}", "function": name, **s}) + categories = ["squared-distance", "dot", "sum-reduction", "rbf", "row-partition"] + summary = {c: {"primitive": 0, "shared": 0, "inline": 0, "inline_functions": []} for c in categories} + for r in rows: + entry = summary[r["category"]] + entry[r["status"]] += 1 + if r["status"] == "inline" and r["function"] not in entry["inline_functions"]: + entry["inline_functions"].append(r["function"]) + for entry in summary.values(): + entry["inline_functions"].sort() + primitives = sorted( + {r["function"] for r in rows if r["status"] == "primitive"} + | {p for p in SHARED_PRIMITIVES if any(re.search(rf"function\s+{p}\s*\(", pth.read_text()) for pth in LIB.glob("*.flow") if pth.name not in SKIP)} + ) + call_sites = {} + for name in sorted(SHARED_PRIMITIVES): + n = 0 + for pth in LIB.glob("*.flow"): + if pth.name in SKIP: + continue + for ln in pth.read_text().splitlines(): + code = ln.split("#", 1)[0] + if re.search(rf"\b{name}\s*\(", code) and not FUNC.match(code) and "function " not in code: + n += 1 + if n: + call_sites[name] = n + return {"schema_version": 1, "defined_primitives": primitives, "primitive_call_sites": call_sites, + "summary": summary, "sites": rows} + + +def render_markdown(doc: dict) -> str: + out = ["# Hot primitive audit", "", + "Generated by `benchmarks/audit_hot_primitives.py`. A static scan of `lib/scikit` for hot-loop shapes.", + "A site is `shared` when its function calls a shared primitive and `inline` otherwise.", "", + "Defined primitives: " + ", ".join(f"`{p}`" for p in doc["defined_primitives"]), "", + "Call sites per primitive: " + ", ".join(f"`{k}` {v}" for k, v in doc["primitive_call_sites"].items()), "", + "| Category | Primitive definitions | Shared call sites | Inline sites | Functions with inline sites |", + "|---|---:|---:|---:|---|"] + for cat, e in doc["summary"].items(): + funcs = ", ".join(f"`{f}`" for f in e["inline_functions"][:12]) + more = len(e["inline_functions"]) - 12 + if more > 0: + funcs += f" and {more} more" + out.append(f"| {cat} | {e['primitive']} | {e['shared']} | {e['inline']} | {funcs} |") + return "\n".join(out) + "\n" + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--json", type=Path, default=ROOT / "benchmarks" / "hot_primitive_audit.json") + ap.add_argument("--markdown", type=Path, default=ROOT / "benchmarks" / "HOT_PRIMITIVE_AUDIT.md") + ap.add_argument("--check", action="store_true") + args = ap.parse_args() + doc = audit() + text = json.dumps(doc, indent=2) + "\n" + md = render_markdown(doc) + if args.check: + if not args.json.exists() or args.json.read_text() != text or not args.markdown.exists() or args.markdown.read_text() != md: + print("hot primitive audit is stale. Run: python benchmarks/audit_hot_primitives.py") + return 1 + print("hot primitive audit matches lib/scikit") + return 0 + args.json.write_text(text) + args.markdown.write_text(md) + for cat, e in doc["summary"].items(): + print(f"{cat:18} primitive {e['primitive']:3} shared {e['shared']:3} inline {e['inline']:4}") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/benchmarks/bench_primitives.flow b/benchmarks/bench_primitives.flow new file mode 100644 index 0000000..ce3fc32 --- /dev/null +++ b/benchmarks/bench_primitives.flow @@ -0,0 +1,149 @@ +# Microbenchmark for the shared squared-distance primitive (issue #498). +# +# Times sqdist_f32 against the two loop forms it replaced, in one process with +# the variants interleaved sample by sample, at the feature counts the +# canonical datasets use (4 iris, 10 diabetes, 64 digits) and at 784 and 4096. +# Every variant sums the same row pairs, and the checksums must match to the +# bit, so a variant the compiler removed shows up as a mismatch rather than as +# a fast time. +# +# FLOW_OPT_LEVEL=3 flow run benchmarks/bench_primitives.flow > primitives.txt +# python benchmarks/check_primitive_bench.py primitives.txt +# +# Output: PRIMITIVE|variant|n_features|median_ns_per_pair|checksum + +import "lib/scikit/scikit.flow" + +extern { + function printf(fmt: string, ...) -> i32 + function flow_now_ns() -> i64 +} + +function bp_fill(a: ptr, n: i32, seed: i32) -> void { + let mut i: i32 = 0 + while i < n { + let raw: i32 = (i * 37 + seed * 11 + (i * i) % 17) % 101 + a[i] = ((raw - 50) as f32) * 0.173 + ((seed % 5) as f32) * 0.0371 + i = i + 1 + } +} + +function bp_ref_for(a: ptr, b: ptr, n: i32) -> f32 { + let mut s: f32 = 0.0 + for i in 0 to n { + let d: f32 = a[i] - b[i] + s = s + d * d + } + return s +} + +function bp_ref_matrix_at(A: Matrix, ra: i32, B: Matrix, rb: i32) -> f32 { + let mut s: f32 = 0.0 + for k in 0 to A.cols { + let d: f32 = matrix_at(A, ra, k) - matrix_at(B, rb, k) + s = s + d * d + } + return s +} + +function bp_pass(variant: i32, A: Matrix, B: Matrix, rows: i32, reps: i32) -> f32 { + let n: i32 = A.cols + let mut total: f32 = 0.0 + let mut r: i32 = 0 + while r < reps { + let mut i: i32 = 0 + while i < rows { + let mut j: i32 = 0 + while j < rows { + if variant == 0 { + total = total + bp_ref_for(A.data + i * n, B.data + j * n, n) + } + if variant == 1 { + total = total + bp_ref_matrix_at(A, i, B, j) + } + if variant == 2 { + total = total + sqdist_f32(A.data + i * n, B.data + j * n, n) + } + j = j + 1 + } + i = i + 1 + } + r = r + 1 + } + return total +} + +function bp_sort(v: ptr, n: i32) -> void { + let mut i: i32 = 1 + while i < n { + let key: f64 = v[i] + let mut j: i32 = i - 1 + while j >= 0 && v[j] > key { + v[j + 1] = v[j] + j = j - 1 + } + v[j + 1] = key + i = i + 1 + } +} + +function bp_case(n: i32) -> void { + let rows: i32 = 64 + let A: Matrix = matrix_new(rows, n) + let B: Matrix = matrix_new(rows, n) + bp_fill(A.data, rows * n, 1) + bp_fill(B.data, rows * n, 4) + let pairs_per_pass: i32 = rows * rows + # Aim for about 20 ms per sample. + let mut reps: i32 = 1 + let probe_t0: i64 = flow_now_ns() + let probe: f32 = bp_pass(2, A, B, rows, 1) + let probe_ns: i64 = flow_now_ns() - probe_t0 + if probe_ns > 0 { + reps = (20000000 / probe_ns) as i32 + } + if reps < 1 { reps = 1 } + let samples: i32 = 9 + let times: ptr = malloc((3 * samples * 8) as i64) as ptr + let sums: ptr = array_new_f32(3) + let mut s: i32 = 0 + # Two warmup rounds, then the timed rounds. Variant order rotates each round. + let mut round: i32 = -2 + while round < samples { + let mut v: i32 = 0 + while v < 3 { + let which: i32 = (v + round + 2) % 3 + let t0: i64 = flow_now_ns() + let total: f32 = bp_pass(which, A, B, rows, reps) + let t1: i64 = flow_now_ns() + sums[which] = total + if round >= 0 { + times[which * samples + round] = ((t1 - t0) as f64) / ((pairs_per_pass * reps) as f64) + } + v = v + 1 + } + round = round + 1 + } + let mut which: i32 = 0 + while which < 3 { + bp_sort(times + which * samples, samples) + let median: f64 = times[which * samples + samples / 2] + let name: string = "inline_for" + if which == 1 { name = "inline_matrix_at" } + if which == 2 { name = "sqdist_f32" } + printf("PRIMITIVE|%s|%d|%.4f|%.9g\n", name, n, median, sums[which] as f64) + which = which + 1 + } + free(times as ptr) + matrix_free(A) + matrix_free(B) +} + +function main() -> i32 { + bp_case(4) + bp_case(10) + bp_case(64) + bp_case(784) + bp_case(4096) + return 0 +} diff --git a/benchmarks/check_primitive_bench.py b/benchmarks/check_primitive_bench.py new file mode 100644 index 0000000..45b7f74 --- /dev/null +++ b/benchmarks/check_primitive_bench.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +"""Gate the shared primitive microbenchmark. + +Reads the output of benchmarks/bench_primitives.flow. For every feature count +the checksum of all variants must match to the bit, and the shared primitive +must not be slower than either inline form it replaced by more than --tolerance. +The default tolerance is 10% because a sub-microsecond pair loop moves by a few +percent from run to run on a shared machine. +""" +from __future__ import annotations + +import argparse +import sys +from collections import defaultdict +from pathlib import Path + + +def parse(text: str) -> dict[int, dict[str, tuple[float, str]]]: + cases: dict[int, dict[str, tuple[float, str]]] = defaultdict(dict) + for line in text.splitlines(): + if not line.startswith("PRIMITIVE|"): + continue + _, variant, n, ns, checksum = line.split("|") + cases[int(n)][variant] = (float(ns), checksum) + return cases + + +def same_checksum(values, rtol: float) -> bool: + nums = [float(v) for v in values] + return max(nums) - min(nums) <= rtol * max(abs(x) for x in nums) + + +def evaluate(cases, tolerance: float, checksum_rtol: float = 0.0) -> list[str]: + problems = [] + for n, variants in sorted(cases.items()): + if set(variants) != {"inline_for", "inline_matrix_at", "sqdist_f32"}: + problems.append(f"n={n}: missing variants {sorted(variants)}") + continue + sums = {v: c for v, (_, c) in variants.items()} + if not same_checksum(sums.values(), checksum_rtol): + problems.append(f"n={n}: checksums differ {sums}") + prim = variants["sqdist_f32"][0] + for ref in ("inline_for", "inline_matrix_at"): + ratio = prim / variants[ref][0] + if ratio > 1.0 + tolerance: + problems.append(f"n={n}: sqdist_f32 is {ratio:.2f}x the time of {ref}") + return problems + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("output", type=Path) + ap.add_argument("--tolerance", type=float, default=0.10) + ap.add_argument("--checksum-rtol", type=float, default=0.0, + help="allow checksums to differ by this relative amount. Use 1e-6 on a target with fused " + "multiply-add, where the vectorized loop rounds the last bit differently from the scalar one") + args = ap.parse_args() + cases = parse(args.output.read_text()) + if not cases: + print("no PRIMITIVE lines found") + return 1 + for n, v in sorted(cases.items()): + f, m, p = (v[k][0] for k in ("inline_for", "inline_matrix_at", "sqdist_f32")) + print(f"n={n:5d} inline_for {f:9.3f} ns inline_matrix_at {m:9.3f} ns sqdist_f32 {p:9.3f} ns ratio {p / f:.2f} / {p / m:.2f}") + problems = evaluate(cases, args.tolerance, args.checksum_rtol) + for p in problems: + print("FAIL", p) + return 1 if problems else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/benchmarks/hot_primitive_audit.json b/benchmarks/hot_primitive_audit.json new file mode 100644 index 0000000..45cf68b --- /dev/null +++ b/benchmarks/hot_primitive_audit.json @@ -0,0 +1,3892 @@ +{ + "schema_version": 1, + "defined_primitives": [ + "array_dot", + "blas_dot", + "blas_dot_strided_f64", + "blas_matvec", + "cblas_ddot", + "cblas_dgemm", + "cblas_sdot", + "cblas_sgemm", + "dot_product", + "sqdist_f32", + "sqdist_f32_acc_f64" + ], + "primitive_call_sites": { + "array_dot": 1, + "blas_dot": 11, + "blas_dot_strided_f64": 3, + "blas_matvec": 13, + "cblas_ddot": 1, + "cblas_dgemm": 2, + "cblas_sdot": 1, + "cblas_sgemm": 15, + "dot_product": 4, + "sqdist_f32": 10, + "sqdist_f32_acc_f64": 1 + }, + "summary": { + "squared-distance": { + "primitive": 2, + "shared": 0, + "inline": 116, + "inline_functions": [ + "_bic_kmeans", + "_bic_piecewise_error", + "_euclidean_dist_row", + "_fs_anova_f_scores", + "_kernel_compute", + "_kmeans_assign", + "_kmeans_lloyd_scratch", + "_kmeans_nearest_centroid", + "_kmeans_run", + "_kmeans_sk_pp_init", + "_mse", + "_mtl_columns", + "_r2_score", + "affinity_propagation_fit", + "agglomerative_clustering_fit", + "array_std", + "bayesian_ridge_fit", + "birch_fit", + "birch_predict", + "bisecting_kmeans_fit", + "brier_score_loss", + "calinski_harabasz_score", + "compute_std_col", + "davies_bouldin_score", + "dbscan_fit", + "elastic_net_cv_fit", + "estimate_bandwidth", + "euclidean_distances", + "explained_variance_score", + "f_classif", + "f_regression", + "gaussian_mixture_fit", + "hdbscan_fit", + "isolation_forest_fit", + "isomap_fit", + "iterative_imputer_fit", + "kernel_density_score_samples", + "kmeans_plusplus_init", + "kmeans_transform", + "kneighbors_transformer_transform", + "knn_classifier_predict_proba", + "knn_regressor_predict", + "lars_cv_fit", + "lasso_cv_fit", + "lasso_fit", + "lasso_lars_cv_fit", + "lasso_lars_ic_fit", + "ledoit_wolf_cv_fit", + "ledoit_wolf_estimate", + "ledoit_wolf_estimate_weighted", + "lin353_sse", + "lin357_newton_fit", + "lle_fit", + "local_outlier_factor_fit", + "mds_fit", + "mean_shift_fit", + "mean_shift_predict", + "mean_squared_error", + "mean_squared_log_error", + "minibatch_kmeans_fit", + "minibatch_kmeans_predict", + "minibatch_nmf_fit", + "multitask_elastic_net_cv_fit", + "multitask_lasso_cv_fit", + "nca_fit", + "nearest_centroid_predict", + "nearest_neighbors_kneighbors", + "nmf_fit", + "nu_svc_predict", + "nu_svr_predict", + "one_class_svm_predict", + "optics_fit", + "permutation_importance_classifier", + "permutation_importance_regression", + "permutation_importance_rf_classifier", + "permutation_importance_rf_regression", + "pls_fit", + "power_transformer_transform", + "r2_score", + "radius_neighbors_classifier_predict", + "radius_neighbors_regressor_predict", + "radius_neighbors_transformer_transform", + "rfecv_fit", + "ridge_cv_fit", + "select_k_best_fit", + "sequential_feature_selector_fit", + "silhouette_samples", + "silhouette_score", + "spectral_embedding_fit", + "standard_scaler_fit", + "transformed_target_regressor_fit", + "trustworthiness", + "tsne_fit" + ] + }, + "dot": { + "primitive": 1, + "shared": 14, + "inline": 233, + "inline_functions": [ + "_build_regressor_tree", + "_centered_dot", + "_gp_linear_kernel", + "_gram_schmidt", + "_ipca_top_eigenvectors", + "_kernel_compute", + "_kernel_func", + "_kernel_svc_smo_precomputed", + "_kmeans_sk_pp_init", + "_kr_dot_f64", + "_mcd_distances", + "_omp_sparse_coding_update", + "_svm_compute_ej", + "_svm_kernel_vec", + "ard_regression_fit", + "ard_regression_predict", + "bayesian_gaussian_mixture_fit", + "bayesian_ridge_fit", + "bayesian_ridge_predict", + "bernoulli_rbm_fit", + "bernoulli_rbm_gibbs_sample", + "bernoulli_rbm_transform", + "cca_fit", + "cca_transform", + "complement_nb_predict", + "cosine_distances", + "dictionary_learning_fit", + "elastic_net_cv_fit", + "elastic_net_cv_predict", + "elastic_net_predict", + "empirical_covariance_mahalanobis", + "factor_analysis_fit", + "factor_analysis_transform", + "fast_ica_fit", + "fast_ica_transform", + "gaussian_process_classifier_fit", + "gaussian_process_regressor_predict", + "gaussian_process_regressor_predict_with_std", + "gaussian_random_projection_transform", + "graphical_lasso_cv_fit", + "graphical_lasso_fit", + "huber_regressor_fit", + "huber_regressor_predict", + "incremental_pca_transform", + "iterative_imputer_fit", + "label_propagation_fit", + "lars_cv_predict", + "lars_fit", + "lars_predict", + "lasso_cd_cols_f64", + "lasso_cd_stream_f64", + "lasso_cv_fit", + "lasso_cv_predict", + "lasso_fit", + "lasso_lars_cv_predict", + "lasso_lars_fit", + "lasso_lars_ic_predict", + "lasso_lars_predict", + "lasso_predict", + "lda_transform", + "ledoit_wolf_estimate_weighted", + "ledoit_wolf_estimator_fit_weighted", + "lin353_sse", + "linear_regression_predict", + "linear_svc_decision_function", + "linear_svc_fit", + "linear_svc_fit_sparse", + "linear_svc_multi_decision_function", + "linear_svr_fit", + "logistic_decision_function", + "logistic_inference_fit", + "logistic_regression_cv_predict", + "logistic_regression_fit_sparse", + "make_regression", + "matrix_multiply", + "matrix_multiply_vec", + "minibatch_dictionary_learning_transform", + "minibatch_nmf_fit", + "minibatch_nmf_transform", + "minibatch_sparse_pca_fit", + "minibatch_sparse_pca_transform", + "mlp_classifier_fit", + "mlp_classifier_predict", + "mlp_regressor_fit", + "mlp_regressor_predict", + "multiclass_logistic_fit", + "multiclass_logistic_predict", + "multiclass_precision_ovr", + "multiclass_recall_ovr", + "multinomial_nb_predict", + "multinomial_nb_predict_proba", + "multitask_elastic_net_cv_fit", + "multitask_elastic_net_cv_predict", + "multitask_elastic_net_predict", + "multitask_lasso_cv_fit", + "multitask_lasso_cv_predict", + "multitask_lasso_predict", + "nca_transform", + "nmf_transform", + "nu_svc_fit", + "nu_svc_predict", + "nystroem_fit", + "nystroem_transform", + "oas_cv_fit", + "ols_inference_fit", + "omp_cv_fit", + "omp_cv_predict", + "one_class_svm_fit", + "one_vs_one_predict", + "one_vs_rest_predict", + "orthogonal_matching_pursuit_fit", + "orthogonal_matching_pursuit_predict", + "output_code_predict", + "passive_aggressive_classifier_fit", + "passive_aggressive_classifier_predict", + "passive_aggressive_regressor_fit", + "passive_aggressive_regressor_predict", + "pca_inverse_transform", + "perceptron_fit", + "perceptron_predict", + "pls_canonical_transform", + "pls_fit", + "pls_svd_fit", + "pls_svd_transform", + "quantile_regressor_fit", + "quantile_regressor_predict", + "ransac_regressor_predict", + "rbf_sampler_transform", + "rfe_fit", + "ridge_classifier_cv_fit", + "ridge_classifier_cv_predict", + "ridge_classifier_decision_function", + "ridge_classifier_fit", + "ridge_classifier_predict", + "ridge_cv_fit", + "ridge_cv_predict", + "ridge_predict", + "sgd_classifier_fit", + "sgd_classifier_predict", + "sgd_one_class_svm_decision_function", + "sgd_one_class_svm_fit", + "sgd_one_class_svm_predict", + "sgd_regressor_fit", + "sgd_regressor_predict", + "sparse_coder_transform", + "sparse_dot_dense", + "sparse_dot_row", + "sparse_pca_fit", + "sparse_pca_transform", + "sparse_random_projection_transform", + "spectral_clustering_fit", + "stacking_classifier_fit", + "stacking_classifier_full_fit", + "stacking_classifier_full_predict", + "stacking_classifier_predict", + "stacking_regressor_fit", + "theil_sen_regressor_predict", + "truncated_svd_fit", + "truncated_svd_transform" + ] + }, + "sum-reduction": { + "primitive": 0, + "shared": 0, + "inline": 93, + "inline_functions": [ + "_array_sum_f32", + "_bic_bistochastic", + "_build_classifier_tree", + "_build_classifier_tree_rf", + "_build_regressor_tree", + "_col_means", + "_find_best_hist_split", + "_fs_anova_f_scores", + "_kmeans_assign", + "_kmeans_sk_pp_init", + "_mean_val", + "_mse", + "_softmax", + "_softmax_probs", + "adaboost_classifier_fit", + "adaboost_regressor_fit", + "adaboost_regressor_predict", + "affinity_propagation_fit", + "array_mean", + "bernoulli_nb_predict", + "bernoulli_rbm_fit", + "bisecting_kmeans_fit", + "calinski_harabasz_score", + "chi2", + "compute_joint_probabilities", + "compute_mean_col", + "d2_absolute_error_score", + "decision_tree_classifier_feature_importances", + "decision_tree_regressor_feature_importances", + "dict_vectorizer_fit", + "dict_vectorizer_transform", + "dummy_regressor_fit", + "empirical_covariance_fit", + "f_classif", + "fast_ica_fit", + "feature_agglomeration_transform", + "gaussian_mixture_fit", + "graphical_lasso_cv_fit", + "graphical_lasso_fit", + "hist_gradient_boosting_regressor_fit", + "iterative_imputer_fit", + "kmeans_plusplus_init", + "knn_imputer_fit", + "knn_imputer_transform", + "label_propagation_fit", + "lasso_lars_fit", + "lda_transform", + "ledoit_wolf_cv_fit", + "ledoit_wolf_estimate", + "ledoit_wolf_estimate_weighted", + "ledoit_wolf_estimator_fit_weighted", + "lin433_softmax_block", + "linear_svc_fit", + "min_cov_det_fit", + "minibatch_sparse_pca_fit", + "multiclass_f1_ovr", + "multiclass_precision_ovo", + "multiclass_precision_ovr", + "multiclass_recall_ovo", + "multiclass_recall_ovr", + "multinomial_nb_fit", + "multinomial_nb_predict_proba", + "oas_cv_fit", + "oas_estimate", + "partial_dependence", + "pca_fit", + "permutation_test_score", + "select_k_best_fit", + "shrunk_covariance_fit", + "sparse_pca_fit", + "truncated_svd_fit", + "tsne_fit" + ] + }, + "rbf": { + "primitive": 0, + "shared": 0, + "inline": 16, + "inline_functions": [ + "_beta_func", + "_build_affinity", + "_build_rbf_affinity", + "_gp_rbf_kernel", + "_kernel_compute", + "_kernel_func", + "_rbf_exp", + "_rbf_exp_f64", + "_svm_kernel_vec", + "gaussian_process_classifier_fit", + "gaussian_process_classifier_predict", + "kernel_compute", + "nu_svr_predict", + "one_class_svm_predict", + "spectral_embedding_fit" + ] + }, + "row-partition": { + "primitive": 0, + "shared": 0, + "inline": 20, + "inline_functions": [ + "_find_best_hist_split", + "_hist_tree_add_split", + "_split_samples", + "_tree_split_goes_left", + "bootstrap_oob_get_split", + "bootstrap_oob_init", + "group_kfold_split", + "group_shuffle_split_get_split", + "group_shuffle_split_init", + "leave_one_group_out_split", + "leave_p_group_out_split", + "leave_p_out_get_split", + "repeated_stratified_k_fold_split", + "shuffle_split_get_split", + "shuffle_split_init", + "stratified_shuffle_split_get_split", + "stratified_shuffle_split_init", + "time_series_split", + "train_test_split", + "train_test_split_free" + ] + } + }, + "sites": [ + { + "file": "lib/scikit/calibration.flow", + "function": "_beta_func", + "line": 228, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "_kmeans_assign", + "line": 153, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "_kmeans_assign", + "line": 208, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "_kmeans_run", + "line": 298, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "_kmeans_sk_pp_init", + "line": 387, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "_kmeans_sk_pp_init", + "line": 406, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "_kmeans_sk_pp_init", + "line": 426, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "_kmeans_sk_pp_init", + "line": 440, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "_kmeans_sk_pp_init", + "line": 460, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "_kmeans_lloyd_scratch", + "line": 585, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "_kmeans_nearest_centroid", + "line": 697, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "kmeans_transform", + "line": 869, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "dbscan_fit", + "line": 981, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "dbscan_fit", + "line": 1016, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "agglomerative_clustering_fit", + "line": 1140, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "minibatch_kmeans_fit", + "line": 1335, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "minibatch_kmeans_predict", + "line": 1379, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "mean_shift_fit", + "line": 1437, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "mean_shift_fit", + "line": 1458, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "mean_shift_fit", + "line": 1480, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "mean_shift_predict", + "line": 1522, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "birch_fit", + "line": 1624, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "birch_predict", + "line": 1725, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "_build_rbf_affinity", + "line": 1775, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "spectral_clustering_fit", + "line": 1820, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "spectral_clustering_fit", + "line": 1829, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "spectral_clustering_fit", + "line": 1839, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "affinity_propagation_fit", + "line": 1934, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "affinity_propagation_fit", + "line": 1947, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "optics_fit", + "line": 2169, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "optics_fit", + "line": 2211, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "bisecting_kmeans_fit", + "line": 2314, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "bisecting_kmeans_fit", + "line": 2342, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "hdbscan_fit", + "line": 2448, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "feature_agglomeration_transform", + "line": 2849, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "estimate_bandwidth", + "line": 2893, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "kmeans_plusplus_init", + "line": 2962, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cluster.flow", + "function": "kmeans_plusplus_init", + "line": 2986, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/compose.flow", + "function": "transformed_target_regressor_fit", + "line": 296, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "empirical_covariance_fit", + "line": 34, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "empirical_covariance_mahalanobis", + "line": 163, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "shrunk_covariance_fit", + "line": 207, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "oas_estimate", + "line": 280, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "ledoit_wolf_estimate", + "line": 352, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "ledoit_wolf_estimate", + "line": 390, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "ledoit_wolf_estimate", + "line": 403, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "ledoit_wolf_estimate_weighted", + "line": 438, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "ledoit_wolf_estimate_weighted", + "line": 449, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "ledoit_wolf_estimate_weighted", + "line": 487, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "ledoit_wolf_estimator_fit_weighted", + "line": 538, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "ledoit_wolf_estimator_fit_weighted", + "line": 548, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "graphical_lasso_fit", + "line": 623, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "graphical_lasso_fit", + "line": 700, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "min_cov_det_fit", + "line": 775, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "graphical_lasso_cv_fit", + "line": 889, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "graphical_lasso_cv_fit", + "line": 951, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "ledoit_wolf_cv_fit", + "line": 1008, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "ledoit_wolf_cv_fit", + "line": 1058, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "oas_cv_fit", + "line": 1126, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "oas_cv_fit", + "line": 1151, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "oas_cv_fit", + "line": 1160, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/covariance.flow", + "function": "_mcd_distances", + "line": 1288, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "compute_mean_col", + "line": 29, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "compute_std_col", + "line": 38, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "pls_fit", + "line": 102, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "pls_fit", + "line": 108, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "pls_fit", + "line": 120, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "pls_fit", + "line": 129, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "pls_fit", + "line": 138, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "pls_fit", + "line": 146, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "pls_fit", + "line": 169, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "pls_fit", + "line": 176, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "cca_fit", + "line": 438, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "cca_fit", + "line": 474, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "cca_fit", + "line": 489, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "cca_transform", + "line": 550, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "pls_canonical_transform", + "line": 717, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "pls_svd_fit", + "line": 784, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/cross_decomposition.flow", + "function": "pls_svd_transform", + "line": 885, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/datasets.flow", + "function": "make_regression", + "line": 103, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "pca_fit", + "line": 130, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "pca_fit", + "line": 137, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "pca_fit", + "line": 153, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "pca_fit", + "line": 158, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "pca_fit", + "line": 177, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "pca_inverse_transform", + "line": 251, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "nmf_fit", + "line": 370, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "nmf_transform", + "line": 405, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "truncated_svd_fit", + "line": 451, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "truncated_svd_fit", + "line": 458, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "truncated_svd_fit", + "line": 473, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "truncated_svd_fit", + "line": 478, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "truncated_svd_fit", + "line": 495, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "truncated_svd_transform", + "line": 527, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "_gram_schmidt", + "line": 567, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "_gram_schmidt", + "line": 575, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "fast_ica_fit", + "line": 597, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "fast_ica_fit", + "line": 638, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "fast_ica_fit", + "line": 678, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "fast_ica_fit", + "line": 697, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "fast_ica_fit", + "line": 711, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "fast_ica_transform", + "line": 746, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "sparse_pca_fit", + "line": 812, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "sparse_pca_fit", + "line": 836, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "sparse_pca_fit", + "line": 858, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "sparse_pca_fit", + "line": 886, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "sparse_pca_transform", + "line": 930, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "minibatch_sparse_pca_fit", + "line": 972, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "minibatch_sparse_pca_fit", + "line": 996, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "minibatch_sparse_pca_fit", + "line": 1023, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "minibatch_sparse_pca_fit", + "line": 1053, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "minibatch_sparse_pca_transform", + "line": 1097, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "_kernel_compute", + "line": 1140, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "_kernel_compute", + "line": 1142, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "_kernel_compute", + "line": 1147, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "_kernel_compute", + "line": 1158, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "kernel_pca_fit", + "line": 1225, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "kernel_pca_fit", + "line": 1251, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "factor_analysis_fit", + "line": 1417, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "factor_analysis_fit", + "line": 1450, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "factor_analysis_transform", + "line": 1494, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "_ipca_top_eigenvectors", + "line": 1600, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "incremental_pca_transform", + "line": 1800, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "dictionary_learning_fit", + "line": 1871, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "dictionary_learning_transform", + "line": 2025, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "_omp_sparse_coding_update", + "line": 2086, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "minibatch_dictionary_learning_transform", + "line": 2250, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "_array_sum_f32", + "line": 2299, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "lda_transform", + "line": 2464, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "lda_transform", + "line": 2474, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "minibatch_nmf_fit", + "line": 2559, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "minibatch_nmf_fit", + "line": 2590, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "minibatch_nmf_fit", + "line": 2599, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "minibatch_nmf_fit", + "line": 2630, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/decomposition.flow", + "function": "minibatch_nmf_transform", + "line": 2660, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/dummy.flow", + "function": "dummy_regressor_fit", + "line": 163, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "adaboost_classifier_fit", + "line": 1102, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "adaboost_classifier_fit", + "line": 1110, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "adaboost_classifier_fit", + "line": 1135, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "adaboost_classifier_fit", + "line": 1153, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "adaboost_regressor_fit", + "line": 1279, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "adaboost_regressor_fit", + "line": 1287, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "adaboost_regressor_fit", + "line": 1350, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "adaboost_regressor_predict", + "line": 1461, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "isolation_forest_fit", + "line": 1780, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "stacking_classifier_full_fit", + "line": 1943, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "stacking_classifier_full_predict", + "line": 2001, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "stacking_classifier_fit", + "line": 2052, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "stacking_classifier_predict", + "line": 2089, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "_hist_tree_add_split", + "line": 2289, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "_find_best_hist_split", + "line": 2349, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "_find_best_hist_split", + "line": 2350, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "_find_best_hist_split", + "line": 2367, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "_find_best_hist_split", + "line": 2368, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "_find_best_hist_split", + "line": 2334, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "_split_samples", + "line": 2399, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "hist_gradient_boosting_regressor_fit", + "line": 2696, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "stacking_regressor_fit", + "line": 3067, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/ensemble.flow", + "function": "stacking_regressor_fit", + "line": 3068, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "sparse_coder_transform", + "line": 77, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "sparse_coder_transform", + "line": 99, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "_bic_kmeans", + "line": 299, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "_bic_bistochastic", + "line": 382, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "_bic_piecewise_error", + "line": 453, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "lasso_lars_ic_fit", + "line": 835, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "lasso_lars_ic_predict", + "line": 907, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "omp_cv_fit", + "line": 957, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "omp_cv_fit", + "line": 976, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "omp_cv_fit", + "line": 988, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "omp_cv_fit", + "line": 1015, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "omp_cv_fit", + "line": 1033, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "omp_cv_predict", + "line": 1060, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "nca_fit", + "line": 1146, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "nca_transform", + "line": 1241, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "sgd_one_class_svm_fit", + "line": 1282, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "sgd_one_class_svm_predict", + "line": 1317, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/extra_estimators.flow", + "function": "sgd_one_class_svm_decision_function", + "line": 1334, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/feature_extraction_extra.flow", + "function": "dict_vectorizer_fit", + "line": 76, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/feature_extraction_extra.flow", + "function": "dict_vectorizer_transform", + "line": 185, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "select_k_best_fit", + "line": 47, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "select_k_best_fit", + "line": 59, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "select_k_best_fit", + "line": 71, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "select_k_best_fit", + "line": 194, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "select_k_best_fit", + "line": 195, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "rfe_fit", + "line": 432, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "rfecv_fit", + "line": 529, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "sequential_feature_selector_fit", + "line": 634, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "sequential_feature_selector_fit", + "line": 690, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "_fs_anova_f_scores", + "line": 796, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "_fs_anova_f_scores", + "line": 808, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "_fs_anova_f_scores", + "line": 819, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "chi2", + "line": 1650, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "f_classif", + "line": 1723, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "f_classif", + "line": 1734, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "f_regression", + "line": 1792, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/feature_selection.flow", + "function": "f_regression", + "line": 1793, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/gaussian_process.flow", + "function": "_gp_rbf_kernel", + "line": 36, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/gaussian_process.flow", + "function": "_gp_linear_kernel", + "line": 42, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/gaussian_process.flow", + "function": "gaussian_process_regressor_predict", + "line": 193, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/gaussian_process.flow", + "function": "gaussian_process_regressor_predict_with_std", + "line": 236, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/gaussian_process.flow", + "function": "gaussian_process_classifier_fit", + "line": 306, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/gaussian_process.flow", + "function": "gaussian_process_classifier_fit", + "line": 314, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/gaussian_process.flow", + "function": "gaussian_process_classifier_predict", + "line": 348, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/impute.flow", + "function": "_euclidean_dist_row", + "line": 41, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/impute.flow", + "function": "knn_imputer_fit", + "line": 112, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/impute.flow", + "function": "knn_imputer_transform", + "line": 150, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/impute.flow", + "function": "iterative_imputer_fit", + "line": 241, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/impute.flow", + "function": "iterative_imputer_fit", + "line": 251, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/impute.flow", + "function": "iterative_imputer_fit", + "line": 262, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/impute.flow", + "function": "iterative_imputer_fit", + "line": 276, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/inspection.flow", + "function": "_r2_score", + "line": 34, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/inspection.flow", + "function": "_r2_score", + "line": 36, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/inspection.flow", + "function": "permutation_importance_regression", + "line": 116, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/inspection.flow", + "function": "permutation_importance_classifier", + "line": 170, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/inspection.flow", + "function": "permutation_importance_rf_regression", + "line": 224, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/inspection.flow", + "function": "permutation_importance_rf_classifier", + "line": 278, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/inspection.flow", + "function": "partial_dependence", + "line": 375, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_approximation.flow", + "function": "rbf_sampler_transform", + "line": 74, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_approximation.flow", + "function": "_kernel_func", + "line": 115, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_approximation.flow", + "function": "_kernel_func", + "line": 120, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_approximation.flow", + "function": "nystroem_fit", + "line": 180, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_approximation.flow", + "function": "nystroem_fit", + "line": 187, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_approximation.flow", + "function": "nystroem_fit", + "line": 203, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_approximation.flow", + "function": "nystroem_fit", + "line": 209, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_approximation.flow", + "function": "nystroem_transform", + "line": 279, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_ridge.flow", + "function": "kernel_compute", + "line": 52, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_ridge.flow", + "function": "_kr_dot_f64", + "line": 308, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_ridge.flow", + "function": "_kr_dot_f64", + "line": 309, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_ridge.flow", + "function": "_kr_dot_f64", + "line": 310, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_ridge.flow", + "function": "_kr_dot_f64", + "line": 311, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_ridge.flow", + "function": "_kr_dot_f64", + "line": 312, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_ridge.flow", + "function": "_kr_dot_f64", + "line": 313, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_ridge.flow", + "function": "_kr_dot_f64", + "line": 314, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_ridge.flow", + "function": "_kr_dot_f64", + "line": 315, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_ridge.flow", + "function": "_kr_dot_f64", + "line": 320, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/kernel_ridge.flow", + "function": "_kr_predict_rbf", + "line": 367, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/kernel_ridge.flow", + "function": "kernel_ridge_predict", + "line": 422, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/linear.flow", + "function": "linear_regression_predict", + "line": 563, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lin353_sse", + "line": 714, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lin353_sse", + "line": 717, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ols_inference_fit", + "line": 866, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lin433_softmax_block", + "line": 1029, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lin357_newton_fit", + "line": 1756, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "logistic_regression_fit_sparse", + "line": 2153, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "logistic_decision_function", + "line": 2345, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "logistic_inference_fit", + "line": 2527, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ridge_predict", + "line": 2796, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_cd_cols_f64", + "line": 2901, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_cd_cols_f64", + "line": 2903, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_cd_stream_f64", + "line": 2947, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_fit", + "line": 3021, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_fit", + "line": 3069, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_fit", + "line": 3079, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_predict", + "line": 3142, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "sgd_classifier_fit", + "line": 3189, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "sgd_classifier_predict", + "line": 3239, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "sgd_regressor_fit", + "line": 3290, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "sgd_regressor_predict", + "line": 3336, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "multiclass_logistic_fit", + "line": 3393, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "_softmax_probs", + "line": 3461, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "multiclass_logistic_predict", + "line": 3476, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "elastic_net_predict", + "line": 3681, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ridge_classifier_fit", + "line": 3713, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ridge_classifier_predict", + "line": 3746, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ridge_classifier_decision_function", + "line": 3765, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "huber_regressor_fit", + "line": 3803, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "huber_regressor_predict", + "line": 3886, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "bayesian_ridge_fit", + "line": 4004, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "bayesian_ridge_fit", + "line": 4009, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "bayesian_ridge_predict", + "line": 4050, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ransac_regressor_predict", + "line": 4167, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "theil_sen_regressor_predict", + "line": 4272, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "perceptron_fit", + "line": 4306, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "perceptron_predict", + "line": 4336, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "passive_aggressive_classifier_fit", + "line": 4371, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "passive_aggressive_classifier_fit", + "line": 4379, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "passive_aggressive_classifier_predict", + "line": 4406, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lars_fit", + "line": 4467, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lars_fit", + "line": 4483, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lars_fit", + "line": 4484, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lars_predict", + "line": 4541, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ard_regression_fit", + "line": 4605, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ard_regression_fit", + "line": 4606, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ard_regression_fit", + "line": 4614, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ard_regression_fit", + "line": 4623, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ard_regression_fit", + "line": 4625, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ard_regression_predict", + "line": 4657, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "orthogonal_matching_pursuit_fit", + "line": 4724, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "orthogonal_matching_pursuit_fit", + "line": 4750, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "orthogonal_matching_pursuit_fit", + "line": 4756, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "orthogonal_matching_pursuit_fit", + "line": 4790, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "orthogonal_matching_pursuit_predict", + "line": 4825, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "quantile_regressor_fit", + "line": 4863, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "quantile_regressor_predict", + "line": 4907, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "_mtl_columns", + "line": 4961, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "multitask_lasso_predict", + "line": 5142, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "multitask_elastic_net_predict", + "line": 5225, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ridge_cv_fit", + "line": 5375, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ridge_cv_fit", + "line": 5378, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ridge_cv_predict", + "line": 5426, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_cv_fit", + "line": 5504, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_cv_fit", + "line": 5508, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_cv_predict", + "line": 5551, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "elastic_net_cv_fit", + "line": 5623, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "elastic_net_cv_fit", + "line": 5626, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "elastic_net_cv_predict", + "line": 5672, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ridge_classifier_cv_fit", + "line": 5749, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "ridge_classifier_cv_predict", + "line": 5804, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "passive_aggressive_regressor_fit", + "line": 5844, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "passive_aggressive_regressor_fit", + "line": 5854, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "passive_aggressive_regressor_predict", + "line": 5897, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "logistic_regression_cv_predict", + "line": 6028, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lars_cv_fit", + "line": 6121, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lars_cv_predict", + "line": 6172, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "_col_means", + "line": 6207, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "_centered_dot", + "line": 6339, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_lars_fit", + "line": 6466, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_lars_fit", + "line": 6499, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_lars_predict", + "line": 6658, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_lars_cv_fit", + "line": 6734, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "lasso_lars_cv_predict", + "line": 6800, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "multitask_lasso_cv_fit", + "line": 6899, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "multitask_lasso_cv_fit", + "line": 6902, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "multitask_lasso_cv_predict", + "line": 6966, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "multitask_elastic_net_cv_fit", + "line": 7086, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "multitask_elastic_net_cv_fit", + "line": 7089, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/linear.flow", + "function": "multitask_elastic_net_cv_predict", + "line": 7154, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "compute_joint_probabilities", + "line": 63, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "tsne_fit", + "line": 151, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "tsne_fit", + "line": 154, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "tsne_fit", + "line": 182, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "tsne_fit", + "line": 206, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "tsne_fit", + "line": 225, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "tsne_fit", + "line": 228, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "isomap_fit", + "line": 351, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "lle_fit", + "line": 482, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "spectral_embedding_fit", + "line": 614, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "spectral_embedding_fit", + "line": 616, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "mds_fit", + "line": 726, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "mds_fit", + "line": 770, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "mds_fit", + "line": 777, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "trustworthiness", + "line": 848, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/manifold.flow", + "function": "trustworthiness", + "line": 868, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/matrix.flow", + "function": "matrix_multiply", + "line": 83, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/matrix.flow", + "function": "matrix_multiply_vec", + "line": 95, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/matrix.flow", + "function": "array_mean", + "line": 351, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/matrix.flow", + "function": "array_std", + "line": 360, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/matrix.flow", + "function": "array_dot", + "line": 403, + "category": "dot", + "status": "primitive" + }, + { + "file": "lib/scikit/matrix.flow", + "function": "sqdist_f32", + "line": 444, + "category": "squared-distance", + "status": "primitive" + }, + { + "file": "lib/scikit/matrix.flow", + "function": "sqdist_f32_acc_f64", + "line": 457, + "category": "squared-distance", + "status": "primitive" + }, + { + "file": "lib/scikit/meta_estimators.flow", + "function": "one_vs_rest_predict", + "line": 93, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/meta_estimators.flow", + "function": "one_vs_one_predict", + "line": 221, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/meta_estimators.flow", + "function": "output_code_predict", + "line": 359, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "mean_squared_error", + "line": 319, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "r2_score", + "line": 347, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "r2_score", + "line": 349, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "explained_variance_score", + "line": 716, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "explained_variance_score", + "line": 717, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "mean_squared_log_error", + "line": 818, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "silhouette_score", + "line": 836, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "silhouette_score", + "line": 865, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "brier_score_loss", + "line": 1135, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "euclidean_distances", + "line": 1151, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "cosine_distances", + "line": 1178, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "cosine_distances", + "line": 1187, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "cosine_distances", + "line": 1188, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "multiclass_precision_ovr", + "line": 1245, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "multiclass_precision_ovr", + "line": 1246, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "multiclass_precision_ovr", + "line": 1247, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "multiclass_recall_ovr", + "line": 1312, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "multiclass_recall_ovr", + "line": 1313, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "multiclass_recall_ovr", + "line": 1314, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "multiclass_f1_ovr", + "line": 1371, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "multiclass_precision_ovo", + "line": 1466, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "multiclass_recall_ovo", + "line": 1505, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "calinski_harabasz_score", + "line": 2045, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "calinski_harabasz_score", + "line": 2077, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "davies_bouldin_score", + "line": 2140, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "davies_bouldin_score", + "line": 2160, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "d2_absolute_error_score", + "line": 2596, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "silhouette_samples", + "line": 2637, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/metrics.flow", + "function": "silhouette_samples", + "line": 2661, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/mixture.flow", + "function": "gaussian_mixture_fit", + "line": 122, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/mixture.flow", + "function": "gaussian_mixture_fit", + "line": 150, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/mixture.flow", + "function": "gaussian_mixture_fit", + "line": 219, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/mixture.flow", + "function": "bayesian_gaussian_mixture_fit", + "line": 498, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "train_test_split", + "line": 37, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "train_test_split_free", + "line": 192, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "shuffle_split_init", + "line": 874, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "shuffle_split_get_split", + "line": 878, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "time_series_split", + "line": 942, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "bootstrap_oob_init", + "line": 1155, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "bootstrap_oob_get_split", + "line": 1163, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "permutation_test_score", + "line": 1429, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "leave_p_out_get_split", + "line": 1534, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "stratified_shuffle_split_init", + "line": 1597, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "stratified_shuffle_split_get_split", + "line": 1608, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "group_kfold_split", + "line": 1727, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "repeated_stratified_k_fold_split", + "line": 1864, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "leave_one_group_out_split", + "line": 1963, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "leave_p_group_out_split", + "line": 2052, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "group_shuffle_split_init", + "line": 2193, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/model_selection.flow", + "function": "group_shuffle_split_get_split", + "line": 2200, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/naive_bayes.flow", + "function": "multinomial_nb_fit", + "line": 392, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/naive_bayes.flow", + "function": "multinomial_nb_predict", + "line": 426, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/naive_bayes.flow", + "function": "multinomial_nb_predict_proba", + "line": 450, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/naive_bayes.flow", + "function": "multinomial_nb_predict_proba", + "line": 461, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/naive_bayes.flow", + "function": "bernoulli_nb_predict", + "line": 604, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/naive_bayes.flow", + "function": "bernoulli_nb_predict", + "line": 606, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/naive_bayes.flow", + "function": "complement_nb_predict", + "line": 734, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neighbors.flow", + "function": "knn_classifier_predict_proba", + "line": 134, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/neighbors.flow", + "function": "knn_regressor_predict", + "line": 244, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/neighbors.flow", + "function": "nearest_neighbors_kneighbors", + "line": 315, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/neighbors.flow", + "function": "radius_neighbors_classifier_predict", + "line": 423, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/neighbors.flow", + "function": "radius_neighbors_regressor_predict", + "line": 481, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/neighbors.flow", + "function": "nearest_centroid_predict", + "line": 566, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/neighbors.flow", + "function": "local_outlier_factor_fit", + "line": 629, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/neighbors.flow", + "function": "local_outlier_factor_fit", + "line": 712, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/neighbors.flow", + "function": "kernel_density_score_samples", + "line": 898, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/neighbors.flow", + "function": "kneighbors_transformer_transform", + "line": 997, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/neighbors.flow", + "function": "radius_neighbors_transformer_transform", + "line": 1065, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "_softmax", + "line": 74, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "mlp_classifier_fit", + "line": 168, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "mlp_classifier_fit", + "line": 196, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "mlp_classifier_predict", + "line": 259, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "mlp_regressor_fit", + "line": 391, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "mlp_regressor_fit", + "line": 409, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "mlp_regressor_predict", + "line": 468, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "bernoulli_rbm_fit", + "line": 550, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "bernoulli_rbm_fit", + "line": 577, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "bernoulli_rbm_fit", + "line": 613, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "bernoulli_rbm_fit", + "line": 636, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "bernoulli_rbm_fit", + "line": 654, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "bernoulli_rbm_transform", + "line": 720, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "bernoulli_rbm_gibbs_sample", + "line": 742, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/neural_network.flow", + "function": "bernoulli_rbm_gibbs_sample", + "line": 760, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/preprocessing.flow", + "function": "standard_scaler_fit", + "line": 59, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/preprocessing.flow", + "function": "power_transformer_transform", + "line": 1339, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/random_projection.flow", + "function": "gaussian_random_projection_transform", + "line": 70, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/random_projection.flow", + "function": "sparse_random_projection_transform", + "line": 146, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/semi_supervised.flow", + "function": "_build_affinity", + "line": 48, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/semi_supervised.flow", + "function": "_build_affinity", + "line": 59, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/semi_supervised.flow", + "function": "label_propagation_fit", + "line": 78, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/semi_supervised.flow", + "function": "label_propagation_fit", + "line": 139, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/sparse.flow", + "function": "sparse_dot_row", + "line": 130, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/sparse.flow", + "function": "sparse_dot_dense", + "line": 148, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svc_fit", + "line": 86, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svc_fit", + "line": 88, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svc_fit", + "line": 117, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svc_fit", + "line": 224, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svc_fit", + "line": 226, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svc_fit_sparse", + "line": 365, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svc_decision_function", + "line": 429, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svc_multi_decision_function", + "line": 529, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svr_fit", + "line": 620, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svr_fit", + "line": 621, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svr_fit", + "line": 622, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svr_fit", + "line": 623, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "linear_svr_fit", + "line": 628, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "_svm_compute_ej", + "line": 717, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "_kernel_svc_smo_precomputed", + "line": 1003, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "_rbf_exp", + "line": 1048, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "_rbf_exp_f64", + "line": 1053, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "_rbf_row", + "line": 1303, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/svm.flow", + "function": "_rbf_row", + "line": 1304, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/svm.flow", + "function": "_rbf_row", + "line": 1305, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/svm.flow", + "function": "_rbf_row", + "line": 1306, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/svm.flow", + "function": "_rbf_row", + "line": 1311, + "category": "dot", + "status": "shared" + }, + { + "file": "lib/scikit/svm.flow", + "function": "nu_svc_fit", + "line": 1680, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "nu_svc_fit", + "line": 1760, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "nu_svc_predict", + "line": 1876, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "nu_svc_predict", + "line": 1878, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "nu_svr_predict", + "line": 2004, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "nu_svr_predict", + "line": 2006, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "one_class_svm_fit", + "line": 2059, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "one_class_svm_fit", + "line": 2082, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "one_class_svm_predict", + "line": 2122, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "one_class_svm_predict", + "line": 2124, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "_svm_kernel_vec", + "line": 2210, + "category": "rbf", + "status": "inline" + }, + { + "file": "lib/scikit/svm.flow", + "function": "_svm_kernel_vec", + "line": 2216, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_mse", + "line": 142, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_mse", + "line": 148, + "category": "squared-distance", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_mean_val", + "line": 180, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_tree_split_goes_left", + "line": 514, + "category": "row-partition", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_build_classifier_tree", + "line": 913, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_build_classifier_tree_rf", + "line": 1404, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "decision_tree_classifier_feature_importances", + "line": 1802, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_build_regressor_tree", + "line": 1920, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_build_regressor_tree", + "line": 1921, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_build_regressor_tree", + "line": 1977, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_build_regressor_tree", + "line": 1978, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_build_regressor_tree", + "line": 1979, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_build_regressor_tree", + "line": 2035, + "category": "sum-reduction", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "_build_regressor_tree", + "line": 2036, + "category": "dot", + "status": "inline" + }, + { + "file": "lib/scikit/tree.flow", + "function": "decision_tree_regressor_feature_importances", + "line": 2188, + "category": "sum-reduction", + "status": "inline" + } + ] +} diff --git a/lib/scikit/cluster.flow b/lib/scikit/cluster.flow index 3731f80..9f8b67b 100644 --- a/lib/scikit/cluster.flow +++ b/lib/scikit/cluster.flow @@ -113,13 +113,7 @@ function _kmeans_scratch_free(scratch: KMeansScratch) -> void { # Squared distance from one sample to one centroid, accumulated in the same # order as the original per-pair loop. function _kmeans_sqdist(x_data: ptr, x_base: i32, crow: ptr, n_features: i32) -> f32 { - let mut dist: f32 = 0.0 - let xrow: ptr = x_data + x_base - for j in 0 to n_features { - let d: f32 = xrow[j] - crow[j] - dist = dist + d * d - } - return dist + return sqdist_f32(x_data + x_base, crow, n_features) } # One Lloyd assignment pass. Fills labels and returns the inertia. @@ -1777,11 +1771,7 @@ function _build_rbf_affinity(X: Matrix, gamma: f32) -> ptr > { for i in 0 to n { W[i] = array_new_f32(n) for j in 0 to n { - let mut s: f32 = 0.0 - for k in 0 to p { - let d: f32 = matrix_at(X, i, k) - matrix_at(X, j, k) - s = s + d * d - } + let s: f32 = sqdist_f32(X.data + i * p, X.data + j * p, p) W[i][j] = exp((-gamma * s) as f64) as f32 } } diff --git a/lib/scikit/gaussian_process.flow b/lib/scikit/gaussian_process.flow index 361787b..c6dc380 100644 --- a/lib/scikit/gaussian_process.flow +++ b/lib/scikit/gaussian_process.flow @@ -31,11 +31,7 @@ export struct GaussianProcessRegressor { } function _gp_rbf_kernel(x1: ptr, x2: ptr, n: i32, length_scale: f32) -> f32 { - let mut dist_sq: f32 = 0.0 - for i in 0 to n { - let d: f32 = x1[i] - x2[i] - dist_sq = dist_sq + d * d - } + let dist_sq: f32 = sqdist_f32(x1, x2, n) let gamma: f32 = 0.5 / (length_scale * length_scale) return exp((0.0 - gamma * dist_sq) as f64) as f32 } @@ -306,11 +302,7 @@ export function gaussian_process_classifier_fit(X: Matrix, y: ptr, gamma: f for i in 0 to n { K[i] = array_new_f32(n) for j in 0 to n { - let mut s: f32 = 0.0 - for k in 0 to p { - let d: f32 = matrix_at(X, i, k) - matrix_at(X, j, k) - s = s + d * d - } + let s: f32 = sqdist_f32(X.data + i * p, X.data + j * p, p) K[i][j] = exp((-gamma * s) as f64) as f32 } } @@ -352,11 +344,7 @@ export function gaussian_process_classifier_predict(model: GaussianProcessClassi for i in 0 to n { let mut s: f32 = 0.0 for j in 0 to model.n_samples { - let mut dist: f32 = 0.0 - for k in 0 to p { - let d: f32 = matrix_at(X, i, k) - matrix_at(model.X_train, j, k) - dist = dist + d * d - } + let dist: f32 = sqdist_f32(X.data + i * X.cols, model.X_train.data + j * model.X_train.cols, p) let k_val: f32 = exp((-model.gamma * dist) as f64) as f32 s = s + k_val * model.y_train[j] * (1.0 / (1.0 + exp((-model.f[j]) as f64) as f32)) } diff --git a/lib/scikit/kernel_approximation.flow b/lib/scikit/kernel_approximation.flow index 8b1c500..511a6bf 100644 --- a/lib/scikit/kernel_approximation.flow +++ b/lib/scikit/kernel_approximation.flow @@ -116,11 +116,7 @@ function _kernel_func(x1: ptr, x2: ptr, n: i32, kernel: i32, gamma: f3 } return s } - let mut s: f32 = 0.0 - for i in 0 to n { - let d: f32 = x1[i] - x2[i] - s = s + d * d - } + let s: f32 = sqdist_f32(x1, x2, n) return exp((-gamma * s) as f64) as f32 } diff --git a/lib/scikit/kernel_ridge.flow b/lib/scikit/kernel_ridge.flow index 981b007..619b196 100644 --- a/lib/scikit/kernel_ridge.flow +++ b/lib/scikit/kernel_ridge.flow @@ -48,11 +48,7 @@ function kernel_compute(x1: ptr, x2: ptr, n: i32, kernel_type: i32, ga return pow_f32(gamma * dot + coef0, degree) } if kernel_type == KR_KERNEL_RBF { - let mut sum: f32 = 0.0 - for i in 0 to n { - let d: f32 = x1[i] - x2[i] - sum = sum + d * d - } + let sum: f32 = sqdist_f32(x1, x2, n) return exp((0.0 - gamma * sum) as f64) as f32 } if kernel_type == KR_KERNEL_SIGMOID { diff --git a/lib/scikit/manifold.flow b/lib/scikit/manifold.flow index 1a5bd5c..26cd6d5 100644 --- a/lib/scikit/manifold.flow +++ b/lib/scikit/manifold.flow @@ -31,11 +31,7 @@ function compute_pairwise_distances(X: Matrix) -> ptr { if i == j { dist[i * n + j] = 0.0 } else { - let mut sum: f32 = 0.0 - for k in 0 to X.cols { - let d: f32 = matrix_at(X, i, k) - matrix_at(X, j, k) - sum = sum + d * d - } + let sum: f32 = sqdist_f32(X.data + i * X.cols, X.data + j * X.cols, X.cols) dist[i * n + j] = sqrt(sum as f64) as f32 } } diff --git a/lib/scikit/matrix.flow b/lib/scikit/matrix.flow index 04c55e5..ed84adf 100644 --- a/lib/scikit/matrix.flow +++ b/lib/scikit/matrix.flow @@ -422,9 +422,40 @@ export function sigmoid(x: f32) -> f32 { } export function dot_product(a: ptr, b: ptr, n: i32) -> f32 { - let mut sum: f32 = 0.0 - for i in 0 to n { - sum = sum + a[i] * b[i] + return array_dot(a, b, n) +} + +# Squared euclidean distance between two contiguous f32 vectors. +# +# Strict mode: the terms are added in ascending index order with the recurrence +# s = f32(s + f32(d * d)), d = f32(a[k] - b[k]) +# with no norm expansion and no reassociation, so a caller that used to carry +# this loop inline gets the same bits. A row at an offset is passed as +# `data + offset`. The loop is a while loop with a constant step because Flow +# emits a range loop with a runtime stride that LLVM will not vectorize +# (Flow issue #1004). A strict f32 sum is a serial dependency, so the compiler +# cannot widen it without reassociation; a relaxed variant, if one is added, +# must be a separate function with its own tolerance. +export function sqdist_f32(a: ptr, b: ptr, n: i32) -> f32 { + let mut s: f32 = 0.0 + let mut k: i32 = 0 + while k < n { + let d: f32 = a[k] - b[k] + s = s + d * d + k = k + 1 } - return sum + return s +} + +# The same distance with the f32 difference widened and summed in f64: +# s = f64(s + f64(d) * f64(d)), d = f32(a[k] - b[k]) +export function sqdist_f32_acc_f64(a: ptr, b: ptr, n: i32) -> f64 { + let mut s: f64 = 0.0 + let mut k: i32 = 0 + while k < n { + let d: f64 = (a[k] - b[k]) as f64 + s = s + d * d + k = k + 1 + } + return s } diff --git a/lib/scikit/semi_supervised.flow b/lib/scikit/semi_supervised.flow index 150eb3b..34fea01 100644 --- a/lib/scikit/semi_supervised.flow +++ b/lib/scikit/semi_supervised.flow @@ -55,13 +55,7 @@ function _build_affinity(X: Matrix, gamma: f32) -> ptr > { # A while loop with a constant step, because Flow emits a range # loop with a stride chosen at runtime and LLVM will not vectorize # that. Flow issue #1004. - let mut s: f32 = 0.0 - let mut k: i32 = 0 - while k < p { - let d: f32 = X.data[base_i + k] - X.data[base_j + k] - s = s + d * d - k = k + 1 - } + let s: f32 = sqdist_f32(X.data + base_i, X.data + base_j, p) let w: f32 = exp((-gamma * s) as f64) as f32 row_i[j] = w W[j][i] = w diff --git a/lib/scikit/svm.flow b/lib/scikit/svm.flow index f98b54a..1b4a913 100644 --- a/lib/scikit/svm.flow +++ b/lib/scikit/svm.flow @@ -1170,11 +1170,7 @@ function _rbf_kernel(X1: Matrix, X2: Matrix, gamma: f32) -> Matrix { let result: Matrix = matrix_new(X1.rows, X2.rows) for i in 0 to X1.rows { for j in 0 to X2.rows { - let mut sum: f64 = 0.0 - for k in 0 to X1.cols { - let d: f64 = (matrix_at(X1, i, k) - matrix_at(X2, j, k)) as f64 - sum = sum + d * d - } + let sum: f64 = sqdist_f32_acc_f64(X1.data + i * X1.cols, X2.data + j * X2.cols, X1.cols) let val: f32 = _rbf_exp_f64(0.0 - (gamma as f64) * sum) as f32 matrix_set(result, i, j, val) } @@ -2210,13 +2206,7 @@ function _svm_tanh_f32(x: f32) -> f32 { # #1004. function _svm_kernel_vec(r1: ptr, r2: ptr, n_features: i32, kernel: i32, gamma: f32, degree: i32, coef0: f32) -> f32 { if kernel == KERNEL_RBF { - let mut s: f32 = 0.0 - let mut k: i32 = 0 - while k < n_features { - let d: f32 = r1[k] - r2[k] - s = s + d * d - k = k + 1 - } + let s: f32 = sqdist_f32(r1, r2, n_features) return exp((0.0 - gamma * s) as f64) as f32 } diff --git a/tests/test_shared_primitives.flow b/tests/test_shared_primitives.flow new file mode 100644 index 0000000..69343bf --- /dev/null +++ b/tests/test_shared_primitives.flow @@ -0,0 +1,157 @@ +# Shared squared-distance primitives must reproduce the loops they replaced. +# +# Issue #498. sqdist_f32 and sqdist_f32_acc_f64 stand in for inline loops in +# KMeans, KernelRidge, KernelSVC, GaussianProcess, TSNE, SpectralClustering, +# LabelSpreading and kernel approximation. Each reference below is the loop as +# it was written at those sites, in its original form. The primitive must give +# the same bits, with and without a row offset, for the lengths that matter +# to the vector and tail paths. A mismatch exits non-zero. + +import "lib/scikit/scikit.flow" + +function sp_fill(a: ptr, n: i32, seed: i32) -> void { + let mut i: i32 = 0 + while i < n { + let raw: i32 = (i * 37 + seed * 11 + (i * i) % 17) % 101 + a[i] = ((raw - 50) as f32) * 0.173 + ((seed % 5) as f32) * 0.0371 + i = i + 1 + } +} + +# The KMeans, KernelRidge, GaussianProcess and kernel approximation form. +function sp_ref_for(a: ptr, b: ptr, n: i32) -> f32 { + let mut s: f32 = 0.0 + for i in 0 to n { + let d: f32 = a[i] - b[i] + s = s + d * d + } + return s +} + +# The TSNE, SpectralClustering and GaussianProcessClassifier form, which read +# both rows through matrix_at. +function sp_ref_matrix_at(A: Matrix, ra: i32, B: Matrix, rb: i32) -> f32 { + let mut s: f32 = 0.0 + for k in 0 to A.cols { + let d: f32 = matrix_at(A, ra, k) - matrix_at(B, rb, k) + s = s + d * d + } + return s +} + +# The KernelSVC form: f32 difference, f64 accumulation. +function sp_ref_f64(A: Matrix, ra: i32, B: Matrix, rb: i32) -> f64 { + let mut sum: f64 = 0.0 + for k in 0 to A.cols { + let d: f64 = (matrix_at(A, ra, k) - matrix_at(B, rb, k)) as f64 + sum = sum + d * d + } + return sum +} + +function sp_check_length(n: i32) -> i32 { + let rows: i32 = 5 + let A: Matrix = matrix_new(rows, n) + let B: Matrix = matrix_new(rows, n) + sp_fill(A.data, rows * n, 1) + sp_fill(B.data, rows * n, 4) + let mut bad: i32 = 0 + let mut i: i32 = 0 + while i < rows { + let mut j: i32 = 0 + while j < rows { + let got: f32 = sqdist_f32(A.data + i * n, B.data + j * n, n) + let want_for: f32 = sp_ref_for(A.data + i * n, B.data + j * n, n) + let want_at: f32 = sp_ref_matrix_at(A, i, B, j) + if got != want_for { bad = bad + 1 } + if got != want_at { bad = bad + 1 } + let got64: f64 = sqdist_f32_acc_f64(A.data + i * n, B.data + j * n, n) + let want64: f64 = sp_ref_f64(A, i, B, j) + if got64 != want64 { bad = bad + 1 } + j = j + 1 + } + i = i + 1 + } + matrix_free(A) + matrix_free(B) + return bad +} + +function test_sqdist_bit_exact() -> i32 { + println("Test: sqdist primitives are bit-identical to the loops they replaced") + let lengths: ptr = malloc(14 * 4) as ptr + lengths[0] = 1; lengths[1] = 2; lengths[2] = 3; lengths[3] = 4; lengths[4] = 7 + lengths[5] = 8; lengths[6] = 9; lengths[7] = 16; lengths[8] = 31; lengths[9] = 64 + lengths[10] = 100; lengths[11] = 257; lengths[12] = 784; lengths[13] = 1024 + let mut bad: i32 = 0 + let mut i: i32 = 0 + while i < 14 { + let b: i32 = sp_check_length(lengths[i]) + if b != 0 { + print(" FAIL: length ") + print(lengths[i]) + print(" differs in ") + print(b) + println(" pairs") + } + bad = bad + b + i = i + 1 + } + free(lengths as ptr) + if bad != 0 { return 1 } + println(" OK: 14 lengths, 25 row pairs each, three reference forms") + return 0 +} + +function test_sqdist_known_values() -> i32 { + println("Test: sqdist known values") + let a: ptr = array_new_f32(3) + let b: ptr = array_new_f32(3) + a[0] = 1.0; a[1] = 2.0; a[2] = 3.0 + b[0] = 4.0; b[1] = 6.0; b[2] = 3.0 + if sqdist_f32(a, b, 3) != 25.0 { + println(" FAIL: (3,4,0) should give 25") + return 1 + } + if sqdist_f32(a, a, 3) != 0.0 { + println(" FAIL: a vector is at distance 0 from itself") + return 1 + } + if sqdist_f32(a, b, 0) != 0.0 { + println(" FAIL: an empty vector has distance 0") + return 1 + } + println(" OK") + return 0 +} + +function test_dot_product_is_array_dot() -> i32 { + println("Test: dot_product and array_dot are one implementation") + let n: i32 = 103 + let a: ptr = array_new_f32(n) + let b: ptr = array_new_f32(n) + sp_fill(a, n, 2) + sp_fill(b, n, 3) + if dot_product(a, b, n) != array_dot(a, b, n) { + println(" FAIL: results differ") + return 1 + } + println(" OK") + return 0 +} + +function main() -> i32 { + println("Running shared primitive tests...") + let mut failures: i32 = 0 + if test_sqdist_bit_exact() != 0 { failures = failures + 1 } + if test_sqdist_known_values() != 0 { failures = failures + 1 } + if test_dot_product_is_array_dot() != 0 { failures = failures + 1 } + if failures == 0 { + println("All shared primitive tests passed!") + return 0 + } + print("FAILED: ") + print(failures) + println(" tests") + return 1 +} From abb57c184f0e242a8101077a6c80aa286310a1f4 Mon Sep 17 00:00:00 2001 From: Abhishek Shivakumar Date: Fri, 20 Nov 2026 00:53:22 +0000 Subject: [PATCH 2/2] Bound the primitive microbenchmark's repetition count The first CI run of bench_primitives.flow did not finish in 40 minutes. The repetition count came from a timed probe pass whose result was unused, and an optimizer is free to delete such a pass, which makes the probe read as about zero and asks for millions of repetitions. The probe result is now branched on, the count is capped so that no pass exceeds 2e8 element operations, and the CI step runs under a 10 minute timeout. --- .github/workflows/flow.yml | 2 +- benchmarks/bench_primitives.flow | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flow.yml b/.github/workflows/flow.yml index 74f9f3c..46beb9d 100644 --- a/.github/workflows/flow.yml +++ b/.github/workflows/flow.yml @@ -149,7 +149,7 @@ jobs: FLOW_HEADLINE_COMMAND: ${{ github.workspace }}/.flow-toolchain/flow run benchmarks/bench_flow_v2.flow run: | python benchmarks/run_headline.py --repeats 5 - ${{ github.workspace }}/.flow-toolchain/flow run benchmarks/bench_primitives.flow > /tmp/primitives.txt + timeout 600 ${{ github.workspace }}/.flow-toolchain/flow run benchmarks/bench_primitives.flow > /tmp/primitives.txt python benchmarks/check_primitive_bench.py /tmp/primitives.txt - uses: actions/upload-artifact@v4 diff --git a/benchmarks/bench_primitives.flow b/benchmarks/bench_primitives.flow index ce3fc32..49cb6d2 100644 --- a/benchmarks/bench_primitives.flow +++ b/benchmarks/bench_primitives.flow @@ -94,14 +94,24 @@ function bp_case(n: i32) -> void { bp_fill(A.data, rows * n, 1) bp_fill(B.data, rows * n, 4) let pairs_per_pass: i32 = rows * rows - # Aim for about 20 ms per sample. + # Aim for about 20 ms per sample. The probe result is branched on so the + # optimizer cannot delete the probe pass. A deleted probe reads as about 0 ns and + # would ask for millions of repetitions, so the count is also capped by work. let mut reps: i32 = 1 let probe_t0: i64 = flow_now_ns() let probe: f32 = bp_pass(2, A, B, rows, 1) let probe_ns: i64 = flow_now_ns() - probe_t0 + if probe < 0.0 { + printf("PROBE|negative|%d\n", n) + } if probe_ns > 0 { reps = (20000000 / probe_ns) as i32 } + # No case may run more than 2e8 element operations per pass, whatever the + # probe read. + let mut max_reps: i32 = (200000000 / ((pairs_per_pass * n) as i64)) as i32 + if max_reps < 1 { max_reps = 1 } + if reps > max_reps { reps = max_reps } if reps < 1 { reps = 1 } let samples: i32 = 9 let times: ptr = malloc((3 * samples * 8) as i64) as ptr