import { a as d, a6 as b } from "../../index-DSGwv2Yx.js";
import { isPackedTensor as p } from "../../utilities/packed.js";
import { b as l } from "../../matMul16-BIT70Vya.js";
import M from "./attentionMask32_program.js";
function w(n) {
  const { q: t, k: e } = n.inputs, { divisor: a, pastLen: o } = n.attrs, m = n.backend;
  if (p(t) && p(e))
    return l(t, e, !1, !0, { causalMask: !0, pastLen: o, scale: a });
  const s = t.shape[0], k = t.shape[2], r = e.shape[2], i = t.shape[1], c = t.shape[3];
  if (b(e.shape, [s, i, r, c], "Error in AttentionMask: "), a === 0)
    throw new Error("Divisor must be non-zero in AttentionMask");
  if (o < 0)
    throw new Error("pastLen must be non-negative in AttentionMask");
  const u = new M(s, i, k, r, c), f = [
    { type: "float32", data: [a] },
    { type: "int32", data: [o] },
    { type: "float32", data: [Number.NEGATIVE_INFINITY] }
  ], h = t.dtype;
  return m.runWebGPUProgram(u, [t, e], h, f);
}
const A = {
  kernelName: "AttentionMask",
  backendName: "webgpu",
  kernelFunc: w
};
d(A);
