import { createReduceInfo as h, reduce as g, ReduceProgram as x } from "./utils/reductions.js";
import { a as k, ah as A } from "../../index-DSGwv2Yx.js";
import { isPackedTensor as P } from "../../utilities/packed.js";
import { transpose16 as b } from "../transpose16.js";
import I from "./utils/deviceInfo.js";
import { s as w } from "../../sum-D39FeU5h.js";
import { a as D, b as K } from "../../axis_util-QWWgLjut.js";
class v extends x {
  shaderKey = "sum16";
  constructor(e, t, o) {
    super(
      e,
      t,
      {
        reductionOp: "sum",
        elementwise: !1
      },
      o
    ), o && (this.shaderKey += "_packed");
  }
}
function y(r) {
  const { x: e } = r.inputs, { axis: t, keepDims: o } = r.attrs, a = r.backend, c = [], u = I(a), m = P(e);
  if (!m)
    return w(e, t, o);
  let n = A(t ?? -1, e.shape);
  const i = D(n, e.shape.length);
  let s = e;
  i != null && (s = b(e, i), n = K(n.length, s.shape.length), c.push(s));
  const p = h([s], -1), f = new v(u, p, m), d = g(f, [s], a);
  return c.forEach((l) => l.dispose()), d;
}
const N = {
  kernelName: "Sum16",
  backendName: "webgpu",
  kernelFunc: y
};
k(N);
