import { isPackedTensor as h } from "../../utilities/packed.js";
import { a as U, m as A, b as c, j as G } from "../../index-DSGwv2Yx.js";
import { matMulMul as P } from "../matMulMul.js";
import { matMulGelu as R } from "../matMulGelu.js";
import { m as f } from "../../mat_mul-DP86qZtZ.js";
import { r as B } from "../../relu-DTvZKBsZ.js";
import { r as v } from "../../reshape-BIN71H3p.js";
import { t as b } from "../../transpose-Qxz-4os3.js";
function j(d) {
  const { A: i, B: m } = d.inputs, { transposeA: o, transposeB: a, scale: M, activation: u, scaleA: k, scaleB: w, forceOutputShape: n, perm: p } = d.attrs, g = !h(i), N = !h(m);
  if (g && N) {
    const t = k !== void 0 ? A(i, c(k)) : i, r = w !== void 0 ? A(m, c(w)) : m;
    let e;
    if (M !== void 0)
      e = P(t, r, c(M), o, a);
    else if (u === "gelu")
      e = R(t, r);
    else if (u === "relu2") {
      const s = f(t, r, o, a), l = B(s);
      s.dispose(), e = G(l), l.dispose();
    } else u === "relu" ? e = B(f(t, r, o, a)) : e = f(t, r, o, a);
    if (p)
      if (n) {
        const s = v(e, n);
        e.dispose();
        const l = b(s, p);
        return s.dispose(), l;
      } else {
        const s = b(e, p);
        return e.dispose(), s;
      }
    else if (n) {
      const s = v(e, n);
      return e.dispose(), s;
    } else
      return e;
  }
  throw new Error("Not implemented: matMul16 with packed inputs");
}
const q = {
  kernelName: "MatMul16",
  backendName: "webgl",
  kernelFunc: j
};
U(q);
