import { c as i, a as p, e as u } from "../index-DSGwv2Yx.js";
import { forcePacked as l, forceFloat as m } from "./grads/utils.js";
import { g } from "../axis_util-QWWgLjut.js";
import { isPackedTensor as f } from "../utilities/packed.js";
import { t as a } from "../transpose-Qxz-4os3.js";
const d = {
  kernelName: "Transpose16",
  gradFunc: (r, s, t) => {
    if (Array.isArray(r))
      throw new Error("Transpose16 gradient does not support multiple outputs.");
    const n = t, { perm: e } = n, o = g(e);
    return { x: () => T(r, o) };
  }
};
i(d);
function c(r) {
  const { inputs: s, attrs: t } = r, { x: n } = s, { perm: e } = t, o = f(n);
  if (o && e[e.length - 1] !== n.shape.length - 1)
    throw new Error("Transpose16 currently only supports the last axis being unchanged.");
  return o ? l(a(m(n), e)) : a(n, e);
}
const k = {
  kernelName: "Transpose16",
  backendName: "webgl",
  kernelFunc: c
};
p(k);
const h = {
  kernelName: "Transpose16",
  backendName: "cpu",
  kernelFunc: c
};
p(h);
function T(r, s) {
  return s == null && (s = r.shape.map((n, e) => e).reverse()), u().runKernel("Transpose16", { x: r }, { perm: s });
}
export {
  T as transpose16,
  d as transpose16GradConfig
};
