import { a as d } from "../../index-DSGwv2Yx.js";
import { c as h } from "../../concat-Dqk7Xk7h.js";
function u(p) {
  const { cache: n, item: s } = p.inputs, { maxSize: i, pastLen: c } = p.attrs, t = n.shape[0], o = n.shape[1], a = n.shape[3], e = s.shape[2];
  if (c + e <= i) {
    const f = n.slice([0, 0, 0, 0], [t, o, c, a]), m = n.slice([0, 0, c + e, 0], [t, o, i - c - e, a]), r = e < e ? s.slice([0, 0, 0, 0], [t, o, e, a]) : s, k = h([f, r, m], 2);
    return f.dispose(), m.dispose(), r !== s && r.dispose(), k;
  }
  const l = n.slice([0, 0, e, 0], [t, o, i - e, a]), C = h([l, s], 2);
  return l.dispose(), C;
}
const w = {
  kernelName: "AppendCache",
  backendName: "cpu",
  kernelFunc: u
};
d(w);
const N = {
  kernelName: "AppendCache",
  backendName: "tensorflow",
  kernelFunc: u
};
d(N);
