import { c as h, _ as f, $ as d, m as g, e as A } from "../index-DSGwv2Yx.js";
import { isPackedTensor as i } from "../utilities/packed.js";
import { sum16 as p } from "./sum16.js";
import { reshape16 as l } from "./reshape16.js";
const x = {
  kernelName: "Mul16",
  inputsToSave: ["a", "b"],
  gradFunc: (r, s) => {
    const [t, o] = s, c = f(t.shape, o.shape);
    if (Array.isArray(r))
      throw new Error("Mul16 gradFunc expected dy to be a Tensor but got an array");
    return { a: () => {
      let e = m(r, o);
      const n = d(t.shape, c);
      if (n.length > 0) {
        const u = p(e, n);
        e.dispose(), e = u;
      }
      const a = l(e, t.shape);
      return e.dispose(), a;
    }, b: () => {
      let e = m(r, t);
      const n = d(o.shape, c);
      if (n.length > 0) {
        const u = p(e, n);
        e.dispose(), e = u;
      }
      const a = l(e, o.shape);
      return e.dispose(), a;
    } };
  }
};
h(x);
function m(r, s) {
  return !i(r) && !i(s) ? g(r, s) : A().runKernel("Mul16", { a: r, b: s });
}
export {
  m as mul16
};
