import { c as u } from "../../index-DSGwv2Yx.js";
import { a as f } from "../../matMul16-BIT70Vya.js";
import { concat16 as g } from "../concat16.js";
import { sum16 as l } from "../sum16.js";
import { s as k } from "../../squeeze-O_YWJpw_.js";
const i = {
  kernelName: "QKV",
  inputsToSave: ["x", "kernel"],
  outputsToSave: [],
  gradFunc: (e, s) => {
    const [r, n, t] = e, [a] = s, p = g([r, n, t], 1);
    r.dispose(), n.dispose(), t.dispose();
    const c = [a.shape[0], a.shape[1], 3 * a.shape[2]], d = f.gradFunc(p, s, {
      transposeA: !1,
      transposeB: !1,
      originalShape: c,
      perm: [0, 2, 1, 3]
    });
    return p.dispose(), {
      x: () => d.A(),
      kernel: () => {
        const o = d.B(), m = o.shape[0] === 1 ? k(o, [0]) : l(o, 0);
        return o.dispose(), m;
      }
    };
  }
};
function B(e, s, r) {
  return i.gradFunc(e, [s, r], {});
}
u(i);
export {
  B as qkvGrad
};
