| 167 | } |
| 168 | |
| 169 | std::pair<mx::array, mx::array> |
| 170 | GreedyDecoder::finalize(const mx::array &Tokens, const mx::array &SumLogprobs) { |
| 171 | |
| 172 | // Make sure each sequence has at least one EOT token at the end |
| 173 | std::vector<std::pair<int, int>> PadWidths = {{0, 0}, {0, 0}, {0, 1}}; |
| 174 | mx::array PaddedTokens = |
| 175 | mx::pad(Tokens, PadWidths, mx::array(Eot, mx::int32)); |
| 176 | |
| 177 | return {PaddedTokens, SumLogprobs}; |
| 178 | } |
| 179 | |
| 180 | // SuppressBlank implementation |
| 181 | SuppressBlank::SuppressBlank(std::shared_ptr<whisper::Tokenizer> Tokenizer, |