call method
Implementation
({MlxArray features, List<int> lengths}) call(
MlxArray mel,
List<int> lengths,
) {
final pre = _preEncoder(mel, lengths);
final pos = _positionalEncoding(pre.features);
var hidden = pos.scaledInput;
final posEmb = pos.posEmb;
try {
if (!identical(hidden, pre.features)) {
pre.features.close();
}
final limit = maxLayers == null
? _blocks.length
: maxLayers!.clamp(0, _blocks.length);
for (var index = 0; index < limit; index += 1) {
final block = _blocks[index];
final watch = Stopwatch()..start();
final next = block(hidden, posEmb: posEmb);
hidden.close();
hidden = next;
watch.stop();
onLayerComplete?.call(index, watch.elapsed, hidden.shape);
}
MlxRuntime.evalAll(<MlxArray>[hidden]);
return (features: hidden, lengths: pre.lengths);
} finally {
posEmb.close();
}
}