function b(e) {
  const r = 4 * e.nEmbed * e.nEmbed, t = e.mlpFactor * e.nEmbed * e.nEmbed + // fc
  e.nEmbed * e.mlpFactor * e.nEmbed;
  return r + t;
}
function a(e) {
  const r = e.vocabSize * e.nEmbed, t = e.nLayer * (4 * e.nEmbed * e.nEmbed), m = e.nLayer * (e.mlpFactor * e.nEmbed * e.nEmbed + // fc
  e.nEmbed * e.mlpFactor * e.nEmbed);
  return r + t + m;
}
function o(e) {
  return a(e) * 4;
}
function E(e, r) {
  const t = o(e), m = t * 2, n = t * 2, s = r * e.blockSize * e.nEmbed * 4;
  return t + m + n + s;
}
function i(e, r) {
  const t = a(e), m = o(e) / (1024 * 1024), n = E(e, r) / (1024 * 1024);
  return {
    numParams: t,
    modelMemoryMB: m,
    trainingMemoryMB: n
  };
}
function d(e) {
  if (e.nEmbed % e.nHead !== 0)
    throw new Error("nEmbed_divisible_nHead");
  if (e.blockSize <= 0)
    throw new Error("blockSize_positive");
  if (e.vocabSize <= 0)
    throw new Error("vocabSize_positive");
  if (e.nLayer <= 0)
    throw new Error("nLayer_positive");
  if (e.mlpFactor <= 0)
    throw new Error("mlpFactor_positive");
  if (e.nEmbed / e.nHead % 2 !== 0)
    throw new Error("headDim_even");
  if (!Number.isInteger(e.nEmbed))
    throw new Error("nEmbed_integer");
  if (!Number.isInteger(e.nHead))
    throw new Error("nHead_integer");
  if (!Number.isInteger(e.nLayer))
    throw new Error("nLayer_integer");
  if (!Number.isInteger(e.blockSize))
    throw new Error("blockSize_integer");
  if (!Number.isInteger(e.vocabSize))
    throw new Error("vocabSize_integer");
}
export {
  b as estimateLayerParameters,
  o as estimateMemoryUsage,
  a as estimateParameterCount,
  i as estimateResources,
  E as estimateTrainingMemoryUsage,
  d as validateConfig
};
