MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / PieceToByte

Function PieceToByte

external/sentencepiece/src/model_interface.cc:214–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214int PieceToByte(absl::string_view piece) {
215 using PieceToByteMap = absl::flat_hash_map<std::string, unsigned char>;
216 static const auto *const kMap = []() -> PieceToByteMap * {
217 auto *m = new PieceToByteMap();
218 for (int i = 0; i < 256; ++i) {
219 (*m)[ByteToPiece(i)] = i;
220 }
221 return m;
222 }();
223 const auto it = kMap->find(std::string(piece));
224 if (it == kMap->end()) {
225 return -1;
226 } else {
227 return it->second;
228 }
229}
230
231} // namespace sentencepiece

Callers 3

TESTFunction · 0.85
DecodeMethod · 0.85
InitializePiecesMethod · 0.85

Calls 4

ByteToPieceFunction · 0.85
stringFunction · 0.50
findMethod · 0.45
endMethod · 0.45

Tested by 1

TESTFunction · 0.68