import { a as h, a6 as l } from "../../index-DSGwv2Yx.js";
import { b as f } from "../../matMul16-BIT70Vya.js";
import { slice16 as a } from "../slice16.js";
import { isPackedTensor as u } from "../../utilities/packed.js";
function k(i) {
  const { x: n, kernel: c } = i.inputs, { heads: e } = i.attrs, r = n.shape[0], t = n.shape[1], s = n.shape[2], p = u(n);
  if (l(c.shape, [p ? s * 2 : s, 3 * s], "Error in QKV: "), s % e !== 0)
    throw new Error(`Channel dimension ${s} must be divisible by number of heads ${e} in QKV.`);
  const o = f(n, c, !1, !1, {
    forceOutputShape: [r, t, 3 * e, s / e],
    perm: [0, 2, 1, 3]
  }), m = [
    a(o, [0, 0, 0, 0], [r, e, t, s / e]),
    a(o, [0, e, 0, 0], [r, e, t, s / e]),
    a(o, [0, 2 * e, 0, 0], [r, e, t, s / e])
  ];
  return o.dispose(), m;
}
const b = {
  kernelName: "QKV",
  backendName: "webgpu",
  kernelFunc: k
};
h(b);
