loadRouter method

Tensor loadRouter({
  1. bool keepFp16 = false,
})

Read the router weight and return it transposed to [D, E] so x @ routerW computes gate logits directly.

HF stores gate.weight as [E, D]. If keepFp16 is true the transpose is done on the fp32-promoted values (safetensors preserves fp16 only for direct reads, not through Tensor.transpose). For the router that's cheap — E is small.

Implementation

Tensor loadRouter({bool keepFp16 = false}) {
  final w = reader.readTensor(routerKey, keepFp16: keepFp16);
  return w.transpose();
}