MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / compressionRatio

Function compressionRatio

plugins/wasi_nn/MLX/model/whisper/decoding.cpp:20–35  ·  view source on GitHub ↗

Utility function implementation

Source from the content-addressed store, hash-verified

18
19// Utility function implementation
20float compressionRatio(const std::string &Text) {
21 if (Text.empty())
22 return 1.0f;
23
24 std::vector<uint8_t> Input(Text.begin(), Text.end());
25 uLongf CompressedSize = compressBound(Input.size());
26 std::vector<uint8_t> Compressed(CompressedSize);
27
28 int Result =
29 compress(Compressed.data(), &CompressedSize, Input.data(), Input.size());
30
31 if (Result != Z_OK)
32 return 1.0f;
33
34 return static_cast<float>(Input.size()) / static_cast<float>(CompressedSize);
35}
36
37// Language detection implementation
38std::pair<mx::array, std::vector<std::map<std::string, float>>>

Callers 1

runMethod · 0.85

Calls 5

emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected